Ticket #2646: freepbx_engine.patch

File freepbx_engine.patch, 2.9 kB (added by jfinstrom, 4 years ago)

the patch

  • freepbx_engine

    old new  
    9595check_asterisk() { 
    9696# check to see if asterisk is running 
    9797# 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.  We call this twice to reduce chances of this happening 
    98 pid_length=`pidof asterisk|awk '{print length($0)}'` 
     98pid_length=$(pidof asterisk|awk '{print length($0)}') 
    9999  if [ "$pid_length" == "0" -a "$pid_length" != "" ] 
    100100    then 
    101101        killall -9 safe_asterisk 
     
    108108        exit 0 
    109109    fi 
    110110} 
     111check_asterisk_kill() { 
     112# check to see if asterisk is running after killall 
     113# 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.  We call this twice to reduce chances of this happening 
     114pid_length=$(pidof asterisk|awk '{print length($0)}') 
     115  if [ "$pid_length" == "0" -a "$pid_length" != "" ] 
     116    then 
     117        killall -9 safe_asterisk 
     118        killall -9 asterisk 
     119        check_asterisk_kill 
     120    fi 
     121} 
    111122 
    112123run_asterisk() { 
    113124# check to see if asterisk is running 
    114125echo 
    115126echo "STARTING ASTERISK" 
    116 pid_length=`pidof asterisk|awk '{print length($0)}'` 
     127pid_length=$(pidof asterisk|awk '{print length($0)}') 
    117128  if [ "$pid_length" != "0" -a "$pid_length" != "" ] 
    118129    then 
    119130      echo "Asterisk is already running" 
     
    132143stop_asterisk() { 
    133144echo 
    134145echo "STOPPING ASTERISK" 
    135 pid_length=`pidof asterisk|awk '{print length($0)}'` 
     146pid_length=$(pidof asterisk|awk '{print length($0)}') 
    136147  if [ "$pid_length" != "0" -a "$pid_length" != "" ] 
    137148    then 
    138149      /usr/sbin/asterisk -rx "stop gracefully" 
     
    142153 
    143154check_fop() { 
    144155#check to see if FOP is running 
    145   pid_length=`pidof -x op_server.pl|awk '{print length($0)}'` 
     156  pid_length=$(pidof -x op_server.pl|awk '{print length($0)}') 
    146157  if [ "$pid_length" == "0" -a "$pid_length" != "" ] 
    147158    then 
    148159        ps -ef | grep safe_opserver | grep -v grep | awk '{print $2}' | xargs kill -9 
     
    159170# check to see if FOP is running 
    160171echo 
    161172echo "STARTING FOP SERVER" 
    162 pid_length=`pidof -x op_server.pl|awk '{print length($0)}'` 
     173pid_length=$(pidof -x op_server.pl|awk '{print length($0)}') 
    163174  if [ "$pid_length" != "0" -a "$pid_length" != "" ] 
    164175    then 
    165176      echo "FOP server is already running" 
     
    174185stop_fop() { 
    175186  echo 
    176187  echo "STOPPING FOP SERVER" 
    177   pid_length=`pidof -x op_server.pl|awk '{print length($0)}'` 
     188  pid_length=$(pidof -x op_server.pl|awk '{print length($0)}') 
    178189    if [ "$pid_length" != "0" -a "$pid_length" != "" ] 
    179190      then 
    180191        ps -ef | grep safe_opserver | grep -v grep | awk '{print $2}' | xargs kill 
     
    188199  echo "KILLING AMP PROCESSES" 
    189200  killall -9 safe_asterisk 
    190201  killall -9 asterisk 
     202  check_asterisk_kill 
    191203  killall -9 mpg123 
    192204  ps -ef | grep safe_opserver | grep -v grep | awk '{print $2}' | xargs kill -9 
    193205  killall -9 op_server.pl