forked from LinusJun/docker-glass-isc-dhcp
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathservice
More file actions
53 lines (47 loc) · 1.07 KB
/
Copy pathservice
File metadata and controls
53 lines (47 loc) · 1.07 KB
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
#!/bin/sh
PIDFILE='/var/run/dhcp/dhcpd.pid'
start() {
echo 'Starting ISC-DHCP-SERVER...'
if [ -f "$PIDFILE" ] && [ ! $(pidof dhcpd) ]; then
echo 'Stale PID file, removing it.' >&2
rm "$PIDFILE"
elif [ ! -f "$PIDFILE" ] && [ $(pidof dhcpd) ]; then
echo 'Server is already running, but missing PID file.' >&2
echo "$(pidof dhcpd)" > "$PIDFILE"
echo 'Created new PID file'
fi
if [ ! -f "$PIDFILE" ] && [ ! $(pidof dhcpd) ]; then
bash -c '/usr/sbin/dhcpd -4 -f -d -cf /etc/dhcp/dhcpd.conf > /var/log/dhcp.log 2>&1 &'
echo 'Service started' >&2
else
echo 'Service is already running.'
fi
}
stop() {
echo "Stopping ISC-DHCP-SERVER..."
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service was not running' >&2
return 1
else
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
fi
}
case "$2" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
*)
echo "Usage: $0 isc-dhcp-server {start|stop|restart}"
exit 1
;;
esac
exit 0