Freepbx16 on debian11 user...sh: 1: runuser: not found

fresh install on Debian 11.2 Bullseye (net install nothing loaded but ssh)

Here are the commands i used to install. For brevity i will show the commands that ran fine and errors i encountered along the way.

apt install sudo

sudo apt -y install build-essential git curl wget libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev libjansson-dev libxml2-dev uuid-dev default-libmysqlclient-dev apache2 mariadb-server mariadb-client php php-curl php-cli php-pdo php-mysql php-pear php-gd php-mbstring php-intl php-bcmath sox mpg123 lame ffmpeg sqlite3  unixodbc sudo dirmngr postfix odbc-mariadb php-ldap nodejs npm pkg-config libicu-dev

sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.4/apache2/php.ini
sed -i 's/\(^memory_limit = \).*/\1256M/' /etc/php/7.4/apache2/php.ini
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
sudo a2enmod rewrite
systemctl restart apache2
rm /var/www/html/index.html

cat <<EOF > /etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL (MariaDB)
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so
FileUsage = 1
EOF

cat <<EOF > /etc/odbc.ini
[MySQL-asteriskcdrdb]
Description = MySQL connection to 'asteriskcdrdb' database
Driver = MySQL
Server = localhost
Database = asteriskcdrdb
Port = 3306
Socket = /var/run/mysqld/mysqld.sock
Option = 3
EOF

cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz
tar zxvf asterisk-18-current.tar.gz
ls
cd asterisk-18.10.1
sudo contrib/scripts/get_mp3_source.sh
sudo contrib/scripts/install_prereq install
./configure
make menuselect
make 
make install
sudo make config
sudo ldconfig
make install-logrotate

sudo groupadd asterisk
sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk
sudo usermod -aG audio,dialout asterisk
sudo chown -R asterisk.asterisk /etc/asterisk
sudo chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
sudo chown -R asterisk.asterisk /usr/lib/asterisk

cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/7.4/freepbx-16.0-latest.tgz
tar zxvf freepbx-16.0-latest.tgz
cd /usr/src/freepbx/

[email protected]:/usr/src/freepbx# ./start_asterisk start


STARTING ASTERISK
Asterisk Started
[email protected]:/usr/src/freepbx# ./install -n
Assuming you are Database Root
Checking if SELinux is enabled...Its not (good)!
Reading /etc/asterisk/asterisk.conf...Done
Checking if Asterisk is running and we can talk to it as the 'asterisk' user...sh: 1: runuser: not found
Error!
Error communicating with Asterisk.  Ensure that Asterisk is properly installed and running as the asterisk user
Asterisk appears to be running as asterisk
Try starting Asterisk with the './start_asterisk start' command in this directory
[email protected]:/usr/src/freepbx#

[email protected]:/home/s2angel# systemctl status asterisk
* asterisk.service - LSB: Asterisk PBX
     Loaded: loaded (/etc/init.d/asterisk; generated)
     Active: active (exited) since Sun 2022-03-06 20:52:09 EST; 11h ago
       Docs: man:systemd-sysv-generator(8)
    Process: 19363 ExecStart=/etc/init.d/asterisk start (code=exited, status=0/SUCCESS)
        CPU: 292ms

Mar 06 20:52:09 pbx systemd[1]: Starting LSB: Asterisk PBX...
Mar 06 20:52:09 pbx asterisk[19363]: Starting Asterisk PBX: asterisk.
Mar 06 20:52:09 pbx systemd[1]: Started LSB: Asterisk PBX.
[email protected]:/usr/src/freepbx# ps aux | grep asterisk
asterisk  407470  0.0  1.7 224632  8672 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
asterisk  407471  0.0  1.7 224632  8672 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
asterisk  407472  0.0  1.7 224632  8672 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
asterisk  407473  0.0  1.7 224632  8672 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
asterisk  407474  0.0  1.7 224632  8672 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
root      410219  0.0  0.2   2420  1324 pts/1    S    08:36   0:00 /bin/sh /usr/sbin/safe_asterisk -U asterisk -G asterisk
root      410300  0.0  0.1   3180   724 pts/1    S+   08:36   0:00 grep asterisk
[email protected]:/usr/src/freepbx#  





