root/freepbx/trunk/start_asterisk

Revision 7598, 3.2 kB (checked in by p_lindheimer, 4 years ago)

Merged revisions 7552-7571,7573-7597 via svnmerge from
http://svn.freepbx.org/freepbx/branches/2.5

........

r7552 | mickecarlsson | 2009-03-26 23:09:45 -0700 (Thu, 26 Mar 2009) | 1 line


Added GPL license text to various files

........

r7591 | p_lindheimer | 2009-04-27 12:09:11 -0700 (Mon, 27 Apr 2009) | 1 line


fix error message so it is same wether username was correct or not

........

r7592 | p_lindheimer | 2009-04-27 13:34:43 -0700 (Mon, 27 Apr 2009) | 1 line


make sure the requested report display is included in the menu items list, otherwise bogus values can be injected

........

r7593 | p_lindheimer | 2009-04-27 13:54:36 -0700 (Mon, 27 Apr 2009) | 1 line


make sure no bogus characters or scripts are injected in a get with the POST/GET variables that reporting uses

........

r7594 | p_lindheimer | 2009-04-27 15:23:37 -0700 (Mon, 27 Apr 2009) | 1 line


run extdisplay and all the derivatives through htmlspecialchars since many pages echo it in the display, this keeps any bogus characters that could create issues from being injected if a url is manually be typed in

........

r7595 | p_lindheimer | 2009-04-27 15:25:25 -0700 (Mon, 27 Apr 2009) | 1 line


filter the search parameters (and sort) to keep bogus entries from creating problems when redisplayed or links generated

........

r7597 | p_lindheimer | 2009-04-29 16:35:39 -0700 (Wed, 29 Apr 2009) | 1 line


add security check when action verb is set to protect against CSRF attacks, but can be disabled with CHECREFERER=false in amportal.conf

........

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/usr/bin/env bash
2 # This file is part of FreePBX.
3 #
4 #    FreePBX is free software: you can redistribute it and/or modify
5 #    it under the terms of the GNU General Public License as published by
6 #    the Free Software Foundation, either version 2 of the License, or
7 #    (at your option) any later version.
8 #
9 #    FreePBX is distributed in the hope that it will be useful,
10 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #    GNU General Public License for more details.
13 #
14 #    You should have received a copy of the GNU General Public License
15 #    along with FreePBX.  If not, see <http://www.gnu.org/licenses/>.
16 #
17 #    Copyright 2007, Philippe Lindheimer
18 #
19 ROOT_UID=0   # root uid is 0
20 E_NOTROOT=67   # Non-root exit error
21
22 echo
23 # check to see if we are root
24 if [ "$UID" -ne "$ROOT_UID" ]
25 then
26   echo "Sorry, you must be root to run this script."
27   echo
28   exit $E_NOTROOT
29 fi
30
31 check_asterisk() {
32 # check to see if asterisk is running
33 # Note, this isn't fool-proof.  If safe_asterisk is constantly restarting a dying asterisk, then there is a chance pidof will return non zero. 
34 # We call this twice to reduce chances of this happening
35 pid_length=`pidof asterisk|awk '{print length($0)}'`
36   if [ "$pid_length" == "0" -a "$pid_length" != "" ]
37     then
38         killall -9 safe_asterisk
39         killall -9 mpg123 > /dev/null
40         echo
41         echo "-----------------------------------------------------"
42         echo "Asterisk could not start!"
43         echo "Use 'tail $ASTLOGDIR/full' to find out why."
44         echo "-----------------------------------------------------"
45         exit 0
46     fi
47 }
48
49 run_asterisk() {
50 # check to see if asterisk is running
51 echo
52 echo "STARTING ASTERISK"
53 pid_length=`pidof asterisk|awk '{print length($0)}'`
54   if [ "$pid_length" != "0" -a "$pid_length" != "" ]
55     then
56       echo "Asterisk is already running"
57     else
58       # su - asterisk -c "export PATH=$PATH:/usr/sbin && export LD_LIBRARY_PATH=/usr/local/lib && /usr/sbin/safe_asterisk"
59       export LD_LIBRARY_PATH=/usr/local/lib
60       /usr/sbin/safe_asterisk -U asterisk -G asterisk
61       sleep 5
62       check_asterisk
63       sleep 1
64       check_asterisk
65       echo "Asterisk Started"
66     fi
67 }
68
69 stop_asterisk() {
70 echo
71 echo "STOPPING ASTERISK"
72 pid_length=`pidof asterisk|awk '{print length($0)}'`
73   if [ "$pid_length" != "0" -a "$pid_length" != "" ]
74     then
75       /usr/sbin/asterisk -rx "stop gracefully"
76       echo "Asterisk Stopped"
77     fi
78 }
79
80 kill_amp() {
81   echo
82   echo "KILLING AMP PROCESSES"
83   killall -9 safe_asterisk
84   killall -9 asterisk
85   killall -9 mpg123
86   ps -ef | grep safe_opserver | grep -v grep | awk '{print $2}' | xargs kill -9
87   killall -9 op_server.pl
88 }
89
90 case "$1" in
91   start)
92     run_asterisk
93   ;;
94   stop)
95     stop_asterisk
96   ;;
97   restart)
98     stop_asterisk
99     sleep 1
100     run_asterisk
101   ;;
102   kill)
103     kill_amp
104   ;;
105   *)
106     echo "-------------FreePBX Control Script-----------------------------------------------"
107     echo
108     echo "Usage:       amportal start|stop|restart|start_fop|stop_fop|restart_fop|kill|chown"
109     echo
110     echo "start:       Starts Asterisk and Flash Operator Panel server if enabled"
111     echo "stop:        Gracefully stops Asterisk and the FOP server"
112     echo "restart:     Stop and Starts"
113     echo "kill:        Kills Asterisk and the FOP server"
114     echo
115     exit 1
116   ;;
117 esac
118
Note: See TracBrowser for help on using the browser.