Devuan: update all install scripts from debian (#390)

* devuan: pull fail2ban updates from debian installer

* devuan: merge updates to postgresql.sh from debian

* devuan: pull updated resources/backup scripts from debian

* devuan: merge and update php installer scripts

* devuan: merged changes to reset_admin_password.sh from debian

* devuan: fix release name typo for chimaera

* devuan: merge iptables changes from debian

* devuan: merge nginx changes from debian

* devuan: merge letsencrypt.sh from debian

* devuan: merge main install scripts and config from debian

* devuan: simplify sngrep install, its in all maintained releases

* devuan: merge main install script updates from debian

* devuan: finish.sh: use /usr/sbin/service for restart

* devuan: postgresql.sh: fix syntax error

* devuan: update and unify sysvinit setup

there is no sysvinit package available from freeswitch,
usethe same init and defaults file for package and source install

* devuan: add equvalent debian releasesto environment.sh

* devuan: merge changes to switch* from debian

* devuan: switch: use os_codenam_debian to add repos

* devuan: olny stop ufw if it was installed

* devuan: update config.sh defaults

* devuan: remove systemd-specifics from switch package installation

* devuan: install postgres before freeswitch

* devuan: removed libyuv-dev installation, embedded in freeswitch

* devuan: fix failing move of freeswitch music

* devuan: removed another libyuv-dev installation, embedded in freeswitch

* devuan: revert freeswitch script dir setting in /etc/default

* devuan: Enable mod_av for the install. (#389)

* devuan: merge improved nginx ssl settings (#388)
This commit is contained in:
Valentin
2022-04-19 03:37:02 +02:00
committed by GitHub
parent d3974e1584
commit 9f550a3c42
37 changed files with 1188 additions and 712 deletions

View File

@@ -6,64 +6,29 @@ cd "$(dirname "$0")"
#includes
. ./config.sh
. ./colors.sh
. ./environment.sh
#database details
database_host=127.0.0.1
database_port=5432
database_username=fusionpbx
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
verbose "Create the database and users"
#allow the script to use the new password
export PGPASSWORD=$database_password
#
# Install the database backup scripts
#
#update the database password
#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
chmod 755 /etc/cron.daily/fusionpbx-backup.sh
sed -i "s/zzz/${database_password}/g" /etc/cron.daily/fusionpbx-backup.sh
#
# Install the maintenance script
#
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
#install the database backup
cp backup/fusionpbx-backup /etc/cron.daily
cp backup/fusionpbx-maintenance /etc/cron.daily
chmod 755 /etc/cron.daily/fusionpbx-backup
chmod 755 /etc/cron.daily/fusionpbx-maintenance
sed -i "s/zzz/$database_password/g" /etc/cron.daily/fusionpbx-backup
sed -i "s/zzz/$database_password/g" /etc/cron.daily/fusionpbx-maintenance
#add the config.php
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
#get the server hostname
#domain_name=$(hostname -f)
if [ .$domain_name = .'hostname' ]; then
domain_name=$(hostname -f)
fi
#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);
#allow the script to use the new password
export PGPASSWORD=$database_password
#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');"
#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
#add the user
@@ -99,45 +65,47 @@ user_uuid=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php);
user_salt=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php);
user_name=$system_username
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
user_password=$system_password
fi
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');"
#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';");
group_uuid=$(echo $group_uuid | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
#get the superadmin group_uuid
#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=$(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
user_group_uuid=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php);
group_name=superadmin
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');"
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');"
fi
fi
#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_password=$(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=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:"{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_user}:$xml_cdr_username:"
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
cd /var/www/fusionpbx && php /var/www/fusionpbx/core/upgrade/upgrade_domains.php
#app defaults
cd /var/www/fusionpbx && php /var/www/fusionpbx/core/upgrade/upgrade.php
#restart freeswitch
/usr/sbin/service freeswitch restart
#welcome message
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 " Use a web browser to login."
echo " domain name: https://$domain_name"
@@ -153,8 +121,8 @@ echo " Fastest way to learn FusionPBX. For more information https://www.fus
echo " Available online and in person. Includes documentation and recording."
echo ""
echo " Location: Online"
echo " Admin Training: TBA"
echo " Advanced Training: TBA"
echo " Admin Training: TBA"
echo " Advanced Training: TBA"
echo " Continuing Education: https://www.fusionpbx.com/training"
echo " Timezone: https://www.timeanddate.com/weather/usa/idaho"
echo ""