Compare Pastes

Differences between the pastes #270658 (11.09.2023 13:56) and #270659 (11.09.2023 13:56).
1
#!/bin/sh
2
#
3
### BEGIN INIT INFO
4
# Provides:          vpnagentd
5
# Required-Start:    $network $remote_fs
6
# Required-Stop:     $remote_fs
7
# Default-Start:     3 5
8
# Default-Stop:  
9
# Description:       Cisco AnyConnect Secure Mobility Client for Linux
10
# chkconfig:         345 85 25
11
# processname:       vpnagentd
12
### END INIT INFO
13
14
# Source function library 
15
  if [ -f "/etc/init.d/functions" ]; then
16
    # Redhat will have library here
17
    . /etc/init.d/functions
18
  else
19
    if [ -f "/lib/lsb/init-functions" ]; then
20
      # Ubuntu will have library here
21
      . /lib/lsb/init-functions
22
    fi
23
  fi
24
25
CLIENTNAME="Cisco AnyConnect Secure Mobility Client Agent"
26
RETVAL=0
27
PIDFILE="/var/run/vpnagentd.pid"
28
29
start() {
30
  # If TUN isn't supported by the kernel, try loading the module...
31
  /bin/lsmod | grep tun > /dev/null 
32
  if [ $? -ne 0 ]; then
33
    /sbin/modprobe tun > /dev/null 2> /dev/null
34
    if [ $? -ne 0 ]; then
35
      # check for /dev/net/tun
36
      [ -c "/dev/net/tun" ] || echo  Warning: Unable to verify that the tun/tap driver is loaded.  Contact your system administrator for assistance.
37
    fi
38
  fi
39
40
  echo -n "Starting up $CLIENTNAME"
41
  /opt/cisco/anyconnect/bin/vpnagentd
42
  RETVAL=$?
43
  echo
44
  return $RETVAL
45
}
46
47
stop() {
48
  echo -n "Shutting down $CLIENTNAME"
49
  VPNPID=$( pidof /opt/cisco/anyconnect/bin/vpnagentd )
50
  if [ "x${VPNPID}" != "x" ] ; then
51
    # wait until vpnagentd dies, or 10 secs
52
    kill ${VPNPID} > /dev/null 2>/dev/null
53
    VPNPID=$( pidof /opt/cisco/anyconnect/bin/vpnagentd )
54
    t=0
55
    while [ "x${VPNPID}" != "x" -a $t -le 10 ]; do 
56
      sleep 1
57
      t=$( expr $t + 1 )
58
      VPNPID=$( pidof /opt/cisco/anyconnect/bin/vpnagentd )
59
    done
60
    if [ "x${VPNPID}" != "x" ] ; then
61
       kill -9 ${VPNPID} > /dev/null 2>/dev/null
62
    fi
63
  fi
64
  RETVAL=$?
65
  echo
66
  return $RETVAL
67
}
68
69
dostatus() {
70
  if [ -f "/etc/init.d/functions" ]; then
71
    status vpnagentd
72
  else
73
    if [ -f "/lib/lsb/init-functions" ]; then
74
      if [ -f $PIDFILE ]; then
75
        status_of_proc -p $PIDFILE vpnagentd "vpnagentd (pid `cat $PIDFILE`)" | sed 's/^[ \*]\+//'
76
      else
77
        echo "vpnagentd is stopped "
78
      fi
79
    fi
80
  fi
81
}
82
83
restart() {
84
	stop
85
	start
86
}
87
88
# See how we were called.
89
case "$1" in
90
  start)
91
	start
92
	;;
93
  stop)
94
	stop
95
	;;
96
  restart)
97
    restart
98
    ;;
99
  status)
100
	dostatus
101
	;;
102
  *)
103
	echo "Usage: vpnagentd {start|stop|restart|status}"
104
	exit 1
105
esac
106
1
#!/bin/sh
2
#
3
### BEGIN INIT INFO
4
# Provides:          vpnagentd
5
# Required-Start:    $network $remote_fs
6
# Required-Stop:     $remote_fs
7
# Default-Start:     3 5
8
# Default-Stop:  
9
# Description:       Cisco AnyConnect Secure Mobility Client for Linux
10
# chkconfig:         345 85 25
11
# processname:       vpnagentd
12
### END INIT INFO
13
14
# Source function library 
15
  if [ -f "/etc/init.d/functions" ]; then
16
    # Redhat will have library here
17
    . /etc/init.d/functions
18
  else
19
    if [ -f "/lib/lsb/init-functions" ]; then
20
      # Ubuntu will have library here
21
      . /lib/lsb/init-functions
22
    fi
23
  fi
24
25
CLIENTNAME="Cisco AnyConnect Secure Mobility Client Agent"
26
RETVAL=0
27
PIDFILE="/var/run/vpnagentd.pid"
28
29
start() {
30
  # If TUN isn't supported by the kernel, try loading the module...
31
  /bin/lsmod | grep tun > /dev/null 
32
  if [ $? -ne 0 ]; then
33
    /sbin/modprobe tun > /dev/null 2> /dev/null
34
    if [ $? -ne 0 ]; then
35
      # check for /dev/net/tun
36
      [ -c "/dev/net/tun" ] || echo  Warning: Unable to verify that the tun/tap driver is loaded.  Contact your system administrator for assistance.
37
    fi
38
  fi
39
40
  echo -n "Starting up $CLIENTNAME"
41
  /opt/cisco/anyconnect/bin/vpnagentd
42
  RETVAL=$?
43
  echo
44
  return $RETVAL
45
}
46
47
stop() {
48
  echo -n "Shutting down $CLIENTNAME"
49
  VPNPID=$( pidof /opt/cisco/anyconnect/bin/vpnagentd )
50
  if [ "x${VPNPID}" != "x" ] ; then
51
    # wait until vpnagentd dies, or 10 secs
52
    kill ${VPNPID} > /dev/null 2>/dev/null
53
    VPNPID=$( pidof /opt/cisco/anyconnect/bin/vpnagentd )
54
    t=0
55
    while [ "x${VPNPID}" != "x" -a $t -le 10 ]; do 
56
      sleep 1
57
      t=$( expr $t + 1 )
58
      VPNPID=$( pidof /opt/cisco/anyconnect/bin/vpnagentd )
59
    done
60
    if [ "x${VPNPID}" != "x" ] ; then
61
       kill -9 ${VPNPID} > /dev/null 2>/dev/null
62
    fi
63
  fi
64
  RETVAL=$?
65
  echo
66
  return $RETVAL
67
}
68
69
dostatus() {
70
  if [ -f "/etc/init.d/functions" ]; then
71
    status vpnagentd
72
  else
73
    if [ -f "/lib/lsb/init-functions" ]; then
74
      if [ -f $PIDFILE ]; then
75
        status_of_proc -p $PIDFILE vpnagentd "vpnagentd (pid `cat $PIDFILE`)" | sed 's/^[ \*]\+//'
76
      else
77
        echo "vpnagentd is stopped "
78
      fi
79
    fi
80
  fi
81
}
82
83
restart() {
84
	stop
85
	start
86
}
87
88
# See how we were called.
89
case "$1" in
90
  start)
91
	start
92
	;;
93
  stop)
94
	stop
95
	;;
96
  restart)
97
    restart
98
    ;;
99
  status)
100
	dostatus
101
	;;
102
  *)
103
	echo "Usage: vpnagentd {start|stop|restart|status}"
104
	exit 1
105
esac
106