Skip to content

Instantly share code, notes, and snippets.

@benasse
Last active October 9, 2022 11:29
Show Gist options
  • Save benasse/7e575749d23edc76cb7da7f9c5886428 to your computer and use it in GitHub Desktop.
Save benasse/7e575749d23edc76cb7da7f9c5886428 to your computer and use it in GitHub Desktop.
shellhub-agent-init
#! /bin/sh
### BEGIN INIT INFO
# Provides: shellhub-agent
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: manage shellhub-agent
### END INIT INFO
NAME="shellhub-agent"
DAEMON="__INSTALL_DIRECTORY__agent"
. /lib/lsb/init-functions
case "$1" in
start)
printf "Starting %s:" "$NAME"
start-stop-daemon --start --quiet --pidfile /var/run/"$NAME".pid --exec "$DAEMON" --background -m || true
echo "$NAME."
;;
stop)
printf "Stopping %s: " "$NAME"
start-stop-daemon --stop --quiet --pidfile /var/run/"$NAME".pid --exec "$DAEMON" || true
echo "$NAME."
;;
status)
echo "Status of shellhub-agent"
status_of_proc -p /var/run/"$NAME".pid "$DAEMON" shellhub-agent && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/shellhub-agent {start|stop|status}"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment