2017-01-12 05:03:09 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
#move to script directory so all relative paths work
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
|
|
|
|
|
#includes
|
|
|
|
|
. ./colors.sh
|
|
|
|
|
. ./arguments.sh
|
|
|
|
|
|
|
|
|
|
#database details
|
|
|
|
|
database_host=127.0.0.1
|
|
|
|
|
database_port=5432
|
|
|
|
|
database_username=fusionpbx
|
|
|
|
|
database_password=$(dd if=/dev/urandom bs=1 count=20 2>/dev/null | base64 | sed 's/[=\+//]//g')
|
|
|
|
|
|
|
|
|
|
#allow the script to use the new password
|
|
|
|
|
export PGPASSWORD=$database_password
|
|
|
|
|
|
|
|
|
|
#update the 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';"
|
|
|
|
|
|
|
|
|
|
#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_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
|
|
|
|
|
|
2017-01-15 08:05:48 +01:00
|
|
|
#get the server hostname
|
|
|
|
|
#domain_name=$(hostname -f)
|
|
|
|
|
|
|
|
|
|
#get the ip address
|
|
|
|
|
domain_name=$(hostname -I | cut -d ' ' -f1)
|
|
|
|
|
|
|
|
|
|
#get a domain_uuid
|
2017-01-12 05:03:09 +01:00
|
|
|
domain_uuid=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php);
|
2017-01-15 08:05:48 +01:00
|
|
|
|
|
|
|
|
#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);
|
|
|
|
|
user_name=admin
|
|
|
|
|
user_password=$(dd if=/dev/urandom bs=1 count=12 2>/dev/null | base64 | sed 's/[=\+//]//g')
|
|
|
|
|
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:]]*$//')
|
|
|
|
|
|
|
|
|
|
#add the user to the group
|
|
|
|
|
group_user_uuid=$(/usr/bin/php /var/www/fusionpbx/resources/uuid.php);
|
|
|
|
|
group_name=superadmin
|
|
|
|
|
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('$group_user_uuid', '$domain_uuid', '$group_name', '$group_uuid', '$user_uuid');"
|
2016-11-25 18:06:21 +01:00
|
|
|
|
|
|
|
|
#restart freeswitch
|
|
|
|
|
/bin/systemctl daemon-reload
|
|
|
|
|
/bin/systemctl restart freeswitch
|
2017-01-12 05:03:09 +01:00
|
|
|
|
|
|
|
|
#welcome message
|
|
|
|
|
echo ""
|
|
|
|
|
echo ""
|
|
|
|
|
verbose "Installation has completed."
|
|
|
|
|
echo ""
|
|
|
|
|
echo " Use a web browser to login."
|
2017-01-15 08:05:48 +01:00
|
|
|
echo " domain name: https://$domain_name"
|
2017-01-12 05:03:09 +01:00
|
|
|
echo " username: $user_name"
|
|
|
|
|
echo " password: $user_password"
|
|
|
|
|
echo ""
|
2017-01-15 08:05:48 +01:00
|
|
|
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"
|
|
|
|
|
echo " Admin Training 24 - 26 Jan (3 Days)"
|
|
|
|
|
echo " Advanced Training 31 Jan - Feb 2 (3 Days)"
|
|
|
|
|
echo " Timezone: https://www.timeanddate.com/worldclock/usa/boise"
|
|
|
|
|
echo " For more info visit https://www.fusionpbx.com"
|
|
|
|
|
echo ""
|
2017-01-15 08:56:37 +01:00
|
|
|
echo " Additional information."
|
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 ""
|
2017-01-15 08:48:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|