Skip to content

Instantly share code, notes, and snippets.

@porcow
Created December 3, 2012 18:19
Show Gist options
  • Save porcow/4196849 to your computer and use it in GitHub Desktop.
Save porcow/4196849 to your computer and use it in GitHub Desktop.
System V init script
#!/bin/bash
#
# chkconfig: 35 90 12
# description: Foo server
#
# For CentOS and RedHat run the following command as root :
# /sbin/chkconfig FOO on
#
# Get function from functions library
. /etc/init.d/functions
# Start the service FOO
start() {
initlog -c "echo -n Starting FOO server: "
/path/to/FOO &
### Create the lock file ###
touch /var/lock/subsys/FOO
success $"FOO server startup"
echo
}
# Restart the service FOO
stop() {
initlog -c "echo -n Stopping FOO server: "
killproc FOO
### Now, delete the lock file ###
rm -f /var/lock/subsys/FOO
echo
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status FOO
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment