#! /bin/bash ### BEGIN INIT INFO # Provides: logmein-hamachi # Required-Start: $local_fs $network # Required-Stop: $local_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/stop logmein-hamachi engine ### END INIT INFO # # Author: LogMeIn, Inc. # PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="LogMeIn Hamachi VPN tunneling engine" NAME=logmein-hamachi DAEMON=/opt/logmein-hamachi/bin/hamachid PID=`pidof -o %PPID $DAEMON` PIDFILE=/var/run/logmein-hamachi/hamachid.pid #SCRIPTNAME=/etc/init.d/$NAME # Exit if the package is not installed [ -x "$DAEMON" ] || exit 5 # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME # Define LSB log_* functions. Depend on lsb-base (>= 3.0-6) #. /lib/lsb/init-functions . /etc/rc.conf . /etc/rc.d/functions # start the daemon/service do_start() { # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started #start_daemon -p $PIDFILE $DAEMON /opt/logmein-hamachi/bin/hamachid return "$?" } # stop the daemon/service do_stop() { # Return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred #stop_daemon $DAEMON #killproc -p $PIDFILE $DAEMON [ ! -z "$PID" ] && kill $PID &> /dev/null RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 # remove pidfile if daemon could not delete on exit. rm -f $PIDFILE return "$RETVAL" } case "$1" in start) echo -n "Starting $DESC $NAME" do_start case "$?" in 0|1) stat_done ; add_daemon logmein-hamachi ;; *) stat_fail ;; esac ;; stop) echo -n "Stopping $DESC $NAME" do_stop case "$?" in 0|1) stat_done ; rm_daemon logmein-hamachi ;; 2) stat_fail ;; esac ;; restart|force-reload) echo -n "Restarting $DESC $NAME" do_stop case "$?" in 0|1) sleep 1 do_start case "$?" in 0) stat_done ;; 1) stat_fail ;; # Old process is still running *) stat_fail ;; # Failed to start esac ;; *) # Failed to stop stat_fail ;; esac ;; *) #log_warning_msg "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 echo "usage: $0 {start|stop|restart}" exit 3 ;; esac :