I am not able to get past this install of freepbx16 Is there something I missed? I have installations going back almost all versions. Have not done a install with latest for a good while and i am stuck please help

Is runuser installed? Can you execute from the CLI? If not, that’s your problem.

you are trying to start asterisk with the old system V init.d script.

In the source contrib/init.d and contrib/systemd are useful files to read for very old Debian versions and more recent ones.

Debian likes to have /etc/default/asterisk fixed
FreePBX systemd service likes to start asterisk with fwconsole

runuser what is that. I have asterisk user? is that a thing I did a search for runuser in my debian 11

# apt search runuser
Sorting... Done
Full Text Search... Done

I got nothing am i missing a program or a repository I need to add to get that where do i get that?

Dicko I am not running a very old debian distro?

I use fwconsole am I miss understanding you?

I looked up /etc/default/asterisk and added user group but still nothing

# cat /etc/default/asterisk
AST_USER="asterisk"
AST_GROUP="asterisk"
[email protected]:~$ /sbin/runuser --help

Usage:
 runuser [options] -u <user> [[--] <command>]
 runuser [options] [-] [<user> [<argument>...]]

Run <command> with the effective user ID and group ID of <user>.  If -u is
not given, fall back to su(1)-compatible semantics and execute standard shell.
The options -c, -f, -l, and -s are mutually exclusive with -u.

https://manpages.debian.org/stretch/util-linux/runuser.1.en.html

If I where you I would

systemctl disable asterisk
rm /etc/init.d/asterisk 

which would stop safe_asterisk or /etc/init.d/sterisk from running, then I would reboot my machine and then

fwconsole restart

and see what happens

oh wow ok… I use to just do su asterisk
learned something new. Although maybe I am doing something wrong or…

[email protected]:/usr/src/freepbx# runuser -u asterisk /usr/sbin/safe_asterisk
bash: runuser: command not found
[email protected]:/usr/src/freepbx# /sbin/runuser -u asterisk /usr/sbin/safe_asterisk
Oops. I'm not root. Falling back to standard prio and file max.
This is NOT suitable for large systems.
id: cannot print only names or real IDs in default format
/usr/sbin/safe_asterisk: 41: cannot create /dev/9: Permission denied
/usr/sbin/safe_asterisk: 175: cannot open /dev/tty9: Permission denied

Dicko,

I have not got freepbx installed yet so fwconsole will not work yet

[email protected]:/usr/src/freepbx# systemctl disable asterisk
asterisk.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable asterisk
[email protected]:/usr/src/freepbx# rm /etc/init.d/asterisk
[email protected]:/usr/src/freepbx# fwconsole restart
bash: fwconsole: command not found
[email protected]:/usr/src/freepbx#

As I said, in the src/contrib/systemd directory is an ‘asterisk.service’ file which works for versions of Debian newer than 2015 that use systemd which work in the absence of FreePBX

Intresting I am not able to just run
runuser

i have to literly type
/sbin/runuser

maybe i need to fix something on my debian 11 with runuser how urgh maybe thats why my freepbx install fails with

./install -n

[email protected]:/usr/src/freepbx# ./install -n
Assuming you are Database Root
Checking if SELinux is enabled...Its not (good)!
Reading /etc/asterisk/asterisk.conf...Done
Checking if Asterisk is running and we can talk to it as the 'asterisk' user...sh: 1: runuser: not found
Error!
Error communicating with Asterisk.  Ensure that Asterisk is properly installed and running as the asterisk user
Asterisk appears to be running as asterisk
Try starting Asterisk with the './start_asterisk start' command in this directory
[email protected]:/usr/src/freepbx#

how the heck do I fix that if thats the problem… ?

simply add it’s location your path

PATH=$PATH:/sbin

ok Dicko thanks for that . now thats fixed

but now my error is a bit different

