devuan: merge main install scripts and config from debian

This commit is contained in:
Valentin Kleibel 2022-04-04 16:47:02 +02:00
parent e7ed1f7398
commit 9a32caccab
5 changed files with 89 additions and 93 deletions

View File

@ -42,11 +42,12 @@ resources/sngrep.sh
resources/postgresql.sh resources/postgresql.sh
#restart services #restart services
if [ ."$php_version" = ."5" ]; then #php-fpm
service php5-fpm restart if [ ."$php_version" = ."7.3" ]; then
/usr/sbin/service php7.3-fpm restart
fi fi
if [ ."$php_version" = ."7" ]; then if [ ."$php_version" = ."7.4" ]; then
service php7.0-fpm restart /usr/sbin/service php7.4-fpm restart
fi fi
service nginx restart service nginx restart

View File

@ -1,18 +1,26 @@
# FusionPBX Settings # FusionPBX Settings
domain_name=ip_address # hostname, ip_address or a custom value
system_username=admin # default username admin system_username=admin # default username admin
system_password=random # random or as a pre-set value system_password=random # random or a custom value
system_branch=stable # master, stable system_branch=master # master, stable
# FreeSWITCH Settings # FreeSWITCH Settings
switch_branch=stable # master, stable switch_branch=stable # master, stable
switch_source=false # true or false switch_source=true # true (source compile) or false (binary package)
switch_package=true # true or false switch_package=false # true (binary package) or false (source compile)
switch_version=1.10.7 # which source code to download, only for source
switch_tls=true # true or false
switch_token= # Get the auth token from https://signalwire.com
# Signup or Login -> Profile -> Personal Auth Token
# Database Settings # Database Settings
database_password=random # random or as a pre-set value database_password=random # random or a custom value (safe characters A-Z, a-z, 0-9)
database_repo=system # PostgreSQL official, system, 2ndquadrant database_repo=official # PostgreSQL official, system, 2ndquadrant
database_version=latest # requires repo official
database_host=127.0.0.1 # hostname or IP address
database_port=5432 # port number
database_backup=false # true or false database_backup=false # true or false
# General Settings # General Settings
php_version=7 # PHP version 5 or 7 php_version=7.4 # PHP version 7.1, 7.3, 7.4
letsencrypt_folder=true # true or false

View File

@ -1,5 +1,8 @@
#!/bin/sh #!/bin/sh
#make sure lsb release is installed
apt-get install lsb-release
#operating system details #operating system details
os_name=$(lsb_release -is) os_name=$(lsb_release -is)
os_codename=$(lsb_release -cs) os_codename=$(lsb_release -cs)
@ -10,8 +13,16 @@ cpu_name=$(uname -m)
cpu_architecture='unknown' cpu_architecture='unknown'
cpu_mode='unknown' cpu_mode='unknown'
#set the environment path
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#check what the CPU and OS are #check what the CPU and OS are
if [ .$cpu_name = .'armv7l' ]; then if [ .$cpu_name = .'armv6l' ]; then
# RaspberryPi Zero
os_mode='32'
cpu_mode='32'
cpu_architecture='arm'
elif [ .$cpu_name = .'armv7l' ]; then
# RaspberryPi 3 is actually armv8l but current Raspbian reports the cpu as armv7l and no Raspbian 64Bit has been released at this time # RaspberryPi 3 is actually armv8l but current Raspbian reports the cpu as armv7l and no Raspbian 64Bit has been released at this time
os_mode='32' os_mode='32'
cpu_mode='32' cpu_mode='32'
@ -21,6 +32,10 @@ elif [ .$cpu_name = .'armv8l' ]; then
os_mode='unknown' os_mode='unknown'
cpu_mode='64' cpu_mode='64'
cpu_architecture='arm' cpu_architecture='arm'
elif [ .$cpu_name = .'aarch64' ]; then
os_mode='64'
cpu_mode='64'
cpu_architecture='arm'
elif [ .$cpu_name = .'i386' ]; then elif [ .$cpu_name = .'i386' ]; then
os_mode='32' os_mode='32'
if [ .$(grep -o -w 'lm' /proc/cpuinfo | head -n 1) = .'lm' ]; then if [ .$(grep -o -w 'lm' /proc/cpuinfo | head -n 1) = .'lm' ]; then

View File

@ -6,64 +6,29 @@ cd "$(dirname "$0")"
#includes #includes
. ./config.sh . ./config.sh
. ./colors.sh . ./colors.sh
. ./environment.sh
#database details #database details
database_host=127.0.0.1
database_port=5432
database_username=fusionpbx database_username=fusionpbx
if [ .$database_password = .'random' ]; then if [ .$database_password = .'random' ]; then
database_password="$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 20 | xargs)" database_password=$(dd if=/dev/urandom bs=1 count=20 2>/dev/null | base64 | sed 's/[=\+//]//g')
fi fi
verbose "Create the database and users" #allow the script to use the new password
export PGPASSWORD=$database_password
# #update the database password
# Install the database backup scripts #sudo -u postgres psql --host=$database_host --port=$database_port --username=$database_username -c "ALTER USER fusionpbx WITH PASSWORD '$database_password';"
# #sudo -u postgres psql --host=$database_host --port=$database_port --username=$database_username -c "ALTER USER freeswitch WITH PASSWORD '$database_password';"
sudo -u postgres psql -c "ALTER USER fusionpbx WITH PASSWORD '$database_password';"
sudo -u postgres psql -c "ALTER USER freeswitch WITH PASSWORD '$database_password';"
cp backup/fusionpbx-backup.sh /etc/cron.daily #install the database backup
chmod 755 /etc/cron.daily/fusionpbx-backup.sh cp backup/fusionpbx-backup /etc/cron.daily
sed -i "s/zzz/${database_password}/g" /etc/cron.daily/fusionpbx-backup.sh cp backup/fusionpbx-maintenance /etc/cron.daily
chmod 755 /etc/cron.daily/fusionpbx-backup
# chmod 755 /etc/cron.daily/fusionpbx-maintenance
# Install the maintenance script sed -i "s/zzz/$database_password/g" /etc/cron.daily/fusionpbx-backup
# sed -i "s/zzz/$database_password/g" /etc/cron.daily/fusionpbx-maintenance
cp backup/fusionpbx-maintenance.sh /etc/cron.daily
chmod 755 /etc/cron.daily/fusionpbx-maintenance.sh
sed -i "s/zzz/${database_password}/g" /etc/cron.daily/fusionpbx-maintenance.sh
#
# Move to /tmp to prevent a red herring error when running sudo with psql
#
cwd=$(pwd)
cd /tmp
#
# I'm not sure why we would do this when the databases don't exist yet.
#
#sudo -u postgres psql -d fusionpbx -c "DROP SCHEMA public cascade;";
#sudo -u postgres psql -d fusionpbx -c "CREATE SCHEMA public;";
sudo -u postgres psql -c "CREATE DATABASE fusionpbx;";
sudo -u postgres psql -c "CREATE ROLE fusionpbx WITH SUPERUSER LOGIN PASSWORD '$database_password';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE fusionpbx to fusionpbx;"
#
# Maybe the freeswitch will use the freeswitch database in the future?
# Right now it's configured to use SQLite.
# So we will comment this out.
#
#sudo -u postgres psql -c "CREATE DATABASE freeswitch;";
#sudo -u postgres psql -c "CREATE ROLE freeswitch WITH SUPERUSER LOGIN PASSWORD '$password';"
#sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to fusionpbx;"
#sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to freeswitch;"
cd $cwd
#add the config.php #add the config.php
mkdir -p /etc/fusionpbx mkdir -p /etc/fusionpbx
@ -77,21 +42,22 @@ sed -i /etc/fusionpbx/config.php -e s:"{database_password}:$database_password:"
cd /var/www/fusionpbx && php /var/www/fusionpbx/core/upgrade/upgrade_schema.php > /dev/null 2>&1 cd /var/www/fusionpbx && php /var/www/fusionpbx/core/upgrade/upgrade_schema.php > /dev/null 2>&1
#get the server hostname #get the server hostname
#domain_name=$(hostname -f) if [ .$domain_name = .'hostname' ]; then
domain_name=$(hostname -f)
fi
#get the ip address #get the ip address
domain_name=$(hostname -I | cut -d ' ' -f1) if [ .$domain_name = .'ip_address' ]; then
domain_name=$(hostname -I | cut -d ' ' -f1)
fi
#get a domain_uuid #get the domain_uuid
domain_uuid=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php); domain_uuid=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php);
#allow the script to use the new password
export PGPASSWORD=$database_password
#add the domain name #add the domain name
psql --host=$database_host --port=$database_port --username=$database_username -c "insert into v_domains (domain_uuid, domain_name, domain_enabled) values('$domain_uuid', '$domain_name', 'true');" psql --host=$database_host --port=$database_port --username=$database_username -c "insert into v_domains (domain_uuid, domain_name, domain_enabled) values('$domain_uuid', '$domain_name', 'true');"
#app defaults - this is needed here otherwise group superadmin will not exist for "get the superadmin group_uuid" * #app defaults
cd /var/www/fusionpbx && php /var/www/fusionpbx/core/upgrade/upgrade_domains.php cd /var/www/fusionpbx && php /var/www/fusionpbx/core/upgrade/upgrade_domains.php
#add the user #add the user
@ -99,45 +65,48 @@ user_uuid=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php);
user_salt=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php); user_salt=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php);
user_name=$system_username user_name=$system_username
if [ .$system_password = .'random' ]; then if [ .$system_password = .'random' ]; then
user_password="$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 12 | xargs)" user_password=$(dd if=/dev/urandom bs=1 count=20 2>/dev/null | base64 | sed 's/[=\+//]//g')
else else
user_password=$system_password user_password=$system_password
fi fi
password_hash=$(php -r "echo md5('$user_salt$user_password');"); password_hash=$(php -r "echo md5('$user_salt$user_password');");
psql --host=$database_host --port=$database_port --username=$database_username -t -c "insert into v_users (user_uuid, domain_uuid, username, password, salt, user_enabled) values('$user_uuid', '$domain_uuid', '$user_name', '$password_hash', '$user_salt', 'true');" psql --host=$database_host --port=$database_port --username=$database_username -t -c "insert into v_users (user_uuid, domain_uuid, username, password, salt, user_enabled) values('$user_uuid', '$domain_uuid', '$user_name', '$password_hash', '$user_salt', 'true');"
#get the superadmin group_uuid * #get the superadmin group_uuid
group_uuid=$(psql --host=$database_host --port=$database_port --username=$database_username -t -c "select group_uuid from v_groups where group_name = 'superadmin';"); #echo "psql --host=$database_host --port=$database_port --username=$database_username -qtAX -c \"select group_uuid from v_groups where group_name = 'superadmin';\""
group_uuid=$(echo $group_uuid | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//') group_uuid=$(psql --host=$database_host --port=$database_port --username=$database_username -qtAX -c "select group_uuid from v_groups where group_name = 'superadmin';");
#add the user to the group #add the user to the group
user_group_uuid=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php); user_group_uuid=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php);
group_name=superadmin group_name=superadmin
if [ .$system_branch = .'master' ]; then if [ .$system_branch = .'master' ]; then
#echo "insert into v_user_groups (user_group_uuid, domain_uuid, group_name, group_uuid, user_uuid) values('$user_group_uuid', '$domain_uuid', '$group_name', '$group_uuid', '$user_uuid');"
psql --host=$database_host --port=$database_port --username=$database_username -c "insert into v_user_groups (user_group_uuid, domain_uuid, group_name, group_uuid, user_uuid) values('$user_group_uuid', '$domain_uuid', '$group_name', '$group_uuid', '$user_uuid');" psql --host=$database_host --port=$database_port --username=$database_username -c "insert into v_user_groups (user_group_uuid, domain_uuid, group_name, group_uuid, user_uuid) values('$user_group_uuid', '$domain_uuid', '$group_name', '$group_uuid', '$user_uuid');"
else else
psql --host=$database_host --port=$database_port --username=$database_username -c "insert into v_group_users (group_user_uuid, domain_uuid, group_name, group_uuid, user_uuid) values('$user_group_uuid', '$domain_uuid', '$group_name', '$group_uuid', '$user_uuid');" psql --host=$database_host --port=$database_port --username=$database_username -c "insert into v_group_users (group_user_uuid, domain_uuid, group_name, group_uuid, user_uuid) values('$user_group_uuid', '$domain_uuid', '$group_name', '$group_uuid', '$user_uuid');"
fi fi
#update xml_cdr url, user and password #update xml_cdr url, user and password
xml_cdr_username=$(dd if=/dev/urandom bs=1 count=12 2>/dev/null | base64 | sed 's/[=\+//]//g') xml_cdr_username=$(dd if=/dev/urandom bs=1 count=20 2>/dev/null | base64 | sed 's/[=\+//]//g')
xml_cdr_password=$(dd if=/dev/urandom bs=1 count=12 2>/dev/null | base64 | sed 's/[=\+//]//g') xml_cdr_password=$(dd if=/dev/urandom bs=1 count=20 2>/dev/null | base64 | sed 's/[=\+//]//g')
sed -i /etc/freeswitch/autoload_configs/xml_cdr.conf.xml -e s:"{v_http_protocol}:http:" sed -i /etc/freeswitch/autoload_configs/xml_cdr.conf.xml -e s:"{v_http_protocol}:http:"
sed -i /etc/freeswitch/autoload_configs/xml_cdr.conf.xml -e s:"{domain_name}:127.0.0.1:" sed -i /etc/freeswitch/autoload_configs/xml_cdr.conf.xml -e s:"{domain_name}:$database_host:"
sed -i /etc/freeswitch/autoload_configs/xml_cdr.conf.xml -e s:"{v_project_path}::" sed -i /etc/freeswitch/autoload_configs/xml_cdr.conf.xml -e s:"{v_project_path}::"
sed -i /etc/freeswitch/autoload_configs/xml_cdr.conf.xml -e s:"{v_user}:$xml_cdr_username:" sed -i /etc/freeswitch/autoload_configs/xml_cdr.conf.xml -e s:"{v_user}:$xml_cdr_username:"
sed -i /etc/freeswitch/autoload_configs/xml_cdr.conf.xml -e s:"{v_pass}:$xml_cdr_password:" sed -i /etc/freeswitch/autoload_configs/xml_cdr.conf.xml -e s:"{v_pass}:$xml_cdr_password:"
#app defaults - not sure if this needs to be executed again #app defaults
cd /var/www/fusionpbx && php /var/www/fusionpbx/core/upgrade/upgrade_domains.php cd /var/www/fusionpbx && php /var/www/fusionpbx/core/upgrade/upgrade.php
/usr/sbin/service freeswitch restart #restart freeswitch
/bin/systemctl daemon-reload
/bin/systemctl restart freeswitch
#welcome message #welcome message
echo "" echo ""
echo "" echo ""
verbose "Installation has completed." verbose "Installation Notes. "
echo ""
echo " Please save the this information and reboot this system to complete the install. "
echo "" echo ""
echo " Use a web browser to login." echo " Use a web browser to login."
echo " domain name: https://$domain_name" echo " domain name: https://$domain_name"

View File

@ -6,16 +6,15 @@ cd "$(dirname "$0")"
#includes #includes
. ./config.sh . ./config.sh
. ./colors.sh . ./colors.sh
. ./environment.sh
#send a message #send a message
verbose "Installing FusionPBX" verbose "Installing FusionPBX"
#install dependencies #install dependencies
apt-get install -qq -y git dbus haveged ssl-cert apt-get install -y vim git dbus haveged ssl-cert qrencode
apt-get install -qq -y ghostscript libtiff5-dev libtiff-tools at apt-get install -y ghostscript libtiff5-dev libtiff-tools at
#set the version #get the branch
if [ .$system_branch = .'master' ]; then if [ .$system_branch = .'master' ]; then
verbose "Using master" verbose "Using master"
branch="" branch=""
@ -27,6 +26,10 @@ else
branch="-b $system_version" branch="-b $system_version"
fi fi
#add the cache directory
mkdir -p /var/cache/fusionpbx
chown -R www-data:www-data /var/cache/fusionpbx
#get the source code #get the source code
git clone $branch https://github.com/fusionpbx/fusionpbx.git /var/www/fusionpbx git clone $branch https://github.com/fusionpbx/fusionpbx.git /var/www/fusionpbx
chown -R www-data:www-data /var/www/fusionpbx chown -R www-data:www-data /var/www/fusionpbx