Skip to content
Snippets Groups Projects
Commit d45eda49 authored by Erick Hitter's avatar Erick Hitter
Browse files

I'm dumb

parent b2a085f2
No related branches found
No related tags found
No related merge requests found
......@@ -25,59 +25,25 @@ NAME=ssh-tunnel-manager
USER=root
DAEMON="/usr/local/bin/${NAME}"
CONFIG="/etc/ssh-tunnel-manager.conf"
PIDFILE="/var/run/${NAME}.pid"
# Overrides
[ -f "/etc/default/$NAME" ] && . /etc/default/$NAME
# If the daemon is not there, then exit.
test -x $DAEMON || exit 5
# If the config is not there, then exit.
test -f $CONFIG || exit 6
case $1 in
start)
# Checked the PID file exists and check the actual status of process
if [ -e $PIDFILE ]; then
status_of_proc -p $PIDFILE $DAEMON "$NAME process" && status="0" || status="$?"
# If the status is SUCCESS then don't need to start again.
if [ $status = "0" ]; then
exit # Exit
fi
fi
# Start the daemon.
log_daemon_msg "Starting the process" "$NAME"
# Start the daemon with the help of start-stop-daemon
# Log the message appropriately
if start-stop-daemon --start --chuid $USER --background --oknodo --pidfile $PIDFILE --make-pidfile --exec $DAEMON -- $CONFIG; then
log_end_msg 0
else
log_end_msg 1
fi
sudo -u $USER -H $DAEMON start
;;
stop)
# Stop the daemon.
if [ -e $PIDFILE ]; then
status_of_proc -p $PIDFILE $DAEMON "Stoppping the $NAME process" && status="0" || status="$?"
if [ "$status" = 0 ]; then
start-stop-daemon --stop --retry=TERM/60/KILL/5 --quiet --oknodo --pidfile $PIDFILE
/bin/rm -rf $PIDFILE
fi
else
log_daemon_msg "$NAME process is not running"
log_end_msg 0
fi
sudo -u $USER -H $DAEMON stop
;;
restart)
# Restart the daemon.
$0 stop && sleep 2 && $0 start
sudo -u $USER -H $DAEMON restart
;;
status)
# Check the status of the process.
if [ -e $PIDFILE ]; then
status_of_proc -p $PIDFILE $DAEMON "$NAME process" && exit 0 || exit $?
else
log_daemon_msg "$NAME Process is not running"
log_end_msg 0
fi
sudo -u $USER -H $DAEMON status
;;
*)
# For invalid arguments, print the usage message.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment