Created
October 24, 2018 08:36
-
-
Save yukikaoru/d3af74698aa25f6e78e9f3e04d36205b to your computer and use it in GitHub Desktop.
init.d template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# scriptname short desc | |
# chkconfig: - 80 20 | |
# description: long description | |
# processname: scriptname | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
prog=/path/to/prog | |
name=$(basename $0) | |
pidfile=/var/run/$name.pid | |
lockfile=/var/lock/subsys/$name | |
RETVAL=0 | |
start() { | |
echo -n "Starting ${name}..." | |
#cmd | |
RETVAL=$0 | |
echo | |
[ $RETVAL = 0 ] && touch $lockfile | |
return $RETVAL | |
} | |
stop() { | |
echo -n "Stopping ${name}..." | |
#cmd | |
RETVAL=$0 | |
echo | |
[ $RETVAL = 0 ] && rm -f $lockfile $pidfile | |
return $RETVAL | |
} | |
case $1 in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
start | |
;; | |
status) | |
status -p $pidfile $prog | |
RETVAL=2 | |
;; | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment