Paste #270660

   
pasted on 11.09.2023 13:57
  • Edit to this paste
  • Print
  • Raw
  • Compare it with the parent paste
  • Look at the parent paste
  • Show paste tree
  • Compare with paste
    #  
  • Toggle line numbers
  • Syntax highlighting  
Text paste
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
#!/bin/sh
#
### BEGIN INIT INFO
# Provides:          vpnagentd
# Required-Start:    $network $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     3 5
# Default-Stop:  
# Description:       Cisco AnyConnect Secure Mobility Client for Linux
# chkconfig:         345 85 25
# processname:       vpnagentd
### END INIT INFO

# Source function library 
  if [ -f "/etc/init.d/functions" ]; then
    # Redhat will have library here
    . /etc/init.d/functions
  else
    if [ -f "/lib/lsb/init-functions" ]; then
      # Ubuntu will have library here
      . /lib/lsb/init-functions
    fi
  fi

CLIENTNAME="Cisco AnyConnect Secure Mobility Client Agent"
RETVAL=0
PIDFILE="/var/run/vpnagentd.pid"

start() {
  # If TUN isn't supported by the kernel, try loading the module...
  /bin/lsmod | grep tun > /dev/null 
  if [ $? -ne 0 ]; then
    /sbin/modprobe tun > /dev/null 2> /dev/null
    if [ $? -ne 0 ]; then
      # check for /dev/net/tun
      [ -c "/dev/net/tun" ] || echo  Warning: Unable to verify that the tun/tap driver is loaded.  Contact your system administrator for assistance.
    fi
  fi

  echo -n "Starting up $CLIENTNAME"
  /opt/cisco/anyconnect/bin/vpnagentd
  RETVAL=$?
  echo
  return $RETVAL
}

stop() {
  echo -n "Shutting down $CLIENTNAME"
  VPNPID=$( pidof /opt/cisco/anyconnect/bin/vpnagentd )
  if [ "x${VPNPID}" != "x" ] ; then
    # wait until vpnagentd dies, or 10 secs
    kill ${VPNPID} > /dev/null 2>/dev/null
    VPNPID=$( pidof /opt/cisco/anyconnect/bin/vpnagentd )
    t=0
    while [ "x${VPNPID}" != "x" -a $t -le 10 ]; do 
      sleep 1
      t=$( expr $t + 1 )
      VPNPID=$( pidof /opt/cisco/anyconnect/bin/vpnagentd )
    done
    if [ "x${VPNPID}" != "x" ] ; then
       kill -9 ${VPNPID} > /dev/null 2>/dev/null
    fi
  fi
  RETVAL=$?
  echo
  return $RETVAL
}

dostatus() {
  if [ -f "/etc/init.d/functions" ]; then
    status vpnagentd
  else
    if [ -f "/lib/lsb/init-functions" ]; then
      if [ -f $PIDFILE ]; then
        status_of_proc -p $PIDFILE vpnagentd "vpnagentd (pid `cat $PIDFILE`)" | sed 's/^[ \*]\+//'
      else
        echo "vpnagentd is stopped "
      fi
    fi
  fi
}

restart() {
	stop
	start
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
    restart
    ;;
  status)
	dostatus
	;;
  *)
	echo "Usage: vpnagentd {start|stop|restart|status}"
	exit 1
esac

exit $RETVAL
Add Comment
Author