· 11 years ago · May 28, 2015, 01:45 AM
1#!/bin/bash
2############################
3#Date May 27, 2015 17:10 CST
4############################
5# The MIT License (MIT)
6################################################################################
7# Copyright (c) <2015> <kb3vgw@gmail.com> Richard Neese
8################################################################################
9# Permission is hereby granted, free of charge, to any person obtaining a copy
10# of this software and associated documentation files (the "Software"), to deal
11# in the Software without restriction, including without limitation the rights
12# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13# copies of the Software, and to permit persons to whom the Software is
14# furnished to do so, subject to the following conditions:
15################################################################################
16# The above copyright notice and this permission notice shall be included in
17# all copies or substantial portions of the Software.
18################################################################################
19# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25# THE SOFTWARE.
26################################################################################
27
28######################################
29# Auto Install Configuration options
30######################################
31
32# ----- Start Edit Here ----- #
33##############################################
34# Enable multi core build.
35###############################################
36multi_core="y"
37
38##############################################
39#Set number of cores to use when running make
40##############################################
41cores="4"
42
43#############################################
44# Select to use the stable zip or dev git
45# Requires dev_tools
46#############################################
47use_git="n"
48
49###########################################
50# Install Developer tools (Developers Only)
51# Git & Subversion for pulling from github
52###########################################
53dev_tools="n"
54
55####################################################
56# Repeater call sign
57# Please change this to match the repeater call sign
58####################################################
59# CALL SIGN
60CS="n3att"
61
62######################################################################
63# Setup up host / domain name or use system default host/domain name.
64######################################################################
65set_hndn="n"
66
67#############################################################
68# If you use the set host name please change these to fields.
69# Please change this to match you host and domain ........
70#############################################################
71# HOST Name
72HN="repeater"
73
74# DOMAIN Name
75DN="mydomain.com"
76
77########################################################################################
78# Configure wan (wide area network) (internet interface) Networking
79# IF you machine is at its final install location and needs/requires a static ip
80# Change this setting from n to y to enable network setup of eth0.
81# Other Wise by default it uses dhcp an the ip will be dynamic wich could lead to issues.
82#########################################################################################
83set_wan_static="n"
84
85###############################################################
86# IF you change set_wan_static=y Please chane these to configure eth0:
87# Make shure they match your current working network.......
88###############################################################
89#Iinterface IP
90IP="0.0.0.0"
91
92# Interface Netmask
93NM="255.0.0.0.0"
94
95# Interface Gateway
96GW="0.0.0.0"
97
98# Interface Name Servers
99NS1="0.0.0.0"
100NS2="0.0.0.0"
101
102###########################
103# Configure Local Timezine
104###########################
105set_timezone="n"
106
107###########################################
108# use nginx for web interface if selected
109# else it uses lighttpd.
110###########################################
111install_nginx="n"
112
113########################################################
114# Set mp3/wav file upload/post size limit for php/nginx
115# ( Must Have the M on the end )
116########################################################
117upload_size="25M"
118
119######################################
120# POSTGRESQL ( Optional Not Required)
121######################################
122################################################
123# Please Select Server or Client not both !!!!!!
124################################################
125
126#################################################################################
127# Install postgresql Client 9.4 for connection to remote postgresql servers (y/n)
128#################################################################################
129postgresql_client="n"
130
131#################################################################################
132# Install postgresql server 9.4 (y/n) (client included)(Local Machine)
133# Notice:
134# You should not use postgresql server on a nand/emmc/sd. It cuts the performance
135# life in half due to all the needed reads and writes. This cuts the life of
136# your pbx emmc/sd in half.
137#################################################################################
138postgresql_server="n"
139
140##########################################################
141# Set Postgresql Server Admin username ( Lower case only )
142##########################################################
143pgsql_admin=pgsqladmin
144
145######################################
146# Set Postgresql Server Admin password
147######################################
148pgsql_admin_passwd=pgsqladmin2015
149
150####################################################################################
151# Set Database Name used for fusionpbx in the postgresql server (Default: repeater)
152####################################################################################
153pg_db_name=repeater
154
155####################################################################################
156# Set FusionPBX database admin name.(used by fusionpbx to access the database table
157# in the postgresql server (Default: openrepeater)
158####################################################################################
159pg_db_user_name=openrepeater
160
161###################################################################################
162# Set Postgressl database admin password .(used by fusionpbx to access the database
163# table in the postgresql server). Please set a very secure password !!!!!!
164###################################################################################
165pg_db_user_passwd=
166
167#################################
168# MySQL ( Optional Not Required)
169#################################
170install_mysql="y"
171
172######################################
173# Set Postgresql Server Admin password
174######################################
175my_admin_passwd=mysql2015
176
177####################################################################################
178# Set Database Name used for fusionpbx in the postgresql server (Default: repeater)
179####################################################################################
180my_db_name=repeater
181
182####################################################################################
183# Set FusionPBX database admin name.(used by fusionpbx to access the database table
184# in the postgresql server (Default: openrepeater)
185####################################################################################
186my_db_user=openrepeater
187
188###################################################################################
189# Set Postgressl database admin password .(used by fusionpbx to access the database
190# table in the postgresql server). Please set a very secure password !!!!!!
191###################################################################################
192my_db_user_passwd=
193
194####################################
195# php conf file for mysql data base
196####################################
197phpDB_SettingsFile="database.php"
198
199#######################################
200# Use for configuring odroid arm boards
201#######################################
202odroid_boards="n"
203
204###########################################
205# Use for configuring beaglebone arm boards
206# Disable Default Web Service
207###########################################
208beaglebone_boards="n"
209
210################################################################
211# Install Ajenti Optional Admin Portal (Optional) (Not Required)
212# (Currently broken on arm installs)
213################################################################
214install_ajenti="n"
215
216####################################################
217# Install vsftpd for devel (Optional) (Not Required)
218####################################################
219install_vsftpd="n"
220
221#####################
222# set vsftp user name
223#####################
224vsftpd_user=""
225
226########################
227# set vsftp user password
228########################
229vsftpd_pwd=""
230
231########################
232# set vsftp config path
233########################
234FTP_CONFIG_PATH="/etc/vsftpd.conf"
235
236# ----- Stop Edit Here ------- #
237
238#######################
239# Nginx default www dir
240#######################
241WWW_PATH="/var/www"
242
243#################################
244#set Web User Interface Dir Name
245#################################
246gui_name="openrepeator"
247
248#####################
249#Php ini config file
250#####################
251php_ini="/etc/php5/fpm/php.ini"
252
253#########################################################
254# FUNCTION USED TO UPDATE CONFIG FILE SETTING KEY/VALUES
255# USAGE: edit_config FILE KEY VALUE ENABLED
256#########################################################
257edit_config() {
258 if [ "$4" = "enabled" ]
259 then
260 # UNCOMMENT THE LINE IF IT IS COMMENTED OUT
261 sed -i "/${2}/ s/# *//" "$1"
262 # CHANGE THE VALUE
263 sed -i "s/\($2 *= *\).*/\1$3/" "$1"
264 else
265 # COMMENT OUT THE LINE
266 sed -i "/${2}/ s/^/# /" "$1"
267 fi
268}
269
270##################################
271#----OS ENVIRONMENT CHECKS-------
272##################################
273
274##################################################################
275# check to confirm running as root. # First, we need to be root...
276##################################################################
277if [ "$(id -u)" -ne "0" ]; then
278 sudo -p "$(basename "$0") must be run as root, please enter your sudo password : " "$0" "$@"
279 exit 0
280fi
281echo
282echo "Looks Like you are root.... continuing!"
283echo
284
285###########################################
286# Run a OS and Platform compatabilty Check
287###########################################
288########
289# ARMEL
290########
291case $(uname -m) in armv[4-6]l)
292echo
293echo " ArmEL is currenty unsupported "
294echo
295exit
296esac
297
298########
299# ARMHF
300########
301case $(uname -m) in armv[7-9]l)
302echo
303echo " ArmHF arm v7 v8 v9 boards supported "
304echo
305esac
306
307#############
308# Intel/AMD
309#############
310case $(uname -m) in x86_64|i[4-6]86)
311echo
312echo " Intel / Amd boards Spported"
313echo
314esac
315echo
316
317########################################################
318# removes the cd img from the /etc/apt/sources.list file
319# (not needed after base install)
320########################################################
321sed -i '/cdrom:/d' /etc/apt/sources.list
322#sed -i '2,4d' /etc/apt/sources.list
323
324#################################################################################################
325# Setting apt_get to use the httpredirecter to get
326# To have <APT> automatically select a mirror close to you, use the Geo-IP redirector in your
327# sources.list "deb http://httpredir.debian.org/debian/ jessie main".
328# See http://httpredir.debian.org/ for more information. The redirector uses HTTP 302 redirects
329# not DNS to serve content so is safe to use with Google DNS.
330# See also <which httpredir.debian.org>. This service is identical to http.debian.net.
331#################################################################################################
332lsb_release -c |grep -i wheezy &> /dev/null 2>&1
333if [ $? -eq 0 ]; then
334 echo "installing wheezy release repo"
335 cat > "/etc/apt/sources.list" << DELIM
336 deb http://httpredir.debian.org/debian/ wheezy main contrib non-free
337DELIM
338else
339 lsb_release -c |grep -i jessie &> /dev/null 2>&1
340 if [ $? -eq 0 ]; then
341 echo "installing jessie release repo"
342 cat > "/etc/apt/sources.list" << DELIM
343 deb http://httpredir.debian.org/debian/ jessie main contrib non-free
344DELIM
345 fi
346fi
347
348######################
349#Update base os
350######################
351for i in update upgrade ;do apt-get -y "${i}" ; done
352
353###############################################
354#if lsb_release is not installed it installs it
355###############################################
356if [ ! -s /usr/bin/lsb_release ]; then
357 apt-get update && apt-get -y install lsb-release
358fi
359
360#################
361# Os/Distro Check
362#################
363lsb_release -c |grep -i wheezy &> /dev/null 2>&1
364if [ $? -eq 0 ]; then
365 echo " Good, you are running Debian 7 : Wheezy "
366 echo
367else
368 lsb_release -c |grep -i jessie &> /dev/null 2>&1
369 if [ $? -eq 0 ]; then
370 echo " OK you are running Debian 8 : Jessie "
371 else
372 echo " This script was written for Debian 7 Wheezy & Debian 8 Jessie "
373 echo
374 echo " Your OS appears to be: " lsb_release -a
375 echo
376 echo " Your OS is not currently supported by this script ... "
377 echo
378 echo " Exiting the install. "
379 exit
380 fi
381fi
382
383###################
384# Notes / Warnings
385###################
386echo
387cat << DELIM
388 Not Ment For L.a.m.p Installs
389
390 L.A.M.P = Linux Apache Mysql PHP
391
392 THIS IS A ONE TIME INSTALL SCRIPT
393
394 IT IS NOT INTENDED TO BE RUN MULTIPLE TIMES
395
396 This Script Is Ment To Be Run On A Fresh Install Of
397
398 Debian 7 (Wheezy) or Fresh Install Of Debian 8 (Jessie)
399
400 If It Fails For Any Reason Please Report To kb3vgw@gmail.com
401
402 Please Include Any Screen Output You Can To Show Where It Fails
403
404DELIM
405
406###########################
407# Pre-Install Information
408###########################
409echo
410cat << DELIM
411 Note:
412
413 Pre-Install Information:
414
415 This script uses Sqlite by default .
416
417 If you wish to use postgresql localy or on a remote server.
418
419 You need to edit the script and enable the pgsql-client or pgsql
420
421 option and fill in the required information.
422
423DELIM
424echo
425
426###############################################################################################
427#Testing for internet connection. Pulled from and modified
428#http://www.linuxscrew.com/2009/04/02/tiny-bash-scripts-check-internet-connection-availability/
429###############################################################################################
430echo
431echo "This Script Currently Requires a internet connection "
432echo
433wget -q --tries=10 --timeout=5 http://www.google.com -O /tmp/index.google &> /dev/null
434
435if [ ! -s /tmp/index.google ];then
436 echo "No Internet connection. Please check ethernet cable"
437 /bin/rm /tmp/index.google
438 exit 1
439else
440 echo "I Found the Internet ... continuing!!!!!"
4412 /bin/rm /tmp/index.google
442fi
443echo
444printf ' Current IP is : '; ip -f inet addr show dev eth0 | sed -n 's/^ *inet *\([.0-9]*\).*/\1/p'
445echo
446
447###################################
448#----install ntpd time daemon-----
449####################################
450apt-get -y install ntp
451service ntp restart
452
453######################
454#Install Dependancies
455# ####################
456echo " Installing install deps "
457apt-get install -y g++ make cmake libsigc++-2.0-dev libgsm1-dev libpopt-dev tcl8.5-dev \
458 libgcrypt11-dev libspeex-dev libasound2-dev alsa-utils vorbis-tools \
459 sox libsox-fmt-mp3 sqlite3 unzip librtlsdr-dev librtlsdr0 opus-tools doxygen \
460 groff libopus-dev libopus0 tcl8.6 tcl8.6-dev tk8.6 tk8.6-dev
461
462####################
463#install dev tools
464####################
465if [[ $dev_tools == "y" ]]; then
466apt-get install -y git-core subversion
467fi
468
469##############################
470#Set a reboot if Kernel Panic
471##############################
472cat > /etc/sysctl.conf << DELIM
473kernel.panic = 10
474DELIM
475
476####################################
477# Set fs to run in a tempfs ramdrive
478####################################
479cat >> /etc/fstab << DELIM
480tmpfs /tmp tmpfs defaults 0 0
481tmpfs /var/tmp tmpfs defaults 0 0
482DELIM
483
484# ############################
485# SET/CHANGE CURRENT TIMEZONE
486# ############################
487if [[ $set_timezone == "y" ]]; then
488 tzselect
489fi
490
491######################################
492# Add in Odroid Preconfigure settings
493# currently u3 board. c1 in the works
494######################################
495if [[ $odroid_boards == "y" ]]; then
496 cat > /etc/network/if-pre-up.d/pre-network-setup << DELIM
497 #!/bin/bash
498 if [ ! -f /boot/.mac ]; then
499 if [ -f /etc/smsc95xx_mac_addr ]; then
500 rm /etc/smsc95xx_mac_addr
501 fi
502 # unloading nic driver
503 rmmod smsc95xx
504 #running modprobe on nic
505 modprobe smsc95xx
506 #placing holder file
507 touch /boot/.mac
508 #rebooting to load new mac
509 reboot
510fi
511
512if [ ! -f /boot/.net ]; then
513 if [ -f "/boot/configs/ip.txt" ]; then
514 cp /boot/setup/ip.txt /etc/network/interfaces
515 fi
516
517 if [ -f "/boot/configs/resolv.txt" ]; then
518 cp /boot/setup/resolv.txt /etc/resolv.conf
519 fi
520
521 if [ -f "/boot/configs/hostname.txt" ]; then
522 cp /boot/setup/hostname.txt /etc/hostname
523 fi
524
525 if [ -f "/boot/configs/hosts.txt" ]; then
526 cp /boot/setup/hosts.txt /etc/hosts
527 fi
528 touch /boot/.net
529 reboot
530fi
531DELIM
532
533cat >> /boot/setup/ip.txt.dflt<< DELIM
534# interfaces(5) file used by ifup(8) and ifdown(8)
535#Local loop back interface
536auto lo
537iface lo inet loopback
538
539#Static mac configuration
540allow-hotplug eth0
541iface eth0 inet static
542address 10.0.0.2
543netmask 255.0.0.0
544gateway 10.0.0.1
545DELIM
546
547cat >> /boot/setup/hostname.txt.dflt << DELIM
548$CS-$HN
549DELIM
550
551cat > /boot/setup/hosts.txt.dflt << DELIM
552127.0.0.1 localhost
553::1 localhost ip6-localhost ip6-loopback
554fe00::0 ip6-localnet
555ff00::0 ip6-mcastprefix
556ff02::1 ip6-allnodes
557ff02::2 ip6-allrouters
558127.0.0.1 $CS-$HN
559DELIM
560
561cat >> /etc/profile << DELIM
562
563#set the rtc for current time
564hwclock -w
565
566# read the time from the rtc
567hwclock -r
568DELIM
569fi
570
571# ####################################
572# DISABLE BEAGLEBONE 101 WEB SERVICES
573# ####################################
574if [[ $beaglebone_boards == "y" ]]; then
575 echo " Disabling The Beaglebone 101 web services "
576 systemctl disable cloud9.service
577 systemctl disable gateone.service
578 systemctl disable bonescript.service
579 systemctl disable bonescript.socket
580 systemctl disable bonescript-autorun.service
581 systemctl disable avahi-daemon.service
582 systemctl disable gdm.service
583 systemctl disable mpd.service
584
585 echo " Stoping The Beaglebone 101 web services "
586 systemctl stop cloud9.service
587 systemctl stop gateone.service
588 systemctl stop bonescript.service
589 systemctl stop bonescript.socket
590 systemctl stop bonescript-autorun.service
591 systemctl stop avahi-daemon.service
592 systemctl stop gdm.service
593 systemctl stop mpd.service
594fi
595
596# ####################################################################################
597# SVXLINK
598# ####################################################################################
599#install svxlink
600if [[ $use_git == "y" ]]; then
601 git clone https://github.com/sm0svx/svxlink.git /usr/src/svxlink-head
602 cd /usr/src/svxlink-head/src
603else
604 mkdir /usr/src/downloads
605 cd /usr/src/downloads
606 wget https://github.com/sm0svx/svxlink/archive/14.08.1.tar.gz
607 tar xvzf 14.08.1.tar.gz -C /usr/src/
608 cd /usr/src/svxlink-14.08.1/src
609fi
610mkdir build
611cd build
612if [[ $multi_core == "y" ]]; then
613 cmake -j$cores -DCMAKE_INSTALL_PREFIX=/usr -DSYSCONF_INSTALL_DIR=/etc/svxlink -DLOCAL_STATE_DIR=/var -DUSE_QT=NO ..
614 make -j$cores
615 make -j$cores doc
616 make -j$cores install
617else
618 cmake -DCMAKE_INSTALL_PREFIX=/usr -DSYSCONF_INSTALL_DIR=/etc -DLOCAL_STATE_DIR=/var -DUSE_QT=NO ..
619 make
620 make doc
621 make install
622fi
623
624ldconfig
625
626if [[ $use_git == "y" ]]; then
627 git clone https://github.com/sm0svx/svxlink-sounds-en_US-heather.git /usr/share/svxlink/sounds/en_US
628else
629 cd /usr/src/downloads
630 wget https://github.com/sm0svx/svxlink-sounds-en_US-heather/archive/master.zip
631 unzip /usr/src/downloads/svxlink-sounds-en_US-heather-master.zip -C /usr/share/svxlink/sounds/
632fi
633
634#rm and link config dir
635#rm -rf /etc/svxlink
636#ln -s $WWW_PATH/$gui_name/admin/svxlink /etc/svxlink
637
638#Comment out settings in ALSA conf file to allow USB audio device over built in audio out.
639#Move svxlink config files from /etc/svxlink to web root, create a symbolic link in its place.
640
641# Create Link to folder with override TCL files
642#ln -s $WWW_PATH/$gui_name/admin/svxlink/local-events.d /usr/share/svxlink/events.d/local
643
644echo "Finished Installing SVXLink"
645
646# ####################################################################################
647# SETUP WEB SERVER
648# ####################################################################################
649###########################################
650#---Start of nginx / php5 install --------
651###########################################
652if [[ $install_nginx == "y" ]]; then
653##############################################
654#Install and configure PHP + Nginx + sqlite3
655##############################################
656apt-get -y install ssl-cert nginx php5-cli php5-common php-apc php5-gd \
657 php-db php5-fpm php5-memcache php5-sqlite
658
659##################################################
660# Changing file upload size from 2M to upload_size
661##################################################
662sed -i "$php_ini" -e "s#upload_max_filesize = 2M#upload_max_filesize = $upload_size#"
663
664######################################################
665# Changing post_max_size limit from 8M to upload_size
666######################################################
667sed -i "$php_ini" -e "s#post_max_size = 8M#post_max_size = $upload_size#"
668
669#####################################################################################################
670#Nginx config Copied from Debian nginx pkg (nginx on debian wheezy uses sockets by default not ports)
671#####################################################################################################
672cat > "/etc/nginx/sites-available/repeator" << DELIM
673server{
674 listen 127.0.0.1:80;
675 server_name 127.0.0.1;
676 access_log /var/log/nginx/access.log;
677 error_log /var/log/nginx/error.log;
678
679 client_max_body_size $upload_size;
680 client_body_buffer_size 128k;
681
682 location / {
683 root $WWW_PATH/$gui_name;
684 index index.php;
685 }
686
687 location ~ \.php$ {
688 fastcgi_pass unix:/var/run/php5-fpm.sock;
689 #fastcgi_pass 127.0.0.1:9000;
690 fastcgi_index index.php;
691 include fastcgi_params;
692 fastcgi_param SCRIPT_FILENAME $WWW_PATH/$gui_name\$fastcgi_script_name;
693 }
694
695 # Disable viewing .htaccess & .htpassword & .db
696 location ~ .htaccess {
697 deny all;
698 }
699 location ~ .htpassword {
700 deny all;
701 }
702 location ~^.+.(db)$ {
703 deny all;
704 }
705}
706
707server{
708 listen 80;
709 listen [::]:80 default_server ipv6only=on;
710 server_name $gui_name;
711 if (\$uri !~* ^.*provision.*$) {
712 rewrite ^(.*) https://\$host\$1 permanent;
713 break;
714 }
715
716 access_log /var/log/nginx/access.log;
717 error_log /var/log/nginx/error.log;
718
719 client_max_body_size $upload_size;
720 client_body_buffer_size 128k;
721
722 location / {
723 root $WWW_PATH/$gui_name;
724 index index.php;
725 }
726
727 location ~ \.php$ {
728 fastcgi_pass unix:/var/run/php5-fpm.sock;
729 fastcgi_index index.php;
730 include fastcgi_params;
731 fastcgi_param SCRIPT_FILENAME $WWW_PATH/$gui_name\$fastcgi_script_name;
732 }
733
734 # Disable viewing .htaccess & .htpassword & .db
735 location ~ .htaccess {
736 deny all;
737 }
738 location ~ .htpassword {
739 deny all;
740 }
741 location ~^.+.(db)$ {
742 deny all;
743 }
744}
745
746server{
747 listen 443;
748 listen [::]:443 default_server ipv6only=on;
749 server_name $gui_name;
750 ssl on;
751 ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
752 ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
753 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
754 ssl_session_timeout 5m;
755 ssl_ciphers HIGH:!ADH:!MD5;
756
757 access_log /var/log/nginx/access.log;
758 error_log /var/log/nginx/error.log;
759
760 client_max_body_size $upload_size;
761 client_body_buffer_size 128k;
762
763 location / {
764 root $WWW_PATH/$gui_name;
765 index index.php;
766 }
767
768 location ~ \.php$ {
769 fastcgi_pass unix:/var/run/php5-fpm.sock;
770 fastcgi_index index.php;
771 include fastcgi_params;
772 fastcgi_param SCRIPT_FILENAME $WWW_PATH/$gui_name\$fastcgi_script_name;
773 }
774
775 # Disable viewing .htaccess & .htpassword & .db
776 location ~ .htaccess {
777 deny all;
778 }
779 location ~ .htpassword {
780 deny all;
781 }
782 location ~^.+.(db)$ {
783 deny all;
784 }
785}
786DELIM
787
788###############################################
789# set nginx worker level limit for performance
790###############################################
791cat > "/etc/nginx/nginx.conf" << DELIM
792user www-data;
793worker_processes 2;
794pid /var/run/nginx.pid;
795
796events {
797 worker_connections 768;
798 multi_accept on;
799}
800
801http {
802
803 ##
804 # Basic Settings
805 ##
806
807 sendfile on;
808 tcp_nopush on;
809 tcp_nodelay on;
810 keepalive_timeout 75;
811 keepalive_requests 10000;
812 types_hash_max_size 2048;
813 # server_tokens off;
814
815 # server_names_hash_bucket_size 64;
816 # server_name_in_redirect off;
817
818 include /etc/nginx/mime.types;
819 default_type application/octet-stream;
820
821 open_file_cache max=1000 inactive=20s;
822 open_file_cache_valid 30s;
823 open_file_cache_min_uses 2;
824 open_file_cache_errors off;
825
826 fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=microcache:15M max_size=1000m inactive=60m;
827
828 ##
829 # Logging Settings
830 ##
831
832 #access_log /var/log/nginx/access.log;
833 error_log /var/log/nginx/error.log;
834
835 ##
836 # Gzip Settings
837 ##
838
839 gzip on;
840 gzip_static on;
841 gzip_disable "msie6";
842
843 # gzip_vary on;
844 # gzip_proxied any;
845 # gzip_comp_level 6;
846 # gzip_buffers 16 8k;
847 # gzip_http_version 1.1;
848 # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
849
850 ##
851 # nginx-naxsi config
852 ##
853 # Uncomment it if you installed nginx-naxsi
854 ##
855
856 #include /etc/nginx/naxsi_core.rules;
857
858 ##
859 # nginx-passenger config
860 ##
861 # Uncomment it if you installed nginx-passenger
862 ##
863
864 #passenger_root /usr;
865 #passenger_ruby /usrruby;
866
867 ##
868 # Virtual Host Configs
869 ##
870
871 include /etc/nginx/conf.d/*.conf;
872 include /etc/nginx/sites-enabled/*;
873}
874
875DELIM
876
877##############################################################
878# linking fusionpbx nginx config from avaible to enabled sites
879##############################################################
880ln -s /etc/nginx/sites-available/"$gui_name" /etc/nginx/sites-enabled/"$gui_name"
881
882######################
883#disable default site
884######################
885rm -rf /etc/nginx/sites-enabled/default
886
887
888# Make sure the path /var/www/ is owned by your web server user:
889chown -R www-data:www-data /var/www
890
891##############################
892#Restarting Nginx and PHP FPM
893##############################
894for i in nginx php5-fpm ;do service "${i}" restart > /dev/null 2>&1 ; done
895
896#fi
897
898else
899
900#####################################################
901#---Start of lighttpd / php5 install --------
902#####################################################
903#if [[ $install_lighttpd == "y" ]]; then
904 apt-get install lighttpd php5-cgi
905
906 # Edit the php.ini file:
907 # nano /etc/php5/cgi/php.ini
908 # And uncomment: 'cgi.fix_pathinfo = 1' uses ; for comment
909
910 # UNCOMMENT THE LINE IF IT IS COMMENTED OUT
911 sed -i "cgi.fix_pathinfo = // s/; *//" /etc/php5/cgi/php.ini
912
913#Replace contents of lighttpd.conf with this:
914lighttpdConfig=$( cat <<EOF
915 server.modules = (
916 "mod_access",
917 "mod_alias",
918 "mod_compress",
919 "mod_redirect",
920 "mod_rewrite",
921 "mod_accesslog",
922 "mod_fastcgi",
923 )
924
925 server.document-root = "/var/www"
926 server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
927 server.errorlog = "/var/log/lighttpd/error.log"
928 server.pid-file = "/var/run/lighttpd.pid"
929 server.username = "www-data"
930 server.groupname = "www-data"
931 server.port = 80
932 server.tag = "Private Server"
933
934 index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
935 url.access-deny = ( "~", ".inc", ".htaccess", ".htpasswd", "password.txt", "username.txt", "login.txt" )
936 static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
937
938 compress.cache-dir = "/var/cache/lighttpd/compress/"
939 compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )
940
941 # default listening port for IPv6 falls back to the IPv4 port
942 include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
943 include_shell "/usr/share/lighttpd/create-mime.assign.pl"
944 include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
945
946 fastcgi.server = ( ".php" => ((
947 "bin-path" => "/usr/bin/php5-cgi",
948 "socket" => "/tmp/php.socket",
949 "max-procs" => 5,
950 "bin-environment" => (
951 "PHP_FCGI_CHILDREN" => "40",
952 "PHP_FCGI_MAX_REQUESTS" => "10000"
953 ),
954 "bin-copy-environment" => (
955 "PATH", "SHELL", "USER"
956 ),
957 "broken-scriptfilename" => "enable"
958 )))
959EOF
960)
961
962 echo "$lighttpdConfig" > /etc/lighttpd/lighttpd.conf
963
964 #Restart Lighttpd:
965 service restart lighttpd
966
967# All errors generated by Lighttpd are saved, by default, in this file:
968# /var/log/lighttpd/error.log
969
970 # Make sure the path /var/www/ is owned by your web server user (www-data or lighttpd):
971 chown -R www-data:www-data /var/www
972fi
973
974###################################
975#Install postgresql-client option
976###################################
977if [[ $postgresql_client == "y" ]]; then
978#####################################################
979# add in postgresql 9.4 repo for x86 x86-64 bit pkgs
980#####################################################
981 case $(uname -m) in x86_64|i[4-6]86)
982 lsb_release -c |grep -i wheezy > /dev/null
983 if [ $? -eq 0 ]; then
984 cat > "/etc/apt/sources.list.d/pgsql-pgdg.list" << DELIM
985 deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main
986DELIM
987 else
988 cat > "/etc/apt/sources.list.d/pgsql-pgdg.list" << DELIM
989 deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main
990DELIM
991 fi
992 ####################
993 #add pgsql repo key
994 ####################
995 wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add -
996
997 ###############################################
998 #run repo update after adding in a new repo....
999 ###############################################
1000 apt-get update
1001
1002 ############################
1003 #Install and configure PGSQL
1004 ############################
1005 for i in postgresql-client-9.4 php5-pgsql ;do apt-get -y install "${i}"; done
1006 service php5-fpm restart
1007 esac
1008 clear
1009
1010 ##########################################
1011 #Install and configure PGSQL 9.1 for armhf
1012 ##########################################
1013 case $(uname -m) in armv7l)
1014 for i in postgresql-client-9.4 php5-pgsql ;do apt-get -y install "${i}"; done
1015 esac
1016
1017 ##########################################################
1018 # Goto gui configure statement
1019 ##########################################################
1020 echo
1021 echo " The $gui_name install has finished... "
1022 echo
1023 echo " Now Waiting on you to finish the installation via web browser "
1024 echo
1025 printf ' Please open a web-browser to http://'; ip -f inet addr show dev eth0 | sed -n 's/^ *inet *\([.0-9]*\).*/\1/p'
1026 cat << DELIM
1027 Or the Doamin name assigned to the machine like http://"$(hostname)".yourdomin.com
1028 On the First configuration page of the web user interface.
1029 Please Select the PostgreSQL option in the pull-down menu as your Database
1030 Also Please fill in the SuperUser Name and Password fields.
1031 On the Second Configuration Page of the web user intercae please fill in the following fields:
1032 Server: Use the IP or Doamin name assigned to the remote postgresql database server machine
1033 Port: use the port for the remote postgresql server
1034 Database Name: "$pg_db_name"
1035 Database Username: "$pg_db_user_name"
1036 Database Password: "$pg_db_user_passwd"
1037 Create Database Username: Database_Superuser_Name of the remote postgresql server
1038 Create Database Password: Database_Superuser_password of the remote postgresql server
1039DELIM
1040fi
1041
1042#################################################
1043#-----install & configure basic postgresql-server
1044#################################################
1045if [[ $postgresql_server == "y" ]]; then
1046#####################################################
1047# add in postgresql 9.4 repo for x86 x86-64 bit pkgs
1048#####################################################
1049 case $(uname -m) in x86_64|i[4-6]86)
1050 lsb_release -c |grep -i wheezy > /dev/null
1051 if [ $? -eq 0 ]; then
1052 cat > "/etc/apt/sources.list.d/pgsql-pgdg.list" << DELIM
1053 deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main
1054DELIM
1055 else
1056 cat > "/etc/apt/sources.list.d/pgsql-pgdg.list" << DELIM
1057 deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main
1058DELIM
1059 fi
1060
1061 ####################
1062 #add pgsql repo key
1063 ####################
1064 wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add -
1065
1066 ###############################################
1067 #run repo update after adding in a new repo....
1068 ################################################
1069 apt-get update
1070
1071 #################################
1072 #Install and configure PGSQL 9.4
1073 #################################
1074 for i in postgresql-9.4 php5-pgsql ;do apt-get -y install "${i}"; done
1075 service php5-fpm restart
1076 esac
1077
1078 ##########################################
1079 #Install and configure PGSQL 9.1 for armhf
1080 ##########################################
1081 case $(uname -m) in armv7l)
1082 echo "postgresql-9.4 is being installed"
1083 for i in postgresql-9.4 php5-pgsql ;do apt-get -y install "${i}"; done
1084 esac
1085
1086 #########################################################
1087 #Adding a SuperUser and Password for Postgresql database.
1088 #########################################################
1089 su -l postgres -c "psql -c \"create role $pgsql_admin with superuser login password '$pgsql_admin_passwd'\""
1090 clear
1091
1092 ##########################################################
1093 # Goto gui configure statement
1094 ##########################################################
1095 echo
1096 echo " The $gui_name install has finished... "
1097 echo
1098 echo " Now Waiting on you to finish the installation via web browser "
1099 echo
1100 printf 'Please open a web browser to http://'; ip -f inet addr show dev eth0 | sed -n 's/^ *inet *\([.0-9]*\).*/\1/p'
1101 cat << DELIM
1102 Or the Doamin name asigned to the machine like http://"$(hostname)".yourdomin.com.
1103 On the First configuration page of the web user interface
1104 Please Select the PostgreSQL option in the pull-down menu as your Database
1105 Also Please fill in the SuperUser Name and Password fields.
1106 On the Second Configuration Page of the web user interface please fill in the following fields:
1107 Database Name: "$pg_db_name"
1108 Database Username: "$pg_db_user_name"
1109 Database Password: "$pg_db_user_passwd"
1110 Create Database Username: "$pgsql_admin"
1111 Create Database Password: "$pgsql_admin_passwd"
1112DELIM
1113else
1114 clear
1115 echo
1116 echo " The $gui_name install has finished... "
1117 echo
1118 echo " Now Waiting on you to finish the installation via web browser "
1119 echo
1120 printf ' Please open a web-browser to http://'; ip -f inet addr show dev eth0 | sed -n 's/^ *inet *\([.0-9]*\).*/\1/p'
1121 cat << DELIM
1122 or the Domain name asigned to the machine like http://"$(hostname)".yourdomin.com.
1123 On the First Configuration page of the web user interface "$gui_name".
1124 Also Please fill in the SuperUser Name and Password fields.
1125 Freeswitch & repeator Web User Interface Installation Completed
1126 Now you can configure SVXLink using the Repeator web user interface
1127DELIM
1128
1129
1130echo -ne " The Install will clean up the last bit of permissions when "
1131echo
1132echo " you finish entering the required information and return here. "
1133echo
1134echo " Waiting on /etc/$gui_name/config.php "
1135while [ ! -e /etc/$gui_name/config.php ]
1136do
1137 echo -ne '.'
1138 sleep 1
1139done
1140echo
1141echo " /etc/$gui_name/config.php Found!"
1142echo
1143echo " Waiting 60 more seconds to be sure the database is fully populated..... "
1144SLEEPTIME=0
1145while [ "$SLEEPTIME" -lt 60 ]
1146do
1147 echo -ne '.'
1148 sleep 1
1149 let "SLEEPTIME = $SLEEPTIME + 1"
1150done
1151fi
1152
1153#################################################
1154#-----install & configure basic mysql-server
1155#################################################
1156if [[ $install_mysql == "y" ]]; then
1157 apt-get install mysql-server php5-mysql
1158
1159##############################
1160# Configure mysql for web gui
1161##############################
1162
1163 MYSQL=(which mysql)
1164
1165 SQL="CREATE DATABASE IF NOT EXISTS $my_db_name;GRANT ALL ON *.* TO '$my_db_user'@'localhost' IDENTIFIED BY '$my_db_user_passwd';FLUSH PRIVILEGES;SHOW DATABASES;"
1166
1167 $MYSQL -uroot --password=$my_admin_passwd -e "$SQL"
1168
1169#######################################################
1170# BUILD NEW DATABASE CONNECTION FILE FOR PHP INTERFACE
1171#######################################################
1172phpDB_Settings=$( cat <<EOF
1173<?php
1174// MySQL Connection
1175\$MySQLUsername = "$my_db_user";
1176\$MySQLPassword = "$my_db_user_passwd";
1177\$MySQLHost = "localhost";
1178\$MySQLDB = "$my_db_name";
1179?>
1180EOF
1181)
1182 echo "$phpDB_Settings" > $WWW_PATH/$gui_name/admin/_includes/$phpDB_SettingsFile
1183
1184 chmod 777 $WWW_PATH/$gui_name/admin/_includes/$phpDB_SettingsFile
1185 chown www-data:www-data $WWW_PATH/$gui_name/admin/_includes/$phpDB_SettingsFile
1186
1187 # EXECUTE PHP SCRIPT TO POPULATE DATABASE WITH DEFAULT VALUES IN SQL FILE.
1188 php /var/www/admin/functions/config_db.php
1189fi
1190
1191# ################################################
1192# Fetch and Install open repeater project web ui
1193# ################################################
1194mkdir $WWW_PATH/$gui_name
1195if [[ $use_git == "y" ]]; then
1196 git clone https://github.com/OpenRepeater/webapp.git $WWW_PATH/$gui_name
1197 git clone https://github.com/OpenRepeater/OpenRepeater.git $WWW_PATH/$gui_name
1198else
1199 cd $WWW_PATH/$gui_name
1200 rm webapp-alpha.zip
1201 wget https://github.com/OpenRepeater/webapp/archive/alpha.zip
1202 unzip webapp-alpha.zip
1203 rm webapp-alpha.zip
1204fi
1205
1206find "$WWW_PATH" -type d -exec chmod 775 {} +
1207find "$WWW_PATH" -type f -exec chmod 664 {} +
1208chown -R www-data:www-data $WWW_PATH
1209
1210# ##################
1211# INSTALL MEMCACHED
1212# ##################
1213apt-get install -y memcached php5-memcache php-pear php5-dev
1214pecl install memcache
1215
1216if [[ $install_nginx == "y" ]]; then
1217 echo " You will need to edit the php.ini file and add extensions=memcached.so location : /etc/php5/fpm/php.ini and then restart web service "
1218else
1219 echo " You will need to edit the php.ini file and add extensions=memcached.so location : /etc/php5/cgi/php.ini and then restart web service "
1220fi
1221
1222if [[ $install_nginx == "y" ]]; then
1223 #Restart nginx:
1224 for i in nginx php5-fpm ;do service "${i}" restart > /dev/null 2>&1 ; done
1225else
1226 #Restart lighttpd
1227 for i in php5-cgi lighttpd ;do service "${i}" restart > /dev/null 2>&1 ; done
1228fi
1229
1230# ##############################################
1231# INSTALL FTP SERVER / ADD USER FOR DEVELOPMENT
1232# ##############################################
1233if [[ $install_vsftpd == "y" ]]; then
1234 apt-get install vsftpd
1235
1236 edit_config $FTP_CONFIG_PATH anonymous_enable NO enabled
1237 edit_config $FTP_CONFIG_PATH local_enable YES enabled
1238 edit_config $FTP_CONFIG_PATH write_enable YES enabled
1239 edit_config $FTP_CONFIG_PATH local_umask 022 enabled
1240
1241 cat "force_dot_files=YES" >> "$FTP_CONFIG_PATH"
1242
1243 system vsftpd restart
1244
1245 # ############################
1246 # ADD FTP USER & SET PASSWORD
1247 # ############################
1248 adduser $vsftpd_user -p $vsftpd_pwd
1249fi
1250
1251##########################################################
1252#Ajenti admin portal. Makes maintaining the system easier.
1253##########################################################
1254
1255##########################
1256#ADD Ajenti repo & ajenti
1257##########################
1258if [[ $install_ajenti == "y" ]]; then
1259 echo "Installing Ajenti Admin Portal"
1260 cat > "/etc/apt/sources.list.d/ajenti.list" <<DELIM
1261 deb http://repo.ajenti.org/debian main main debian
1262DELIM
1263
1264######################
1265# add ajenti repo key
1266######################
1267wget http://repo.ajenti.org/debian/key -O- | apt-key add -
1268
1269#######################
1270# install ajenti
1271#######################
1272apt-get update &> /dev/null && apt-get -y install ajenti
1273fi
1274
1275#########################################################
1276#-----Installing Fail2Ban/monit Protection services------
1277#########################################################
1278for i in fail2ban monit ;do apt-get -y install "${i}" ; done
1279
1280#############################
1281#Setting Host/Domain name
1282#############################
1283if [[ $set_hndn == "y" ]]; then
1284cat << EOF > /etc/hostname
1285$CS-$HN
1286EOF
1287fi
1288
1289#########################################
1290# Setup Primary Network Interface (WLAN)
1291#########################################
1292if [[ $set_wan_static == "y" ]]; then
1293cat << EOF > /etc/network/interfaces
1294# The loopback network interface
1295auto lo
1296iface lo inet loopback
1297
1298# The primary network interface
1299allow-hotplug eth0
1300iface eth0 inet static
1301 address $IP
1302 netmask $NM
1303 gateway $GW
1304 dns-nameservers $NS1 $NS2
1305EOF
1306
1307#################
1308#Setup /etc/hosts
1309#################
1310cat << EOF > /etc/hosts
1311127.0.0.1 localhost
1312::1 localhost ip6-localhost ip6-loopback
1313fe00::0 ip6-localnet
1314ff00::0 ip6-mcastprefix
1315ff02::1 ip6-allnodes
1316ff02::2 ip6-allrouters
1317$IP $HN.$DN
1318$IP $HN.$DN $DN
1319EOF
1320fi
1321
1322echo " ########################################################################################## "
1323echo " # The Open Repeater Project / SVXLink / Echo link server Install is now complete # "
1324echo " # and your system is ready for use.. # "
1325echo " # # "
1326echo " # Please send any feed back to kb3vgw@gmail.com # "
1327echo " ########################################################################################## "
1328
1329######################
1330# Post Install Reboot
1331######################
1332echo
1333echo " Post Install Reboot"
1334echo
1335shutdown -r now
1336