Advertisement
load-net

Freepbx-Installer-Script.sh

Nov 24th, 2022
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.51 KB | None | 0 0
  1. Skip to content
  2. Product
  3. Solutions
  4. Open Source
  5. Pricing
  6. Search
  7. Sign in
  8. Sign up
  9. astdev
  10. /
  11. freepbx
  12. Public
  13. Code
  14. Issues
  15. Pull requests
  16. Actions
  17. Projects
  18. Wiki
  19. Security
  20. Insights
  21. freepbx/Freepbx-Installer-Script.sh
  22. @astdev
  23. astdev Update Freepbx-Installer-Script.sh
  24. Latest commit ad3a01d on Jul 31, 2013
  25. History
  26. 1 contributor
  27. 406 lines (331 sloc) 14.6 KB
  28.  
  29. # Installer Script to take a stock Centos 6.4 64bit to a FreePBX Distro 4.211.64-1 release.
  30. # Once completed you can use the upgrade scripts for version track 4.211.64
  31. # To keep your system updated.
  32.  
  33. # Copyright 2013 Schmooze Com, Inc.
  34.  
  35. # This script is not to be copied for other use.
  36.  
  37. # This script and the finished product that is installed carries NO WARRANTY and is
  38. # used to get your FreePBX system setup and installed. The installed product is released
  39. # as the FreePBX Distro and is licensed under the GPLV2 and can be used by anyone
  40. # free of charge. Please see http://www.gnu.org/ for more information on the use of the GPL License
  41. ###########################################################################
  42. # Set some Variable
  43. echo "Set some Variables needed for install time"
  44. brand=FreePBXDistro
  45. version=4.211.64-1
  46. ###########################################################################
  47. echo
  48. echo "Moving to Next Step"
  49. echo
  50. ###########################################################################
  51. # Check to see if MySQL is installed.
  52. echo " Check to see if MySQL is installed"
  53. if [ `rpm -qa | grep mysql-server | wc -l` -gt 0 ]; then
  54. echo " MySQL appears to be installed will now check for a MySQL root password"
  55. echo "Test to make sure MySQL does not have a root password"
  56. if mysql -uroot -e'show databases' > /dev/null 2>&1; [ $? -gt 0 ]; then
  57. echo "The root user for MySQL has a password. Please remove the password and re-run this script"
  58. exit
  59. else
  60. echo "You do not have a password for the root MySQL user. We will now continue with the install"
  61. fi
  62. else
  63. echo " MySQL is not installed so we will continue on with the installer"
  64. fi
  65. ###########################################################################
  66. echo
  67. echo "Moving to Next Step"
  68. echo
  69. ###########################################################################
  70. echo " Replace repos with only FreePBX Distro since some people have added other repos which can break updates"
  71. # Setup FreePBX Distro Repos Only
  72. rm -rf /etc/yum.repos.d/*
  73. /bin/cat <<'EOTT' >/etc/yum.repos.d/FreePBX.repo
  74. # FreePBX-Base.repo
  75. #
  76. # If the mirrorlist= does not work for you, as a fall back you can try the
  77. # remarked out baseurl= line instead.
  78. #
  79. [base]
  80. name=CentOS-$releasever - Base
  81. mirrorlist=http://mirrorlist.freepbxdistro.org/?release=6.4&arch=$basearch&repo=os
  82. #baseurl=http://yum.freepbxdistro.org/centos/$releasever/os/$basearch/
  83. gpgcheck=0
  84. enabled=1
  85. #released updates
  86. [updates]
  87. name=CentOS-$releasever - Updates
  88. mirrorlist=http://mirrorlist.freepbxdistro.org/?release=6.4&arch=$basearch&repo=updates
  89. #baseurl=http://yum.freepbxdistro.org/centos/$releasever/updates/$basearch/
  90. gpgcheck=0
  91. enabled=1
  92. #additional packages that may be useful
  93. [extras]
  94. name=CentOS-$releasever - Extras
  95. mirrorlist=http://mirrorlist.freepbxdistro.org/?release=6.4&arch=$basearch&repo=extras
  96. #baseurl=http://yum.freepbxdistro.org/centos/$releasever/extras/$basearch/
  97. gpgcheck=0
  98. enabled=1
  99. #additional packages that extend functionality of existing packages
  100. [centosplus]
  101. name=CentOS-$releasever - Plus
  102. mirrorlist=http://mirrorlist.freepbxdistro.org/?release=6.4&arch=$basearch&repo=centosplus
  103. #baseurl=http://yum.freepbxdistro.org/centos/$releasever/centosplus/$basearch/
  104. gpgcheck=0
  105. enabled=0
  106. #Core PBX Packages
  107. [pbx]
  108. name=pbx
  109. mirrorlist=http://mirrorlist.freepbxdistro.org/?pbxver=4.211.64&release=6.4&arch=$basearch&repo=pbx
  110. #baseurl=http://yum.freepbxdistro.org/pbx/4.211.64/$basearch/
  111. gpgcheck=0
  112. enabled=1
  113. #Schmooze Commercial Packages
  114. [schmooze-commercial]
  115. name=schmooze-commercial
  116. mirrorlist= http://mirrorlist.schmoozecom.net/?release=6.4&arch=$basearch&repo=schmooze-commercial
  117. #baseurl=http://yum.schmoozecom.net/schmooze-commercial/$release/$basearch/
  118. gpgcheck=0
  119. enabled=1
  120. EOTT
  121. ###########################################################################
  122. echo
  123. echo "Clean Yum just to make sure we have a fresh list"
  124. echo
  125. yum clean all
  126. ###########################################################################
  127. echo
  128. echo "Moving to Next Step"
  129. echo
  130. ###########################################################################
  131. # Yum Install Packages
  132. echo " yum install needed packages"
  133.  
  134. # software raid
  135. yum -y install sgpio mdadm
  136.  
  137. # NOTE: The Kernel packages need to match what we tell Sangoma to compile Wanpipe against or we will have issues
  138. yum -y install kernel-2.6.32-358.0.1.el6 kernel-headers-2.6.32-358.0.1.el6 kernel-devel-2.6.32-358.0.1.el6
  139.  
  140. # Vim goodies
  141. yum -y install vim-enhanced
  142.  
  143. # Apache
  144. yum -y install httpd
  145.  
  146. # MySQL
  147. yum -y install mysql mysql-server mysql-libs
  148.  
  149. # PHP
  150. yum -y install php-5.3.3 php-mysql-5.3.3 php-common-5.3.3 php-cli-5.3.3 php-ldap-5.3.3 php-gd-5.3.3 php-pdo-5.3.3 php-process-5.3.3 php-devel-5.3.3 php-pear-1.9.4 php-pear-DB-1.7.13 php-5.3-zend-guard-loader-5.5.0
  151.  
  152. # Various utilities
  153. yum -y install dnsmasq lm_sensors gcc gcc-c++ gdb incron screen
  154.  
  155. # Network Tools
  156. yum -y install ntp nmap openvpn
  157.  
  158. # Install Asterisk 1.8
  159. yum -y install asterisk18-1.8.21.0 asterisk18-addons-1.8.21.0 asterisk18-addons-bluetooth-1.8.21.0 asterisk18-addons-core-1.8.21.0 asterisk18-addons-mysql-1.8.21.0 asterisk18-addons-ooh323-1.8.21.0 asterisk18-core-1.8.21.0 asterisk18-curl-1.8.21.0 asterisk18-dahdi-1.8.21.0 asterisk18-flite-1.8.21.0 asterisk18-doc-1.8.21.0 asterisk18-flite-debuginfo-1.8.21.0 asterisk18-voicemail-1.8.21.0 asterisk18-odbc-1.8.21.0
  160.  
  161. # Dahdi, libpri and other Dahdi tools
  162. yum -y install kmod-dahdi-linux-2.6.1 dahdi-linux-kmod-debuginfo-2.6.1 dahdi-linux-2.6.1 dahdi-linux-debuginfo-2.6.1 dahdi-linux-devel-2.6.1 dahdi-tools-2.6.1 dahdi-tools-debuginfo-2.6.1 dahdi-tools-doc-2.6.1 dahdi-firmware-2.5.0.1 dahdi-firmware-hx8-2.06 dahdi-firmware-oct6114-064-1.05.01 dahdi-firmware-oct6114-128-1.05.01 dahdi-firmware-oct6114-256-1.05.01 dahdi-firmware-tc400m-MR6.12 dahdi-firmware-vpmoct032-1.12.0 dahdi-firmware-te820-1.76 dahdi-firmware-xorcom-1.0
  163. yum -y install libpri-1.4.12 libpri-debuginfo-1.4.12 libpri-devel-1.4.12
  164. yum -y install libtonezone-2.6.1 libtonezone-devel-2.6.1
  165. yum -y install libresample-0.1.3
  166. yum -y install libss7-1.0.2 libss7-devel-1.0.2 libopenr2-1.3.2
  167. yum -y install schmooze-dahdi
  168.  
  169. # Asterisk Sounds
  170. yum -y install asterisk-sounds-core-en-alaw-1.4.21 asterisk-sounds-core-en-ulaw-1.4.21 asterisk-sounds-core-en-gsm-1.4.21 asterisk-sounds-extra-en-alaw-1.4.9 asterisk-sounds-extra-en-ulaw-1.4.9 asterisk-sounds-extra-en-gsm-1.4.9 moh-sounds
  171.  
  172. # Flite
  173. yum -y install flite flite-devel
  174.  
  175. # TFTP and FTP Server
  176. yum -y install tftp-server vsftpd
  177.  
  178. # Java
  179. yum -y install jre
  180.  
  181. # Play audio files from asterisk
  182. yum -y install mpg123 sox esound-devel libtool-ltdl
  183.  
  184. # Remove sendmail and install postifx to handle email
  185. yum -y install postfix mailx cyrus-sasl-plain
  186.  
  187. # fax conversion applications
  188. yum -y install libtiff libtiff-devel ghostscript ghostscript-fonts
  189.  
  190. # SVN
  191. yum -y install subversion
  192.  
  193. # Fail2ban RPM for Security
  194. yum -y install fail2ban
  195.  
  196. # Install iksemel for SRTP
  197. yum -y install iksemel
  198.  
  199. # Install spandsp for faxing
  200. yum -y install spandsp
  201. yum -y install spandsp-devel
  202.  
  203. # Install Mosh for MAC and Linux Users
  204. yum -y install mosh
  205.  
  206. # Radiusclient for Asterisk CEL logging
  207. yum -y install radiusclient-ng radiusclient-ng-devel
  208.  
  209. # fxload for xorcom USB support
  210. yum -y install fxload
  211.  
  212. # odbc for CEL support in asterisk
  213. yum -y install mysql-connector-odbc unixODBC
  214.  
  215. # libwat
  216. yum -y install libwat libwat-devel libwat-debuginfo
  217.  
  218. # Tree
  219. yum -y install tree
  220.  
  221. # JS for LumenVox
  222. yum -y install js
  223.  
  224. #XMPP-Jabber Server
  225. yum -y install prosody
  226.  
  227. # SRTP support for Asterisk
  228. yum -y install libsrtp-devel libsrtp
  229.  
  230. # Sangoma Wanpipe
  231. yum -y install wanpipe
  232. ###########################################################################
  233. echo
  234. echo "Moving to Next Step"
  235. echo
  236. ###########################################################################
  237. # Cleanup files and setup things.
  238. echo "Cleanup files and setup things"
  239.  
  240. # COMMON THINGS BETWEEN ALL DISTROS
  241. # ntp settings
  242. echo "driftfile /var/lib/ntp/drift" > /etc/ntp.conf
  243. echo "server 0.pool.ntp.org" >> /etc/ntp.conf
  244. echo "server 1.pool.ntp.org" >> /etc/ntp.conf
  245. echo "server 2.pool.ntp.org" >> /etc/ntp.conf
  246. echo "server 127.127.1.0" >> /etc/ntp.conf
  247. echo "fudge 127.127.1.0 stratum 10" >> /etc/ntp.conf
  248.  
  249. # Setup DNSMasq to ignore reqeust for DNS from outside world
  250. sed -i 's/#listen-address=/listen-address=127.0.0.1/g' /etc/dnsmasq.conf
  251.  
  252. cp -f /etc/xinetd.d/tftp /tmp/xinetd.tftp.old
  253. sed -e "s/\W*disable\W*yes/ disable = no/" /tmp/xinetd.tftp.old > /etc/xinetd.d/tftp
  254. sed -i "s/\/var\/lib\/tftpboot/\/tftpboot/" /etc/xinetd.d/tftp
  255.  
  256. # Change which user apache runs as so freepbx can modify asterisk files
  257. sed -i "s/^User apache$/User asterisk/" /etc/httpd/conf/httpd.conf
  258. sed -i "s/^Group apache$/Group asterisk/" /etc/httpd/conf/httpd.conf
  259.  
  260. # The standard timeout will prevent us from downloading modules and installing them
  261. sed -i "s/^Timeout 120$/Timeout 300/" /etc/httpd/conf/httpd.conf
  262.  
  263. # Improve the amount of memory php can use
  264. sed -i "s/^memory_limit = 16M.*$/memory_limit = 128M/" /etc/php.ini
  265. sed -i "s/^memory_limit = 32M.*$/memory_limit = 128M/" /etc/php.ini
  266.  
  267. # Make a bunch of processes start on boot
  268. /sbin/chkconfig httpd on
  269. /sbin/chkconfig mysqld on
  270. /sbin/chkconfig ntpd on
  271. /sbin/chkconfig dnsmasq on
  272. /sbin/chkconfig incrond on
  273. /sbin/chkconfig fail2ban on
  274. /sbin/chkconfig tftp on
  275. /sbin/chkconfig openvpn off
  276.  
  277. # Various file ownership changes
  278. /bin/chown -R asterisk:asterisk /var/www/html
  279. /bin/chown -R asterisk:asterisk /var/lib/php/session
  280.  
  281. # Create rc.local
  282. /bin/echo "# Make sure asterisk starts on boot" >> /etc/rc.local
  283. /bin/echo "/usr/local/sbin/amportal start" >> /etc/rc.local
  284.  
  285. # write resolv.conf file
  286. /bin/echo "nameserver 127.0.0.1" > /etc/resolv.conf.new
  287. cat /etc/resolv.conf >> /etc/resolv.conf.new
  288. mv -f /etc/resolv.conf.new /etc/resolv.conf
  289.  
  290. # set up java stuff
  291. mkdir /usr/java
  292. ln -s /usr/java/jre1.7.0_05 /usr/java/latest
  293.  
  294. # install and configure aastra config file
  295. mkdir /tftpboot
  296. /bin/chown -R asterisk:asterisk /tftpboot
  297.  
  298. # change sshd_config settings
  299. sed -i "s/#UseDNS yes/UseDNS no/g" /etc/ssh/sshd_config
  300.  
  301. # Setup logger
  302. # remove logger.conf so FreePBX 2.10 can symlink to it
  303. rm -rf /etc/asterisk/logger.conf
  304.  
  305. # add voicemail.conf settings for contexts to dial from
  306. sed -i 's/;pollmailboxes=yes/pollmailboxes=yes/g' /etc/asterisk/vm_general.inc
  307. sed -i 's/;pollfreq=.*/pollfreq=10/g' /etc/asterisk/vm_general.inc
  308.  
  309. # Setup a odbc for asteriskcdrdb settings
  310. touch /etc/odbc.ini
  311. cat <<'EOF' >/etc/odbc.ini
  312. [MySQL-cel]
  313. Description=MySQL connection to 'asterisk' database
  314. driver=MySQL
  315. server=localhost
  316. database=asteriskcdrdb
  317. Port=3306
  318. Socket=/var/lib/mysql/mysql.sock
  319. option=3
  320. EOF
  321.  
  322. # create sudoers settings for user asterisk
  323. sed -i "s/Defaults\s*requiretty/#Defaults requiretty/g" /etc/sudoers
  324.  
  325. # Create Upgrade Notes Section
  326. mkdir /var/log/pbx
  327. mkdir /var/log/pbx/install
  328. mkdir /var/log/pbx/upgrade
  329. chown -R asterisk:asterisk /var/log/pbx
  330.  
  331. # fix php.ini config parameters
  332. sed -i 's/upload_max_filesize = .*/upload_max_filesize = 100M/' /etc/php.ini
  333. sed -i 's/post_max_size = .*/post_max_size = 100M/' /etc/php.ini
  334.  
  335. # run a weekly updatedb to keep locate up to date
  336. echo -e "#"\!"/bin/bash\nupdatedb" > /etc/cron.weekly/update-locate.sh
  337. chmod +x /etc/cron.weekly/update-locate.sh
  338.  
  339. #Set nano as default editor for crons
  340. echo "export VISUAL=nano" >> /root/.bashrc
  341.  
  342. # set permission of file that the FreePBX dahdi needs
  343. chown -R asterisk:asterisk /etc/modprobe.d/dahdi.conf
  344.  
  345. # Create Directory for version and license file
  346. mkdir /etc/schmooze
  347. chown asterisk:asterisk /etc/schmooze/
  348.  
  349. # Setup MySQL Logging Centos 6.x Only
  350. sed -i 's/\[mysqld\]/\[mysqld\]\ngeneral_log = 1\ngeneral_log_file = \/var\/log\/mysql\/mysql.log/g' /etc/my.cnf
  351. mkdir -p /var/log/mysql
  352.  
  353. #copy grub splash from sourcefiles directy Centos 6.x Only
  354. cd /boot/grub/
  355. wget http://upgrades.freepbxdistro.org/files/grub-splash.xpm.gz
  356.  
  357. ###########################################################################
  358. echo
  359. echo "Moving to Next Step"
  360. echo
  361. ###########################################################################
  362. # Install FreePBX and enable Modules.
  363. echo "Install FreePBX and enable Modules"
  364.  
  365. # FreePBX GUI
  366. yum -y install freepbx-2.11*
  367.  
  368. # Enable modules that in 2.11 are not being enabled from the RPM
  369. echo "Enable modules that in 2.11 are not being enabled from the RPM"
  370. sudo -u asterisk /var/lib/asterisk/bin/module_admin enable fw_ari
  371. sudo -u asterisk /var/lib/asterisk/bin/module_admin enable framework
  372. sudo -u asterisk /var/lib/asterisk/bin/module_admin disable fw_fop
  373. sudo -u asterisk /var/lib/asterisk/bin/retrieve_conf
  374. sudo -u asterisk /var/lib/asterisk/bin/module_admin reload
  375.  
  376. # pull in all freepbx modules and load them
  377. echo "pull in all freepbx modules and load them"
  378. `which amportal` chown
  379. # Install all core modules and reload
  380. sudo -u asterisk /var/lib/asterisk/bin/module_admin installall
  381. sudo -u asterisk /var/lib/asterisk/bin/module_admin installall
  382. sudo -u asterisk /var/lib/asterisk/bin/module_admin installall
  383. sudo -u asterisk /var/lib/asterisk/bin/retrieve_conf
  384. sudo -u asterisk /var/lib/asterisk/bin/module_admin reload
  385. # Install Misc non Core modules and reload
  386. sudo -u asterisk /var/lib/asterisk/bin/module_admin download sysadmin
  387. sudo -u asterisk /var/lib/asterisk/bin/module_admin install sysadmin
  388. sudo -u asterisk /var/lib/asterisk/bin/module_admin install sysadmin
  389. sudo -u asterisk /var/lib/asterisk/bin/module_admin --repos extended download dahdiconfig
  390. sudo -u asterisk /var/lib/asterisk/bin/module_admin --repos extended install dahdiconfig
  391. sudo -u asterisk /var/lib/asterisk/bin/module_admin --repos commercial installall
  392. sudo -u asterisk /var/lib/asterisk/bin/module_admin download motif
  393. sudo -u asterisk /var/lib/asterisk/bin/module_admin install motif
  394. sudo -u asterisk /var/lib/asterisk/bin/retrieve_conf
  395. sudo -u asterisk /var/lib/asterisk/bin/module_admin reload
  396.  
  397. # Sysadmin RPM for Sysadmin Module Moved to Firstboot or we can create the incrontab
  398. yum -y install sysadmin-*
  399.  
  400. # Install iSymphony
  401. yum -y install iSymphonyServer-fpbx-*
  402. sudo -u asterisk /var/lib/asterisk/bin/retrieve_conf
  403. sudo -u asterisk /var/lib/asterisk/bin/module_admin reload
  404.  
  405. # sed out wrong setting for EPM to handle more entries. Move to FreePBX RPM soon
  406. sed -i 's/AllowOverride None/AllowOverride Options/g' /etc/httpd/conf.d/freepbx.conf
  407.  
  408. # Pull down Asterisk Version switch script
  409. cd /usr/local/sbin
  410. wget http://upgrades.freepbxdistro.org/files/asterisk-version-switch
  411. chmod +x asterisk-version-switch
  412.  
  413. # add MOTD banner on SSH login
  414. echo "" > /etc/motd
  415. echo "/usr/local/sbin/MOTD.py" >> /etc/profile
  416. cd /usr/local/sbin/
  417. wget http://upgrades.freepbxdistro.org/files/MOTD.py
  418. chmod +x /usr/local/sbin/MOTD.py
  419.  
  420. ###########################################################################
  421. echo
  422. echo "Moving to Next Step"
  423. echo
  424. ###########################################################################
  425. # set some version information
  426. echo "$version" > /etc/schmooze/pbx-version
  427. echo "1.0.0.0" > /etc/schmooze/pbx-failsafe
  428. echo "$brand" > /etc/schmooze/pbx-brand
  429.  
  430. Footer
  431. © 2022 GitHub, Inc.
  432. Footer navigation
  433. Terms
  434. Privacy
  435. Security
  436. Status
  437. Docs
  438. Contact GitHub
  439. Pricing
  440. API
  441. Training
  442. Blog
  443. About
  444.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement