Skip to content

Instantly share code, notes, and snippets.

@leafsummer
Created August 22, 2019 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leafsummer/da9ebcf179e17062969979fafd554d70 to your computer and use it in GitHub Desktop.
Save leafsummer/da9ebcf179e17062969979fafd554d70 to your computer and use it in GitHub Desktop.
[start a daemon with ubuntu shell]
#!/bin/sh
### BEGIN INIT INFO
# Provides: apache2
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Start/stop apache2 web server
# Description: Start the web server and associated helpers
# This script will start apache2, and possibly all associated instances.
# Moreover, it will set-up temporary directories and helper tools such as
# htcacheclean when required by the configuration.
### END INIT INFO
DESC="description goes here"
NAME=provess-name
DAEMON=/usr/sbin/$NAME
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
initctl start provess-name
RET_STATUS=$?
case "$RET_STATUS" in
0|1)
log_success_msg
[ $RET_STATUS = 1 ] && log_warning_msg "Server was already running"
;;
2)
log_failure_msg
print_error_msg
exit 1
;;
esac
;;
stop|graceful-stop)
log_daemon_msg "Stopping $DESC" "$NAME"
initctl stop provess-name
RET_STATUS=$?
case "$RET_STATUS" in
0|1)
log_success_msg
[ $RET_STATUS = 1 ] && log_warning_msg "Process was not running"
;;
2)
log_failure_msg
print_error_msg
exit 1
;;
esac
print_error_msg
;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment