2016-04-29 21:24:22 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
2016-06-14 02:40:49 +02:00
|
|
|
#move to script directory so all relative paths work
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
|
|
|
|
|
. resources/colors.sh
|
|
|
|
|
|
2016-05-26 12:55:14 +02:00
|
|
|
#Process command line options
|
2016-06-11 16:52:38 +02:00
|
|
|
ARGS=$(getopt -n 'install.sh' -o h -l help,use-switch-source,use-switch-package-all,use-switch-master,use-switch-package-unofficial-arm,no-cpu-check -- "$@")
|
2016-05-26 12:55:14 +02:00
|
|
|
|
2016-06-11 16:52:38 +02:00
|
|
|
if [ $? -ne 0 ]; then
|
2016-06-14 02:40:49 +02:00
|
|
|
error "Failed parsing options."
|
2016-06-11 16:52:38 +02:00
|
|
|
exit 1
|
|
|
|
|
fi
|
2016-05-26 12:55:14 +02:00
|
|
|
|
2016-06-04 21:21:32 +02:00
|
|
|
export USE_SWITCH_SOURCE=false
|
|
|
|
|
export USE_SWITCH_PACKAGE_ALL=false
|
|
|
|
|
export USE_SWITCH_PACKAGE_UNOFFICIAL_ARM=false
|
|
|
|
|
export USE_SWITCH_MASTER=false
|
2016-06-11 16:52:38 +02:00
|
|
|
export CPU_CHECK=true
|
2016-05-26 12:55:14 +02:00
|
|
|
HELP=false
|
|
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
|
case "$1" in
|
2016-06-04 21:21:32 +02:00
|
|
|
--use-switch-source ) export USE_SWITCH_SOURCE=true; shift ;;
|
|
|
|
|
--use-switch-package-all ) export USE_SWITCH_PACKAGE_ALL=true; shift ;;
|
|
|
|
|
--use-switch-package-unofficial-arm ) export USE_SWITCH_PACKAGE_UNOFFICIAL_ARM=true; shift ;;
|
|
|
|
|
--use-switch-master ) export USE_SWITCH_MASTER=true; shift ;;
|
2016-06-11 16:52:38 +02:00
|
|
|
--no-cpu-check ) export CPU_CHECK=false; shift ;;
|
2016-05-26 12:55:14 +02:00
|
|
|
-h | --help ) HELP=true; shift ;;
|
|
|
|
|
-- ) shift; break ;;
|
|
|
|
|
* ) break ;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ $HELP = true ]; then
|
2016-06-14 02:40:49 +02:00
|
|
|
warning "Debian installer script"
|
|
|
|
|
warning " --use-switch-source will use freeswitch from source rather than ${green}(default:packages)"
|
|
|
|
|
warning " --use-switch-package-all if using packages use the meta-all package"
|
|
|
|
|
warning " --use-switch-package-unofficial-arm if your system is arm and you are using packages, use the unofficial arm repo"
|
|
|
|
|
warning " --use-switch-master will use master branch/packages instead of ${green}(default:stable)"
|
|
|
|
|
warning " --no-cpu-check disable the cpu check ${green}(default:check)"
|
2016-05-26 12:55:14 +02:00
|
|
|
exit;
|
|
|
|
|
fi
|
|
|
|
|
|
2016-06-11 16:52:38 +02:00
|
|
|
if [ $CPU_CHECK = true ]; then
|
|
|
|
|
#check what the CPU is
|
|
|
|
|
OS_bits=$(uname -m)
|
|
|
|
|
OS_arch=$(uname -m)
|
|
|
|
|
CPU_bits='i686'
|
2016-08-05 16:10:39 +02:00
|
|
|
if [ "$(grep -o -w 'lm' /proc/cpuinfo)" = 'lm' ]; then
|
2016-06-11 16:52:38 +02:00
|
|
|
CPU_bits='x86_64'
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ $USE_SWITCH_SOURCE = false ]; then
|
|
|
|
|
if [ $OS_arch = 'armv7l' ]; then
|
2016-08-05 16:10:39 +02:00
|
|
|
if [ $USE_SWITCH_PACKAGE_UNOFFICIAL_ARM = false ] && [ OS_bits = 'i686' ]; then
|
2016-06-14 02:40:49 +02:00
|
|
|
error "You are using a 32bit arm OS this is unsupported"
|
|
|
|
|
warning " please rerun with either --use-switch-package-unofficial-arm or --use-switch-source"
|
2016-06-11 16:52:38 +02:00
|
|
|
exit 3
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
if [ $OS_bits = 'i686' ]; then
|
2016-06-14 02:40:49 +02:00
|
|
|
error "You are using a 32bit OS this is unsupported"
|
2016-06-11 16:52:38 +02:00
|
|
|
if [ $CPU_bits = 'x86_64' ]; then
|
2016-06-14 02:40:49 +02:00
|
|
|
error "Your CPU is 64bit you should consider reinstalling with a 64bit OS"
|
2016-06-11 16:52:38 +02:00
|
|
|
fi
|
2016-06-14 02:40:49 +02:00
|
|
|
warning " please rerun with --use-switch-source"
|
2016-06-11 16:52:38 +02:00
|
|
|
exit 3
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2016-06-08 15:04:57 +02:00
|
|
|
# removes the cd img from the /etc/apt/sources.list file (not needed after base install)
|
|
|
|
|
sed -i '/cdrom:/d' /etc/apt/sources.list
|
|
|
|
|
|
2016-04-29 21:24:22 +02:00
|
|
|
#Update Debian
|
2016-06-14 02:40:49 +02:00
|
|
|
verbose "Update Debian"
|
2016-04-29 21:24:22 +02:00
|
|
|
apt-get upgrade && apt-get update -y --force-yes
|
|
|
|
|
|
|
|
|
|
#IPTables
|
2016-05-26 12:55:14 +02:00
|
|
|
resources/iptables.sh
|
2016-04-29 21:24:22 +02:00
|
|
|
|
|
|
|
|
#FusionPBX
|
2016-05-26 12:55:14 +02:00
|
|
|
resources/fusionpbx.sh
|
2016-04-29 21:24:22 +02:00
|
|
|
|
|
|
|
|
#NGINX web server
|
2016-05-26 12:55:14 +02:00
|
|
|
resources/nginx.sh
|
2016-04-29 21:24:22 +02:00
|
|
|
|
2016-08-02 19:14:57 +02:00
|
|
|
#PHP
|
|
|
|
|
resources/php.sh
|
|
|
|
|
|
2016-04-29 21:24:22 +02:00
|
|
|
#Fail2ban
|
2016-05-26 12:55:14 +02:00
|
|
|
resources/fail2ban.sh
|
2016-04-29 21:24:22 +02:00
|
|
|
|
|
|
|
|
#FreeSWITCH
|
2016-06-04 21:21:32 +02:00
|
|
|
if [ $USE_SWITCH_SOURCE = true ]; then
|
|
|
|
|
if [ $USE_SWITCH_MASTER = true ]; then
|
2016-05-26 12:55:14 +02:00
|
|
|
resources/switch/source-master.sh
|
|
|
|
|
else
|
|
|
|
|
resources/switch/source-release.sh
|
|
|
|
|
fi
|
|
|
|
|
resources/switch/source-permissions.sh
|
|
|
|
|
else
|
2016-06-04 21:21:32 +02:00
|
|
|
if [ $USE_SWITCH_MASTER = true ]; then
|
|
|
|
|
if [ $USE_SWITCH_PACKAGE_ALL = true ]; then
|
2016-05-26 12:55:14 +02:00
|
|
|
resources/switch/package-master-all.sh
|
|
|
|
|
else
|
|
|
|
|
resources/switch/package-master.sh
|
|
|
|
|
fi
|
|
|
|
|
else
|
2016-06-04 21:21:32 +02:00
|
|
|
if [ $USE_SWITCH_PACKAGE_ALL = true ]; then
|
2016-05-26 12:55:14 +02:00
|
|
|
resources/switch/package-all.sh
|
|
|
|
|
else
|
|
|
|
|
resources/switch/package-release.sh
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
resources/switch/package-permissions.sh
|
|
|
|
|
fi
|
2016-04-29 21:24:22 +02:00
|
|
|
|
|
|
|
|
#Postgres
|
2016-05-26 12:55:14 +02:00
|
|
|
resources/postgres.sh
|
2016-04-29 21:24:22 +02:00
|
|
|
|
|
|
|
|
#set the ip address
|
|
|
|
|
server_address=$(hostname -I)
|
|
|
|
|
|
|
|
|
|
#restart services
|
2016-06-11 16:50:10 +02:00
|
|
|
systemctl daemon-reload
|
|
|
|
|
systemctl try-restart freeswitch
|
|
|
|
|
systemctl daemon-reload
|
|
|
|
|
systemctl restart php5-fpm
|
|
|
|
|
systemctl restart nginx
|
|
|
|
|
systemctl restart fail2ban
|
2016-04-29 21:24:22 +02:00
|
|
|
|
|
|
|
|
#Show database password
|
2016-06-14 02:40:49 +02:00
|
|
|
verbose "Complete the install by by going to the IP address of this server ";
|
|
|
|
|
verbose "in your web browser or with a domain name for this server.";
|
2016-04-29 21:24:22 +02:00
|
|
|
echo " https://$server_address"
|
|
|
|
|
echo ""
|
|
|
|
|
echo ""
|
|
|
|
|
|
2016-05-10 00:30:26 +02:00
|
|
|
#wait for the config.php to exist and then restart the service
|
2016-05-10 19:15:14 +02:00
|
|
|
#resources/./finish.sh
|