- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
#!/usr/bin/env bash
ROOT_UID=0 # root uid is 0
E_NOTROOT=67 # Non-root exit error
# define freepbx config file if not alreaddy set
if [ -z "$FREEPBX_CONF" ]; then
if [ -e "/etc/freepbx.conf" ]; then
FREEPBX_CONF="/etc/freepbx.conf"
elif [ -e "/etc/asterisk/freepbx.conf" ]; then
FREEPBX_CONF="/etc/asterisk/freepbx.conf"
else
FREEPBX_CONF="/etc/freepbx.conf"
fi
fi
echo
# check to see if we are root
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Sorry, you must be root to run this script."
echo
exit $E_NOTROOT
fi
# get settings from db/config file
if [[ -e $FREEPBX_CONF && -w "/etc/amportal.conf" && -z "$FORCE_AMPORTAL_CONF" ]]; then # Check if file exists.
php -r > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Please wait..."
`php -r '
$bootstrap_settings["freepbx_auth"] = false;
$bootstrap_settings["skip_astman"] = true;
$restrict_mods = true;
if (!@include_once(getenv("FREEPBX_CONF") ? getenv("FREEPBX_CONF") : "/etc/freepbx.conf")) {
include_once("/etc/asterisk/freepbx.conf");
}
foreach($amp_conf as $key => $val) {
if (is_bool($val)) {
echo "export " . trim($key) . "=" . ($val?"TRUE":"FALSE") ."\n";
} else {
echo "export " . trim($key) . "=" . escapeshellcmd(trim($val)) ."\n";
}
}
'`
elif [ -e "/var/lib/asterisk/bin/gen_amp_conf.php" ]; then
echo "Fetching FreePBX settings with gen_amp_conf.php.."
`/var/lib/asterisk/bin/gen_amp_conf.php`
elif [ -e "/etc/amportal.conf" ]; then # Check if file exists.
echo "Fetching settings from amportal.conf file.."
. /etc/amportal.conf
else
echo;
echo "FreePBX settings could not be fetched and no backup config file found!";
echo "Have you installed FreePBX?";
exit;
fi
elif [ -e "/etc/amportal.conf" ]; then # Check if file exists.
. /etc/amportal.conf
else
echo;
echo "FreePBX config file not found!";
echo "Have you installed FreePBX?";
exit;
fi
if [ -x ${AMPBIN}/freepbx_engine ]; then
${AMPBIN}/freepbx_engine $@
elif [ -x ${ASTVARLIBDIR}/bin/freepbx_engine ]; then
${ASTVARLIBDIR}/bin/freepbx_engine $@
elif [ -x /var/lib/asterisk/bin/freepbx_engine ]; then
/var/lib/asterisk/bin/freepbx_engine $@
else
echo "FATAL: can not find freepbx_engine to start Asterisk"
fi