| Server IP : 54.233.248.239 / Your IP : 172.28.1.13 Web Server : Apache System : Linux ip-172-28-29-189 6.5.0-1014-aws #14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.2.34-43+ubuntu22.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /etc/init.d/ |
Upload File : |
#!/bin/sh
# hibagent daemon
# chkconfig: - 20 80
# description: EC2 instance hibernation agent
# processname: hibagent
### BEGIN INIT INFO
# Provides: hibagent
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start EC2 Spot hibernation agent
### END INIT INFO
. /lib/lsb/init-functions
DAEMON_PATH="/usr/bin"
NAME=hibagent
DESC="My daemon description"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/hibagent
DAEMON=hibagent
DAEMONOPTS="--config /etc/hibagent-config.cfg --pidfile $PIDFILE"
if [ $# -eq 0 ]; then
echo "Usage: $0 {start|stop|restart}"
exit 1
else
COMMAND="$1"
fi
case $COMMAND in
start)
printf "%-50s" "Starting $NAME..."
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
if [[ "`ps axf | grep ${PID} | grep -v grep`" ]]; then
echo "hibagent is already running"
exit 0
fi
fi
cd $DAEMON_PATH
$DAEMON $DAEMONOPTS > /dev/null 2>&1
if [ $? -eq 0 ]; then
printf "%s\n" "Ok"
else
printf "%s\n" "Fail"
exit 1
fi
;;
status)
printf "%-50s" "Checking $NAME..."
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
printf "%s\n" "Process dead but pidfile exists"
else
echo "Running"
fi
else
printf "%s\n" "Service not running"
fi
;;
stop)
printf "%-50s" "Stopping $NAME"
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
kill -HUP $PID
printf "%s\n" "Ok"
rm -f $PIDFILE
exit 0
else
printf "%s\n" "already stopped"
exit 0
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {status|start|stop|restart}"
exit 1
esac