fusionpbx-install.sh/debian/resources/finish.sh

137 lines
6.3 KiB
Bash
Raw Normal View History

2017-01-12 05:03:09 +01:00
#!/bin/sh
#move to script directory so all relative paths work
cd "$(dirname "$0")"
#includes
2017-03-04 20:49:27 +01:00
. ./config.sh
2017-01-12 05:03:09 +01:00
. ./colors.sh
#database details
database_username=fusionpbx
2017-03-19 06:03:37 +01:00
if [ .$database_password = .'random' ]; then
database_password=$(dd if=/dev/urandom bs=1 count=20 2>/dev/null | base64 | sed 's/[=\+//]//g')
fi
2017-01-12 05:03:09 +01:00
#allow the script to use the new password
export PGPASSWORD=$database_password
#update the database password
2020-08-19 20:47:00 +02:00
#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';"
2017-01-12 05:03:09 +01:00
sudo -u postgres psql -c "ALTER USER fusionpbx WITH PASSWORD '$database_password';"
sudo -u postgres psql -c "ALTER USER freeswitch WITH PASSWORD '$database_password';"
2018-12-11 09:27:32 +01:00
#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
2017-01-12 05:03:09 +01:00
#add the config.php
mkdir -p /etc/fusionpbx
chown -R www-data:www-data /etc/fusionpbx
cp fusionpbx/config.php /etc/fusionpbx
sed -i /etc/fusionpbx/config.php -e s:"{database_host}:$database_host:"
2017-01-12 05:03:09 +01:00
sed -i /etc/fusionpbx/config.php -e s:'{database_username}:fusionpbx:'
sed -i /etc/fusionpbx/config.php -e s:"{database_password}:$database_password:"
#add the database schema
cd /var/www/fusionpbx && php /var/www/fusionpbx/core/upgrade/upgrade_schema.php > /dev/null 2>&1
#get the server hostname
2017-07-29 19:09:14 +02:00
if [ .$domain_name = .'hostname' ]; then
domain_name=$(hostname -f)
fi
#get the ip address
2017-07-29 19:09:14 +02:00
if [ .$domain_name = .'ip_address' ]; then
domain_name=$(hostname -I | cut -d ' ' -f1)
fi
2017-07-29 19:20:22 +02:00
#get the domain_uuid
2017-01-12 05:03:09 +01:00
domain_uuid=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php);
#add the domain name
2017-01-12 05:03:09 +01:00
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
cd /var/www/fusionpbx && php /var/www/fusionpbx/core/upgrade/upgrade_domains.php
#add the user
user_uuid=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php);
user_salt=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php);
2017-03-19 06:03:37 +01:00
user_name=$system_username
if [ .$system_password = .'random' ]; then
2019-11-28 01:58:14 +01:00
user_password=$(dd if=/dev/urandom bs=1 count=20 2>/dev/null | base64 | sed 's/[=\+//]//g')
2017-03-19 06:03:37 +01:00
else
user_password=$system_password
fi
2017-01-12 05:03:09 +01:00
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
2020-08-18 04:03:10 +02:00
#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';");
2017-01-12 05:03:09 +01:00
#add the user to the group
2019-02-09 18:51:32 +01:00
user_group_uuid=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php);
2017-01-12 05:03:09 +01:00
group_name=superadmin
2019-02-10 16:44:45 +01:00
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');"
2019-02-10 16:44:45 +01:00
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
2017-01-15 21:38:42 +01:00
#update xml_cdr url, user and password
2019-11-28 01:58:14 +01:00
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')
2017-01-15 21:38:42 +01:00
sed -i /etc/freeswitch/autoload_configs/xml_cdr.conf.xml -e s:"{v_http_protocol}:http:"
2020-08-19 20:47:00 +02:00
sed -i /etc/freeswitch/autoload_configs/xml_cdr.conf.xml -e s:"{domain_name}:$database_host:"
2017-01-15 21:38:42 +01:00
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:"
2017-01-15 10:34:02 +01:00
#app defaults
cd /var/www/fusionpbx && php /var/www/fusionpbx/core/upgrade/upgrade_domains.php
#restart freeswitch
/bin/systemctl daemon-reload
/bin/systemctl restart freeswitch
2021-10-14 19:47:02 +02:00
/bin/systemctl restart php${php_version}-fpm
2017-01-12 05:03:09 +01:00
#welcome message
echo ""
echo ""
verbose "Installation has completed."
echo ""
echo " Use a web browser to login."
echo " domain name: https://$domain_name"
2017-01-12 05:03:09 +01:00
echo " username: $user_name"
echo " password: $user_password"
echo ""
echo " The domain name in the browser is used by default as part of the authentication."
echo " If you need to login to a different domain then use username@domain."
echo " username: $user_name@$domain_name";
2017-01-12 05:03:09 +01:00
echo ""
2017-01-15 08:48:56 +01:00
echo " Official FusionPBX Training"
2017-03-05 18:50:21 +01:00
echo " Fastest way to learn FusionPBX. For more information https://www.fusionpbx.com."
2017-03-03 21:08:54 +01:00
echo " Available online and in person. Includes documentation and recording."
2017-01-15 08:48:56 +01:00
echo ""
2018-12-06 05:41:34 +01:00
echo " Location: Online"
2019-12-12 03:08:18 +01:00
echo " Admin Training: TBA"
2020-03-07 20:03:41 +01:00
echo " Advanced Training: TBA"
2021-10-07 03:30:53 +02:00
echo " Continuing Education: https://www.fusionpbx.com/training"
2018-12-06 05:41:34 +01:00
echo " Timezone: https://www.timeanddate.com/weather/usa/idaho"
2017-04-16 19:57:58 +02:00
echo ""
2017-01-15 08:56:37 +01:00
echo " Additional information."
2019-06-06 18:33:26 +02:00
echo " https://fusionpbx.com/members.php"
2017-11-29 09:24:10 +01:00
echo " https://fusionpbx.com/training.php"
2017-01-15 08:48:56 +01:00
echo " https://fusionpbx.com/support.php"
2017-01-12 05:03:09 +01:00
echo " https://www.fusionpbx.com"
echo " http://docs.fusionpbx.com"
echo ""