Script will take argument as {start|stop|restart|status}
and do with process specified [here siproxd]
One can replace siproxd as other process or take process as a argument as well.
#!/bin/bash
#
# siproxd This shell script takes care of starting and stopping
#
# chkconfig: - 13 87
# description: To start the siproxd \
# probe: true
if [ $# != 1 ]; then
echo $"Usage: $0 {start|stop|restart|status}"
exit 3
fi
#echo -n $"Starting named: "
start()
{
inc=0
for i in `ps -A | grep siproxd | awk {'print $1'}`
do
#echo $i
inc=$(($inc+1));
done
if [ $inc != 0 ] ; then
echo -e $"Siproxd is already running: PID" $i
else
echo -e $"Starting siproxd....."
sleep 2
/usr/local/sbin/siproxd -d 0
fi
}
stop()
{
inc=0
for i in `ps -A | grep siproxd | awk {'print $1'}`
do
#echo $i
inc=$(($inc+1));
done
if [ $inc != 0 ] ; then
sleep 2
killall siproxd
echo -e $"Siproxd is stopped."
else
echo -e $"Siproxd was not running."
fi
}
restart()
{
inc=0
for i in `ps -A | grep siproxd | awk {'print $1'}`
do
#echo $i
inc=$(($inc+1));
done
if [ $inc != 0 ] ; then
echo -e "Stopping siproxd."
sleep 2
killall siproxd
else
echo -e "Siproxd was not running."
fi
echo -e "Starting siproxd."
sleep 3
/usr/local/sbin/siproxd -d 0
}
status()
{
inc=0
for i in `ps -A | grep siproxd | awk {'print $1'}`
do
#echo $i
inc=$(($inc+1));
done
if [ $inc != 0 ] ; then
echo -e "Siproxd is running: PID" $i
else
echo -e "Siproxd is not running."
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 3
esac
No comments:
Post a Comment