~smoser/ubuntu/precise/isc-dhcp/nouid

« back to all changes in this revision

Viewing changes to debian/isc-dhcp-server.isc-dhcp-server6.upstart

  • Committer: Stéphane Graber
  • Date: 2012-03-08 00:05:52 UTC
  • Revision ID: stgraber@ubuntu.com-20120308000552-7jyj494xr8adsh5f
Convert each sysvinit job into two upstart jobs one for IPv4 and one for IPv6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
description "ISC DHCP IPv6 server"
 
2
author "Stéphane Graber <stgraber@ubuntu.com>"
 
3
 
 
4
start on runlevel [2345]
 
5
stop on runlevel [!2345]
 
6
 
 
7
pre-start script
 
8
    if [ ! -f /etc/default/isc-dhcp-server ]; then
 
9
        echo "/etc/default/isc-dhcp-server does not exist! - Aborting..."
 
10
        echo "Run 'dpkg-reconfigure isc-dhcp-server' to fix the problem."
 
11
        stop
 
12
        exit 0
 
13
    fi
 
14
    . /etc/default/isc-dhcp-server
 
15
 
 
16
    if [ -f /etc/ltsp/dhcpd6.conf ]; then
 
17
        CONFIG_FILE=/etc/ltsp/dhcpd6.conf
 
18
    else
 
19
        CONFIG_FILE=/etc/dhcp/dhcpd6.conf
 
20
    fi
 
21
    if [ ! -f $CONFIG_FILE ]; then
 
22
        echo "$CONFIG_FILE does not exist! - Aborting..."
 
23
        echo "Please create and configure $CONFIG_FILE to fix the problem."
 
24
        stop
 
25
        exit 0
 
26
    fi
 
27
 
 
28
    if ! /usr/sbin/dhcpd -t -q -6 -cf $CONFIG_FILE > /dev/null 2>&1; then
 
29
        echo "dhcpd self-test failed. Please fix the config file."
 
30
        echo "The error was: "
 
31
        /usr/sbin/dhcpd -t -6 -cf $CONFIG_FILE
 
32
        stop
 
33
        exit 0
 
34
    fi
 
35
end script
 
36
 
 
37
respawn
 
38
script
 
39
    if [ -f /etc/ltsp/dhcpd6.conf ]; then
 
40
        CONFIG_FILE=/etc/ltsp/dhcpd6.conf
 
41
    else
 
42
        CONFIG_FILE=/etc/dhcp/dhcpd6.conf
 
43
    fi
 
44
 
 
45
    . /etc/default/isc-dhcp-server
 
46
 
 
47
    # Allow dhcp server to write lease and pid file
 
48
    mkdir -p /var/run/dhcp-server
 
49
    chown dhcpd:dhcpd /var/run/dhcp-server
 
50
    [ -e /var/lib/dhcp/dhcpd6.leases ] || touch /var/lib/dhcp/dhcpd6.leases
 
51
    chown dhcpd:dhcpd /var/lib/dhcp /var/lib/dhcp/dhcpd6.leases
 
52
    if [ -e /var/lib/dhcp/dhcpd6.leases~ ]; then
 
53
        chown dhcpd:dhcpd /var/lib/dhcp/dhcpd6.leases~
 
54
    fi
 
55
 
 
56
    exec /usr/sbin/dhcpd -f -q -6 -cf $CONFIG_FILE $INTERFACES
 
57
end script