forked from inverse-inc/packetfence
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packetfence.init
executable file
·120 lines (111 loc) · 2.37 KB
/
packetfence.init
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
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
#
# Init script for PacketFence network registration / worm mitigation system
#
# chkconfig: 345 90 10
# description: PacketFence network registration / worm mitigation system
#
# processname:
# config: /usr/local/pf/conf/pf.conf
source /etc/rc.d/init.d/functions
[ -x /usr/local/pf/bin/pfcmd ] || exit 1
start() {
if [ -z ${1+x} ]; then
pfredis_cache
pfconfig
echo -n $"Starting PacketFence..."
IPSET=`command -v ipset`
if [ $IPSET ]; then
modprobe ip_set
#flush any previous ipset rules
/usr/sbin/ipset destroy
fi
/sbin/vconfig set_name_type DEV_PLUS_VID_NO_PAD
/usr/local/pf/bin/pfcmd service pf start
RETVAL=$?
echo
return $RETVAL
else
echo -n $"Starting $1"
/usr/local/pf/bin/pfcmd service $1 start;
RETVAL=$?
echo
return $RETVAL
fi
}
stop() {
if [ -z ${1+x} ]; then
pfredis_cache
pfconfig
echo -n $"Shutting down PacketFence..."
/usr/local/pf/bin/pfcmd service pf stop
RETVAL=$?
echo
return $RETVAL
else
echo -n $"Shutting down $1"
/usr/local/pf/bin/pfcmd service $1 start;
RETVAL=$?
echo
return $RETVAL
fi
}
restart() {
if [ -z ${1+x} ]; then
pfredis_cache
pfconfig
echo -n $"Restarting PacketFence..."
/usr/local/pf/bin/pfcmd service pf restart
RETVAL=$?
echo
return $RETVAL
else
echo -n $"Restarting $1"
/usr/local/pf/bin/pfcmd service $1 restart;
RETVAL=$?
echo
return $RETVAL
fi
}
pfredis_cache() {
/etc/init.d/packetfence-redis-cache start
}
pfconfig() {
# Check if packetfence-config is started
if [ ! -f /usr/local/pf/var/run/pfconfig.pid ] || ! ps -p $(cat /usr/local/pf/var/run/pfconfig.pid) > /dev/null; then
if [ -f /etc/init.d/packetfence-config ]; then
/etc/init.d/packetfence-config start
fi
fi
}
case "$1" in
start)
start $2
;;
stop)
stop $2
;;
restart)
restart $2
;;
status)
pfconfig
/usr/local/pf/bin/pfcmd service pf status
if [ ! -f /usr/local/pf/var/run/pfmon.pid ]; then
RETVAL=3
fi
;;
condrestart)
if [ -f /usr/local/pf/var/run/pfmon.pid ]; then
restart
else
if [ -f /usr/local/pf/var/run/pfsetvlan.pid ]; then
restart
fi
fi
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
RETVAL=1
esac
exit $RETVAL