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")"
|
|
|
|
|
|
2016-10-01 00:59:58 +02:00
|
|
|
. ./resources/colors.sh
|
|
|
|
|
. ./resources/arguments.sh
|
2016-05-26 12:55:14 +02:00
|
|
|
|
2017-02-24 17:54:19 +01:00
|
|
|
if [ .$CPU_CHECK = .true ] && [ .$USE_SWITCH_SOURCE = .false ]; then
|
2016-08-15 17:22:23 +02:00
|
|
|
#check what the CPU and OS are
|
|
|
|
|
OS_test=$(uname -m)
|
|
|
|
|
CPU_arch='unknown'
|
|
|
|
|
OS_bits='unknown'
|
|
|
|
|
CPU_bits='unknown'
|
2017-02-24 17:54:19 +01:00
|
|
|
if [ .$OS_test = .'armv7l' ]; then
|
2016-08-15 17:22:23 +02:00
|
|
|
OS_bits='32'
|
|
|
|
|
CPU_bits='32'
|
|
|
|
|
# RaspberryPi 3 is actually armv8l but current Raspbian reports the cpu as armv7l and no Raspbian 64Bit has been released at this time
|
|
|
|
|
CPU_arch='arm'
|
2017-02-24 17:54:19 +01:00
|
|
|
elif [ .$OS_test = .'armv8l' ]; then
|
2016-08-15 17:22:23 +02:00
|
|
|
# We currently have no test case for armv8l
|
|
|
|
|
OS_bits='unknown'
|
|
|
|
|
CPU_bits='64'
|
|
|
|
|
CPU_arch='arm'
|
2017-02-24 17:54:19 +01:00
|
|
|
elif [ .$OS_test = .'i386' ]; then
|
2016-08-15 17:22:23 +02:00
|
|
|
OS_bits='32'
|
2017-02-24 17:54:19 +01:00
|
|
|
if [ .$(grep -o -w 'lm' /proc/cpuinfo | head -n 1) = .'lm' ]; then
|
2016-08-15 17:22:23 +02:00
|
|
|
CPU_bits='64'
|
|
|
|
|
else
|
|
|
|
|
CPU_bits='32'
|
|
|
|
|
fi
|
|
|
|
|
CPU_arch='x86'
|
2017-02-24 17:54:19 +01:00
|
|
|
elif [ .$OS_test = .'i686' ]; then
|
2016-08-15 17:22:23 +02:00
|
|
|
OS_bits='32'
|
2017-02-24 17:54:19 +01:00
|
|
|
if [ .$(grep -o -w 'lm' /proc/cpuinfo | head -n 1) = .'lm' ]; then
|
2016-08-15 17:22:23 +02:00
|
|
|
CPU_bits='64'
|
|
|
|
|
else
|
|
|
|
|
CPU_bits='32'
|
|
|
|
|
fi
|
|
|
|
|
CPU_arch='x86'
|
2017-02-24 17:54:19 +01:00
|
|
|
elif [ .$OS_test = .'x86_64' ]; then
|
2016-08-15 17:22:23 +02:00
|
|
|
OS_bits='64'
|
2017-02-24 17:54:19 +01:00
|
|
|
if [ .$(grep -o -w 'lm' /proc/cpuinfo | head -n 1) = .'lm' ]; then
|
2016-08-15 17:22:23 +02:00
|
|
|
CPU_bits='64'
|
|
|
|
|
else
|
|
|
|
|
CPU_bits='32'
|
|
|
|
|
fi
|
|
|
|
|
CPU_arch='x86'
|
2016-06-11 16:52:38 +02:00
|
|
|
fi
|
|
|
|
|
|
2017-02-24 17:54:19 +01:00
|
|
|
if [ .$CPU_arch = .'arm' ]; then
|
|
|
|
|
if [ .$OS_bits = .'32' ]; then
|
2016-08-25 23:38:52 +02:00
|
|
|
export USE_SWITCH_PACKAGE_UNOFFICIAL_ARM=true
|
|
|
|
|
verbose "Correct CPU/OS detected, using unofficial arm repo"
|
2017-02-24 17:54:19 +01:00
|
|
|
elif [ .$OS_bits = .'64' ]; then
|
2016-08-15 17:22:23 +02:00
|
|
|
error "You are using a 64bit arm OS this is unsupported"
|
|
|
|
|
warning " please rerun with --use-switch-source"
|
|
|
|
|
exit 3
|
2016-06-11 16:52:38 +02:00
|
|
|
else
|
2016-08-15 17:22:23 +02:00
|
|
|
error "Unknown OS_bits $OS_bits this is unsupported"
|
|
|
|
|
warning " please rerun with --use-switch-source"
|
|
|
|
|
exit 3
|
|
|
|
|
fi
|
2017-02-24 17:54:19 +01:00
|
|
|
elif [ .$CPU_arch = .'x86' ]; then
|
|
|
|
|
if [ .$OS_bits = .'32' ]; then
|
2016-08-15 17:22:23 +02:00
|
|
|
error "You are using a 32bit OS this is unsupported"
|
2017-02-24 17:54:19 +01:00
|
|
|
if [ .$CPU_bits = .'64' ]; then
|
2016-08-15 17:22:23 +02:00
|
|
|
warning " Your CPU is 64bit you should consider reinstalling with a 64bit OS"
|
2016-06-11 16:52:38 +02:00
|
|
|
fi
|
2016-08-15 17:22:23 +02:00
|
|
|
warning " please rerun with --use-switch-source"
|
|
|
|
|
exit 3
|
2017-02-24 17:54:19 +01:00
|
|
|
elif [ .$OS_bits = .'64' ]; then
|
2016-08-15 17:22:23 +02:00
|
|
|
verbose "Correct CPU/OS detected"
|
|
|
|
|
else
|
|
|
|
|
error "Unknown OS_bits $OS_bits this is unsupported"
|
|
|
|
|
warning " please rerun with --use-switch-source"
|
|
|
|
|
exit 3
|
2016-06-11 16:52:38 +02:00
|
|
|
fi
|
2016-08-15 17:22:23 +02:00
|
|
|
else
|
|
|
|
|
error "You are using a unsupported architecture $CPU_arch"
|
2016-06-11 16:52:38 +02:00
|
|
|
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
|
|
|
|
|
|
2017-02-25 02:15:15 +01:00
|
|
|
#Add dependencies
|
|
|
|
|
apt-get install -y lsb-release
|
|
|
|
|
|
2016-04-29 21:24:22 +02:00
|
|
|
#IPTables
|
2016-05-26 12:55:14 +02:00
|
|
|
resources/iptables.sh
|
2016-04-29 21:24:22 +02:00
|
|
|
|
2017-01-12 05:12:21 +01:00
|
|
|
#FusionPBX
|
|
|
|
|
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
|
2017-02-24 17:54:19 +01: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
|
2016-08-16 22:15:18 +02:00
|
|
|
|
|
|
|
|
#copy the switch conf files to /etc/freeswitch
|
|
|
|
|
resources/switch/conf-copy.sh
|
|
|
|
|
|
2016-08-16 19:47:08 +02:00
|
|
|
#set the file permissions
|
|
|
|
|
resources/switch/source-permissions.sh
|
2016-08-16 07:07:30 +02:00
|
|
|
|
2016-08-16 19:55:14 +02:00
|
|
|
#systemd service
|
|
|
|
|
resources/switch/source-systemd.sh
|
|
|
|
|
|
2016-05-26 12:55:14 +02:00
|
|
|
else
|
2017-02-24 17:54:19 +01: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
|
2017-02-24 17:54:19 +01: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
|
2016-08-16 22:15:18 +02:00
|
|
|
|
|
|
|
|
#copy the switch conf files to /etc/freeswitch
|
|
|
|
|
resources/switch/conf-copy.sh
|
|
|
|
|
|
2016-08-16 19:47:08 +02:00
|
|
|
#set the file permissions
|
|
|
|
|
resources/switch/package-permissions.sh
|
2016-08-16 07:07:30 +02:00
|
|
|
|
2016-08-16 19:55:14 +02:00
|
|
|
#systemd service
|
|
|
|
|
resources/switch/package-systemd.sh
|
|
|
|
|
|
2016-05-26 12:55:14 +02:00
|
|
|
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
|
2017-02-28 17:32:26 +01:00
|
|
|
if [ .$USE_PHP5_PACKAGE = .true ]; then
|
|
|
|
|
systemctl restart php5-fpm
|
|
|
|
|
else
|
|
|
|
|
systemctl restart php7.0-fpm
|
|
|
|
|
fi
|
2016-06-11 16:50:10 +02:00
|
|
|
systemctl restart nginx
|
|
|
|
|
systemctl restart fail2ban
|
2016-04-29 21:24:22 +02:00
|
|
|
|
2017-01-12 05:12:21 +01:00
|
|
|
#add the database schema, user and groups
|
|
|
|
|
resources/finish.sh
|