#!/bin/bash #servico Monitor Ramal # chkconfig: 3 98 99 # description: MonitorRamal Simples IP RETVAL=0 script="./mntRamal.php" function start () { if [ "`ps aux | grep $script | grep -v grep`" != "" ]; then echo "O script $script em execucao." exit 1 else php /var/lib/asterisk/scripts/monitoramento/$script & echo "iniciado ..." fi } function stop () { kill `ps aux | grep $script | grep -v "grep" | awk '{print $2}'` echo "O desligando monitoramento..." } function status () { if [ "`ps aux | grep $script | grep -v "grep"`" != "" ]; then return="Monitor Ramal Iniciado." else return="Monitor Ramal Parado." fi echo $return } case "$1" in start) start ;; stop) stop ;; restart) stop sleep 2 start ;; status) status ;; *) echo "Uso: $0 {start|stop|restart|status}" RETVAL=1 esac exit $RETVAL