Current File : //etc/rc.d/rc2.d/S20datacycle |
#!/bin/bash
# description: start or stop the datacycle daemon
# chkconfig: 2345 20 10
# do not use systemctl on C7
SYSTEMCTL_SKIP_REDIRECT=1
# source function library
. /etc/rc.d/init.d/functions
PIDFILE='/var/run/datacycle.start'
if [[ -f $PIDFILE ]]; then
PID=$(cat $PIDFILE)
if [[ -d /proc/$PID ]]; then
RUNNING=1
else
RUNNING=0
fi
else
RUNNING=0
fi
case "$1" in
'start')
if [[ $RUNNING -eq 1 ]]; then
echo "datacycle already running"
exit 1
fi
echo "Starting datacycle.pl"
if [[ ! -d /proc/sys/fs/datacycle ]]; then
echo "cannot find /proc/sys/fs/datacycle, is this kernel patched?"
exit 1
fi
nohup /opt/eig_linux/datacycle.pl >/dev/null 2>&1 &
RETVAL=$?
;;
'stop')
if [[ $RUNNING -eq 0 ]]; then
echo "datacycle is not running"
exit 1
fi
echo "Stopping datacycle.pl"
kill -SIGABRT $PID
RETVAL=$?
;;
'restart')
if [[ $RUNNING -eq 0 ]]; then
echo "datacycle is not running"
else
echo "Stopping datacycle.pl"
kill -SIGINT $PID
sleep 2
fi
echo "Starting datacycle.pl"
nohup /opt/eig_linux/datacycle.pl >/dev/null 2>&1 &
RETVAL=$?
;;
'status')
status datacycle.pl
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
RETVAL=1
;;
esac
exit $RETVAL