[email protected]:/usr/src/freepbx# ./install -n
Assuming you are Database Root
Checking if SELinux is enabled...Its not (good)!
Reading /etc/asterisk/asterisk.conf...Done
Checking if Asterisk is running and we can talk to it as the 'asterisk' user...sh: 1: runuser: not found
Error!
Error communicating with Asterisk.  Ensure that Asterisk is properly installed and running as the asterisk user
Asterisk appears to be running as asterisk
Try starting Asterisk with the './start_asterisk start' command in this directory
[email protected]:/usr/src/freepbx# runuser
bash: runuser: command not found
[email protected]:/usr/src/freepbx# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
[email protected]:/usr/src/freepbx# export PATH="$PATH:/sbin"
[email protected]:/usr/src/freepbx# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin
[email protected]:/usr/src/freepbx# runuser
[email protected]:/usr/src/freepbx# ./install -n
Assuming you are Database Root
Checking if SELinux is enabled...Its not (good)!
Reading /etc/asterisk/asterisk.conf...Done
Checking if Asterisk is running and we can talk to it as the 'asterisk' user...Error!
Error communicating with Asterisk.  Ensure that Asterisk is properly installed and running as the asterisk user
Asterisk appears to be running as asterisk
Try starting Asterisk with the './start_asterisk start' command in this directory
[email protected]:/usr/src/freepbx#

did you yrt

Try starting Asterisk with the ‘./start_asterisk start’ command in this directory
[email protected]:/usr/src/freepbx#
?

After killing off any asterisk

# cd /usr/src/freepbx
[email protected]:/usr/src/freepbx# ps aux |grep asterisk
asterisk  407470  0.0  1.1 224632  5468 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
asterisk  407471  0.0  1.1 224632  5496 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
asterisk  407472  0.0  1.1 224632  5488 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
asterisk  407473  0.0  1.1 224632  5488 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
asterisk  407474  0.0  1.1 224632  5524 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
root      549586  0.0  0.1   3180   648 pts/0    S+   17:35   0:00 grep asterisk
[email protected]:/usr/src/freepbx# ./start_asterisk start


STARTING ASTERISK
Asterisk Started
[email protected]:/usr/src/freepbx# ./install -n
Assuming you are Database Root
Checking if SELinux is enabled...Its not (good)!
Reading /etc/asterisk/asterisk.conf...Done
Checking if Asterisk is running and we can talk to it as the 'asterisk' user...sh: 1: runuser: not found
Error!
Error communicating with Asterisk.  Ensure that Asterisk is properly installed and running as the asterisk user
Asterisk appears to be running as asterisk
Try starting Asterisk with the './start_asterisk start' command in this directory
[email protected]:/usr/src/freepbx# ps aux |grep asterisk
asterisk  407470  0.0  1.1 224632  5468 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
asterisk  407471  0.0  1.1 224632  5496 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
asterisk  407472  0.0  1.1 224632  5488 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
asterisk  407473  0.0  1.1 224632  5488 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
asterisk  407474  0.0  1.1 224632  5524 ?        S    08:31   0:00 /usr/sbin/apache2 -k start
root      549602  0.0  0.2   2420  1316 pts/0    S    17:35   0:00 /bin/sh /usr/sbin/safe_asterisk -U asterisk -G asterisk
root      549978  0.0  0.1   3180   648 pts/0    S+   17:36   0:00 grep asterisk
[email protected]:/usr/src/freepbx# 

its seems to run asterisk as user root?

no. i runs safe_asterisk as root
safe_asterisk should start asterisk as asterisk

does

/usr/sbin/asterisk -f -U asterisk -G asterisk -vvvg -c

start an asterisk ‘console’ ?

