acl/dist/master/init.d/acl-master

153 lines
2.8 KiB
Bash
Executable File

#!/bin/sh
#
#set -x
# acl_master Start/Stop the acl_master daemon.
#
# chkconfig: 2345 90 60
# description: acl master framework
### BEGIN INIT INFO
# Provides: acl_master crontab
# Required-Start: $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2345
# Default-Stop: 90
# Short-Description: acl - master framework to control services
### END INIT INFO
RETVAL=0
prog="acl_master"
HOME_PATH={install_path}
exec=$HOME_PATH/libexec/acl_master
PROG_NAME=acl_master
PID_FILE=$HOME_PATH/var/pid/acl_master.pid
EXE_PATH=$HOME_PATH/libexec/$PROG_NAME
CONF_PATH=$HOME_PATH/conf
LOG_PATH=$HOME_PATH/var/log/acl_master
lockfile=/var/lock/subsys/acl_master
# Source function library.
# use systemd
# SYSTEMCTL_SKIP_REDIRECT=1
. /etc/rc.d/init.d/functions
# A function to find the pid of a program. Looks *only* at the pidfile
findpidfileofproc() {
local pid
# Test syntax.
if [ "$#" = 0 ] ; then
echo $"Usage: pidfileofproc {program}"
return 1
fi
__pids_var_run "$1" "$2"
[ -n "$pid" ] && echo $pid
return 0
}
start() {
if [ $UID -ne 0 ] ; then
echo "User has insufficient privilege."
exit 4
fi
[ -x $exec ] || exit 5
echo -n $"Starting $prog: "
ulimit -c 0
ulimit -n 204800
trap '' 1
#daemon --pidfile=${PID_FILE}
$exec -k -c $CONF_PATH -l $LOG_PATH &
sleep 1
rh_status_q && success
echo
retval=$?
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
if [ $UID -ne 0 ] ; then
echo "User has insufficient privilege."
exit 4
fi
echo -n $"Stopping $prog: "
if [ -n "`findpidfileofproc $exec $PID_FILE`" ]; then
killproc -p $PID_FILE -d 3 $exec
RETVAL=3
else
failure $"Stopping $prog"
fi
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
sleep 1
start
}
reload() {
echo -n $"Reloading $prog: "
if [ -n "`findpidfileofproc $exec $PID_FILE`" ]; then
killproc $exec -HUP
else
failure $"Reloading $prog"
fi
retval=$?
echo
}
force_reload() {
# new configuration takes effect after restart
restart
}
rh_status() {
# run checks to determine if the service is running or use generic status
status -p $PID_FILE $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status || exit 0
;;
masterrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?