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