[email protected]:/usr/src/freepbx# /usr/sbin/asterisk -f -U asterisk -G asterisk -vvvg -c
Asterisk 18.10.1, Copyright (C) 1999 - 2021, Sangoma Technologies Corporation and others.
Created by Mark Spencer <[email protected]>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Running as user 'asterisk'
Running under group 'asterisk'
Manager registered action DBGet
Manager registered action DBPut
Manager registered action DBDel
Manager registered action DBDelTree
PBX UUID: fcb0828f-a3e7-46b7-8505-721f3b55218a
Unable to load config file 'stasis.conf'
Could not load Stasis configuration; using defaults
Registered 'audio' codec 'codec2' at sample rate '8000' with id '1'
Created cached format with name 'codec2'
Registered 'audio' codec 'g723' at sample rate '8000' with id '2'
Created cached format with name 'g723'
Registered 'audio' codec 'ulaw' at sample rate '8000' with id '3'
Created cached format with name 'ulaw'
Registered 'audio' codec 'alaw' at sample rate '8000' with id '4'
Created cached format with name 'alaw'
Registered 'audio' codec 'gsm' at sample rate '8000' with id '5'
Created cached format with name 'gsm'
Registered 'audio' codec 'g726' at sample rate '8000' with id '6'
Created cached format with name 'g726'
Registered 'audio' codec 'g726aal2' at sample rate '8000' with id '7'
Created cached format with name 'g726aal2'
Registered 'audio' codec 'adpcm' at sample rate '8000' with id '8'
Created cached format with name 'adpcm'
Registered 'audio' codec 'slin' at sample rate '8000' with id '9'
Created cached format with name 'slin'
Registered 'audio' codec 'slin' at sample rate '12000' with id '10'
Created cached format with name 'slin12'
Registered 'audio' codec 'slin' at sample rate '16000' with id '11'
Created cached format with name 'slin16'
Registered 'audio' codec 'slin' at sample rate '24000' with id '12'
Created cached format with name 'slin24'
Registered 'audio' codec 'slin' at sample rate '32000' with id '13'
Created cached format with name 'slin32'
Registered 'audio' codec 'slin' at sample rate '44100' with id '14'
Created cached format with name 'slin44'
Registered 'audio' codec 'slin' at sample rate '48000' with id '15'
Created cached format with name 'slin48'
Registered 'audio' codec 'slin' at sample rate '96000' with id '16'
Created cached format with name 'slin96'
Registered 'audio' codec 'slin' at sample rate '192000' with id '17'
Created cached format with name 'slin192'
Registered 'audio' codec 'lpc10' at sample rate '8000' with id '18'
Created cached format with name 'lpc10'
Registered 'audio' codec 'g729' at sample rate '8000' with id '19'
Created cached format with name 'g729'
Registered 'audio' codec 'speex' at sample rate '8000' with id '20'
Created cached format with name 'speex'
Registered 'audio' codec 'speex' at sample rate '16000' with id '21'
Created cached format with name 'speex16'
Registered 'audio' codec 'speex' at sample rate '32000' with id '22'
Created cached format with name 'speex32'
Registered 'audio' codec 'ilbc' at sample rate '8000' with id '23'
Created cached format with name 'ilbc'
Registered 'audio' codec 'g722' at sample rate '16000' with id '24'
Created cached format with name 'g722'
Registered 'audio' codec 'siren7' at sample rate '16000' with id '25'
Created cached format with name 'siren7'
Registered 'audio' codec 'siren14' at sample rate '32000' with id '26'
Created cached format with name 'siren14'
Registered 'audio' codec 'testlaw' at sample rate '8000' with id '27'
Created cached format with name 'testlaw'
Registered 'audio' codec 'g719' at sample rate '48000' with id '28'
Created cached format with name 'g719'
Registered 'audio' codec 'opus' at sample rate '48000' with id '29'
Created cached format with name 'opus'
Registered 'image' codec 'jpeg' at sample rate '0' with id '30'
Created cached format with name 'jpeg'
Registered 'image' codec 'png' at sample rate '0' with id '31'
Created cached format with name 'png'
Registered 'video' codec 'h261' at sample rate '1000' with id '32'
Created cached format with name 'h261'
Registered 'video' codec 'h263' at sample rate '1000' with id '33'
Created cached format with name 'h263'
Registered 'video' codec 'h263p' at sample rate '1000' with id '34'
Created cached format with name 'h263p'
Registered 'video' codec 'h264' at sample rate '1000' with id '35'
Created cached format with name 'h264'
Registered 'video' codec 'h265' at sample rate '1000' with id '36'
Created cached format with name 'h265'
Registered 'video' codec 'mpeg4' at sample rate '1000' with id '37'
Created cached format with name 'mpeg4'
Registered 'video' codec 'vp8' at sample rate '1000' with id '38'
Created cached format with name 'vp8'
Registered 'video' codec 'vp9' at sample rate '1000' with id '39'
Created cached format with name 'vp9'
Registered 'text' codec 'red' at sample rate '0' with id '40'
Created cached format with name 'red'
Registered 'text' codec 't140' at sample rate '0' with id '41'
Created cached format with name 't140'
Registered 'image' codec 't38' at sample rate '0' with id '42'
Created cached format with name 't38'
Registered 'audio' codec 'none' at sample rate '8000' with id '43'
Created cached format with name 'none'
Registered 'audio' codec 'silk' at sample rate '8000' with id '44'
Created cached format with name 'silk8'
Registered 'audio' codec 'silk' at sample rate '12000' with id '45'
Created cached format with name 'silk12'
Registered 'audio' codec 'silk' at sample rate '16000' with id '46'
Created cached format with name 'silk16'
Registered 'audio' codec 'silk' at sample rate '24000' with id '47'
Created cached format with name 'silk24'
Sorcery registered wizard 'bucket'
Sorcery registered wizard 'bucket_file'
[Mar  7 17:48:10] ERROR[553202]: logger.c:1985 init_logger: Errors detected in logger.conf.  Default console logging is being used.
  == Message handler 'dialplan' registered.
  == Registered custom function 'MESSAGE'
  == Registered custom function 'MESSAGE_DATA'
  == Registered application 'MessageSend'
  == Manager registered action MessageSend
  == Registered channel type 'Surrogate' (Surrogate channel used to pull channel from an application)
  == Manager registered action BridgeTechnologyList
  == Manager registered action BridgeTechnologySuspend
  == Manager registered action BridgeTechnologyUnsuspend
  == Registered DNS resolver 'system' with priority '2147483647'
 Asterisk PBX Core Initializing
  == Registering builtin functions:
  == Registered custom function 'EXCEPTION'
  == Registered custom function 'TESTTIME'
  == Manager registered action ShowDialPlan
  == Manager registered action ExtensionStateList
  == Registered application 'Answer'
  == Registered application 'BackGround'
  == Registered application 'Busy'
  == Registered application 'Congestion'
  == Registered application 'ExecIfTime'
  == Registered application 'Goto'
  == Registered application 'GotoIf'
  == Registered application 'GotoIfTime'
  == Registered application 'ImportVar'
  == Registered application 'Hangup'
  == Registered application 'Incomplete'
  == Registered application 'NoOp'
  == Registered application 'Proceeding'
  == Registered application 'Progress'
  == Registered application 'RaiseException'
  == Registered application 'Ringing'
  == Registered application 'SayAlpha'
  == Registered application 'SayAlphaCase'
  == Registered application 'SayDigits'
  == Registered application 'SayMoney'
  == Registered application 'SayNumber'
  == Registered application 'SayOrdinal'
  == Registered application 'SayPhonetic'
  == Registered application 'SetAMAFlags'
  == Registered application 'Wait'
  == Registered application 'WaitDigit'
  == Registered application 'WaitExten'
  == Registered application 'Set'
  == Registered application 'MSet'
  == Registered channel type 'Local' (Local Proxy Channel Driver)
  == Manager registered action LocalOptimizeAway
 Asterisk Dynamic Loader Starting:
