blob: 2deb3787f2a62b110eb67d171bc050817a188aae [file] [log] [blame]
Harald Welte632e8432017-09-05 18:12:14 +02001#!/bin/sh
2#
3# osmo-ggsn This shell script takes care of starting and stopping
4# osmo-ggsn.
5#
6# chkconfig: - 65 35
7# description: osmo-ggsn is a Gateway GPRS Support Node.
8
9# Source function library.
10. /etc/rc.d/init.d/functions
11
12# Source networking configuration.
13. /etc/sysconfig/network
14
15if [ -f /etc/sysconfig/osmo-ggsn ]; then
16 . /etc/sysconfig/osmo-ggsn
17fi
18
19# Check that networking is up.
20[ ${NETWORKING} = "no" ] && exit 0
21
22[ -f /usr/bin/osmo-ggsn ] || exit 0
23[ -f /etc/osmo-ggsn.cfg ] || exit 0
24
25RETVAL=0
26prog="osmo-ggsn"
27
28start() {
29 # Start daemons.
30 echo -n $"Starting $prog: "
31
32 # Load tun module
33 /sbin/modprobe tun >/dev/null 2>&1
34
35 # Enable routing of packets: WARNING!!!
36 # Users should enable this explicitly
37 # echo 1 > /proc/sys/net/ipv4/ip_forward
38
39 # Check for runtime directory of nonvolatile data
40 if [ ! -d /var/lib/osmo-ggsn ]; then
41 mkdir /var/lib/osmo-ggsn
42 fi
43
44 # Check for GTP restart counter
45 if [ ! -d /var/lib/osmo-ggsn/gsn_restart ]; then
46 echo 0 > /var/lib/osmo-ggsn/gsn_restart
47 fi
48
49
50 daemon /usr/bin/osmo-ggsn
51 RETVAL=$?
52 echo
53 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/osmo-ggsn
54 return $RETVAL
55}
56
57stop() {
58 # Stop daemons.
59 echo -n $"Shutting down $prog: "
60 killproc osmo-ggsn
61 RETVAL=$?
62 echo
63 [ $RETVAL = 0 ] && rm -f /var/lock/subsys/osmo-ggsn /var/run/osmo-ggsn.pid
64 return $RETVAL
65}
66
67# See how we were called.
68case "$1" in
69 start)
70 start
71 ;;
72 stop)
73 stop
74 ;;
75 restart|reload)
76 stop
77 start
78 RETVAL=$?
79 ;;
80 condrestart)
81 if [ -f /var/lock/subsys/osmo-ggsn ] ; then
82 stop
83 start
84 RETVAL=$?
85 fi
86 ;;
87 status)
88 status osmo-ggsn
89 RETVAL=$?
90 ;;
91 *)
92 echo $"Usage: $0 {start|stop|restart|condrestart|status}"
93 exit 1
94esac
95
96exit $RETVAL
97