#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          GlobalProtect_VPN_Client
# Required-Start:    networking
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: VPN client from Palo Alto Networks GlobalProtect
# Description:       VPN client from Palo Alto Networks GlobalProtect
### END INIT INFO

NAME=pangps
DAEMON=/opt/paloaltonetworks/globalprotect/PanGPS

# If PanGPS is not there, then exit.

test -x $DAEMON || exit 5

case $1 in
    start)
    # Start the daemon.
    echo "Starting the process of pangps"
    # Start the daemon with the help of start-stop-daemon
    # Log the message appropriately
    if start-stop-daemon --start --background --quiet --oknodo --exec $DAEMON ; then
      echo "Start successful"
    else
     echo "Start failed"
    fi
    ;;

    stop)
    # Stop the daemon.
    if [ `pgrep PanGPS` ]; then
      start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
    else
     echo "pangps process is not running"
    fi
    ;;

    status)
    ;;

    restart)
    $0 stop && sleep 5 && $0 start
    ;;
esac
