Skip to content

Instantly share code, notes, and snippets.

@deivuh
Created June 29, 2014 02:57
Show Gist options
  • Save deivuh/0a66e74104b846c020a5 to your computer and use it in GitHub Desktop.
Save deivuh/0a66e74104b846c020a5 to your computer and use it in GitHub Desktop.
Bash services
#!/bin/sh
#
# myservice This shell script takes care of starting and stopping
# the /home/webreports/report-listen
#
# Source function library
. /etc/rc.d/init.d/functions
# Do preliminary checks here, if any
#### START of preliminary checks #########
##### END of preliminary checks #######
# Handle manual control parameters like start, stop, status, restart, etc.
case "$1" in
start)
# Start daemons.
echo -n $"Starting report-listen daemon: "
echo
daemon /home/webreports/report-listen
echo
;;
stop)
# Stop daemons.
echo -n $"Shutting down report-listen: "
killproc /home/webreports/report-listen
echo
# Do clean-up works here like removing pid files from /var/run, etc.
;;
status)
status /home/webreports/report-listen
;;
restart)
$0 stop
$0 start
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment