updated on Thu Jan 19 04:14:35 UTC 2012
[aur-mirror.git] / freepbx / freepbx.install
blob5109d6741cc23328cf6bf9d81a934349473612b4
1 pre_install ()
3   red='\e[1;31m'
4   nc='\e[0m'
5   
6   echo ">>> Performing pre-installation checks"
7   echo ">>>"
8   echo ">>> Checking for mysql server"
9   if [ "$(pidof mysqld)" ]
10   then
11     echo ">>>"
12     echo ">>> Good"
13     echo ">>>"
14   else
15     echo -e "${red}>>> FreePBX requires Mysql server!"
16     echo -e ">>> Mysql is not Running!"
17     echo -e ">>> Please start Mysql server before continuing the installation!"
18     echo -e ">>>${nc}"
19   fi
21   echo ">>> Checking for Apache"
22   if [ "$(pidof httpd)" ]
23   then
24     echo ">>>"
25     echo ">>> Good"
26     echo ">>>"
27   else
28     echo -e "${red}>>> FreePBX requires Apache!"
29     echo -e ">>> Apache is not Running!"
30     echo -e ">>> Please start Apache before continuing the installation!"
31     echo -e ">>>${nc}"
32   fi
34   php_config="/etc/php/php.ini"
35   echo ">>> Checking for PHP"
36   if [ -e $php_config ]
37   then
38     echo ">>>"
39     echo ">>> Good"
40     echo ">>>"
41   else
42     echo -e "${red}>>> FreePBX requires PHP!"
43     echo -e ">>> Please enable PHP and restart Apache"
44     echo -e ">>> before continuing the installation!"
45     echo -e ">>>${nc}"
46   fi
48   echo ">>> Checking for PHP-MYSQL"
49   if [ "$(grep '^extension=mysql.so' /etc/php/php.ini)" ]
50   then
51     echo ">>>"
52     echo ">>> Good"
53     echo ">>>"
54   else
55     echo -e "${red}>>> FreePBX requires PHP-MYSQL!"
56     echo -e ">>> Please enable mysql.so in php.ini and restart Apache"
57     echo -e ">>> before continuing the installation!"
58     echo -e ">>>${nc}"
59   fi
61   echo ">>> Checking for PHP-POSIX"
62   if [ "$(grep '^extension=mysql.so' /etc/php/php.ini)" ]
63   then
64     echo ">>>"
65     echo ">>> Good"
66     echo ">>>"
67   else
68     echo -e "${red}>>> FreePBX requires PHP-POSIX!"
69     echo -e ">>> Please enable posix.so in php.ini and restart Apache"
70     echo -e ">>> before continuing the installation!"
71     echo -e ">>>${nc}"
72   fi
74   echo ">>> Checking if open_basedir is set"
75   if [ "$(grep '^open_basedir' /etc/php/php.ini)" ]
76   then
77     echo -e "${red}>>> FreePBX cannot be installed with open_basedir set."
78     echo -e ">>> Please comment out open_basedir in php.ini and restart Apache"
79     echo -e ">>> before continuing the installation!"
80     echo -e ">>>${nc}"
81   else
82     echo ">>>"
83     echo ">>> Good"
84     echo ">>>"
85   fi
88 post_install() {
90 pear install DB
91 echo ">>>       Please create databases for FreePBX using the following commands:"
92 echo ">>>       # mysqladmin create asteriskcdrdb -p"
93 echo ">>>       # mysql --user=root --password=db_root_pwd asteriskcdrdb < /usr/src/freepbx-$1/SQL/cdr_mysql_table.sql"
94 echo ">>>"      
95 echo ">>>"
96 echo ">>>       # mysqladmin create asterisk -p"
97 echo ">>>       # mysql --user root -p asterisk < /usr/src/freepbx-$1/SQL/newinstall.sql"
98 echo ">>>"      
99 echo ">>>"
100 echo ">>>       # mysql --user root -p"
101 echo ">>>       mysql> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'password';"
102 echo ">>>       mysql> GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'password';"
103 echo ">>>       mysql> quit"
104 echo ">>>"
105 echo ">>>       And then run:"
106 echo ">>>"
107 echo ">>>       cd /usr/src/freepbx-$1 && ./install_amp --username=asteriskuser --password=password"
108 echo ">>>"
109 echo ">>>       to complete the installation"
110 /bin/true
112           
113 post_upgrade() {
114 echo ">>>       Please run:"
115 echo ">>>"
116 echo ">>>       cd /usr/src/freepbx-$1 && ./install_amp"
117 echo ">>>"
118 echo ">>>       to complete the upgrade"
119 /bin/true
121                         
122 op=$1
123 shift
124 $op $*