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
#restart services
if [ ."$php_version" = ."5" ]; then
service php5-fpm restart
#php-fpm
if [ ."$php_version" = ."7.3" ]; then
/usr/sbin/service php7.3-fpm restart
fi
if [ ."$php_version" = ."7" ]; then
service php7.0-fpm restart
if [ ."$php_version" = ."7.4" ]; then
/usr/sbin/service php7.4-fpm restart
fi
service nginx restart

View File

@ -1,18 +1,26 @@
# FusionPBX Settings
system_username=admin # default username admin
system_password=random # random or as a pre-set value
system_branch=stable # master, stable
domain_name=ip_address # hostname, ip_address or a custom value
system_username=admin # default username admin
system_password=random # random or a custom value
system_branch=master # master, stable
# FreeSWITCH Settings
switch_branch=stable # master, stable
switch_source=false # true or false
switch_package=true # true or false
switch_branch=stable # master, stable
switch_source=true # true (source compile) or false (binary package)
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_password=random # random or as a pre-set value
database_repo=system # PostgreSQL official, system, 2ndquadrant
database_backup=false # true or false
database_password=random # random or a custom value (safe characters A-Z, a-z, 0-9)
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
# 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
#make sure lsb release is installed
apt-get install lsb-release
#operating system details
os_name=$(lsb_release -is)
os_codename=$(lsb_release -cs)
@ -10,8 +13,16 @@ cpu_name=$(uname -m)
cpu_architecture='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
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
os_mode='32'
cpu_mode='32'
@ -21,6 +32,10 @@ elif [ .$cpu_name = .'armv8l' ]; then
os_mode='unknown'
cpu_mode='64'
cpu_architecture='arm'
elif [ .$cpu_name = .'aarch64' ]; then
os_mode='64'
cpu_mode='64'
cpu_architecture='arm'
elif [ .$cpu_name = .'i386' ]; then
os_mode='32'
if [ .$(grep -o -w 'lm' /proc/cpuinfo | head -n 1) = .'lm' ]; then

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,48 @@ 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
/usr/sbin/service freeswitch restart
#restart freeswitch
/bin/systemctl daemon-reload
/bin/systemctl restart freeswitch
#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 +122,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 ""

View File

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