1 | #!/bin/bash |
---|
2 | |
---|
3 | /sbin/postinst.sh post.mysqld || exit 1 |
---|
4 | svcstop /service/asterisk || exit 1 |
---|
5 | |
---|
6 | #too many problems with the old 2.6 amportal.conf, so just start fresh |
---|
7 | mv /etc/amportal.conf.new /etc/amportal.conf 2>/dev/null |
---|
8 | rm /etc/freepbx.conf 2>/dev/null |
---|
9 | |
---|
10 | #to allow 2.6 updating (otherwise install_amp will ask to overwrite) |
---|
11 | rm /etc/asterisk/cdr_mysql.conf /etc/asterisk/manager.conf /var/lib/asterisk/bin/freepbx_engine 2>/dev/null |
---|
12 | |
---|
13 | #freepbx uses absolute paths, so create two symlinks to make it work |
---|
14 | ln -s /var/www/htdocs/syn3/freepbx/admin/ /var/www/htdocs/admin 2>/dev/null |
---|
15 | ln -s /var/www/htdocs/syn3/freepbx/recordings/ /var/www/htdocs/recordings 2>/dev/null |
---|
16 | |
---|
17 | |
---|
18 | #create db and reset passwords |
---|
19 | ( echo create database asterisk\;; echo use asterisk\;; cat /var/spool/freepbx/newinstall.sql ) | syn3-mysqlcreate asterisk /etc/amportal.conf || exit 1 |
---|
20 | ( echo create database asteriskcdrdb\;; echo use asteriskcdrdb\;; cat /var/spool/freepbx/cdr_mysql_table.sql ) | mysql --user=root --password=`cat /etc/my.passwd` #ignore erorrs if it already exsts |
---|
21 | mysql --user=root --password=`cat /etc/my.passwd` -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asterisk@'localhost';" || exit 1 |
---|
22 | |
---|
23 | |
---|
24 | sed "s/passw0rd/`mkpasswd -s 0`/" -i /etc/amportal.conf |
---|
25 | sed "s/amp111/`mkpasswd -s 0`/" -i /etc/amportal.conf |
---|
26 | sed "s/ari_password/`mkpasswd -s 0`/" -i /etc/amportal.conf |
---|
27 | |
---|
28 | |
---|
29 | |
---|
30 | #upgrade/install freepbx |
---|
31 | echo "################################### generating base configs" |
---|
32 | cd /home/system/freepbx_upgrade |
---|
33 | ./apply_conf.sh /etc/amportal.conf || exit 1 |
---|
34 | svcstart /service/asterisk || exit 1 |
---|
35 | echo "################################### Installing/upgrading freepbx:" |
---|
36 | /usr/bin/php /home/system/freepbx_upgrade/install_amp || exit 1 |
---|
37 | |
---|
38 | #add minor updates |
---|
39 | echo "################################### Upgrading all modules" |
---|
40 | amportal a ma upgradeall #some scripts fail because the upgrade scripts overwrites itself, so only check last step |
---|
41 | amportal a ma enable framework |
---|
42 | amportal a ma enable fw_ari |
---|
43 | amportal a ma upgrade framework |
---|
44 | amportal a ma upgrade core |
---|
45 | amportal a ma upgradeall || exit 1 |
---|
46 | |
---|
47 | #install all standard modules |
---|
48 | echo "################################### Installing usefull modules" |
---|
49 | #NO: too much changes and unsupported modules: |
---|
50 | #amportal a ma installall #first one fails because the upgrade scripts overwrites itself |
---|
51 | #amportal a ma installall || exit 1 |
---|
52 | echo fax iaxsettings ivr parking queues ringgroups sipsettings timeconditions weakpasswords findmefollow announcement | xargs -n1 amportal a ma upgrade |
---|
53 | |
---|
54 | echo "################################### Generating dialplan" |
---|
55 | svcrestart /service/asterisk || exit 1 |
---|
56 | amportal a reload |
---|
57 | svcrestart /service/asterisk || exit 1 |
---|
58 | |
---|
59 | echo "################################### fixing permissions" |
---|
60 | chown -R nobody:nogroup /var/www/htdocs/syn3/freepbx /var/lib/asterisk/agi-bin || exit 1 |
---|
61 | chown -R nobody:nogroup /var/www/cgi-bin/ || exit 1 |
---|
62 | chown nobody:nogroup /etc/amportal.conf || exit 1 |
---|
63 | |
---|
64 | |
---|
65 | |
---|
66 | svcreset /service/mysql || exit 1 |
---|
67 | svcreset /service/asterisk || exit 1 |
---|