[Mar  7 17:48:10] WARNING[553202]: loader.c:2224 loader_config_init: 'modules.conf' invalid or missing.
[Mar  7 17:48:10] ERROR[553202]: asterisk.c:3938 check_init: Module initialization failed.  ASTERISK EXITING!

  == Manager unregistered action DBGet
  == Manager unregistered action DBPut
  == Manager unregistered action DBDel
  == Manager unregistered action DBDelTree
    -- Remote UNIX connection
    -- Remote UNIX connection disconnected
[email protected]:/usr/src/freepbx#

That says your /etc/asterisk/modules.conf is missing (or currupt) , make sure you didn’t miss any steps when .configure’ing, make menuconfig’ing, compiling, make’ing and make install’ing asterisk.

Given this and your missing path’s , starting over would not be a bad idea

How did you get the root shell? /sbin should be in the path for root, but if you su, without a -, root’s environment will not be set up. I think the same is true for sudo.

are you saying I should be runing these commands from the user account I have on my system using sudo?

i have always used su and did the install in root for all the older versions of debian and asterisk freepbx

I’m suggesting that you should be using “su -”, rather than just su.

However I have an upgraded old Debian, and it is possible that you can’t get a login shell for root that way, on your version.

IMHO it is most simple to install FreePBX/Asterisk as root.
Both sudo and su logins of various flavors have some subtle differences in the environment you will encounter (but both have man pages to explain the differences)