blob: 156bb3433e26320b9035c1ffe931190f83066ea4 [file] [log] [blame]
Simon Kelleyc72daea2012-01-05 21:33:27 +00001#!/bin/sh
2set -e
3
4# create a user to run as (code stolen from dovecot-common)
5if [ "$1" = "configure" ]; then
6 if [ -z "`id -u dnsmasq 2> /dev/null`" ]; then
7 adduser --system --home /var/lib/misc --gecos "dnsmasq" \
8 --no-create-home --disabled-password \
9 --quiet dnsmasq || true
10 fi
11
12 # Make the directory where we keep the pid file - this
13 # has to be owned by "dnsmasq" do that the file can be unlinked.
14 if [ ! -d /var/run/dnsmasq ]; then
15 mkdir /var/run/dnsmasq
16 chown dnsmasq:nogroup /var/run/dnsmasq
17 fi
18
19 # handle new location of pidfile during an upgrade
20 if [ -e /var/run/dnsmasq.pid ]; then
21 mv /var/run/dnsmasq.pid /var/run/dnsmasq
22 fi
23fi
24
25if [ -x /etc/init.d/dnsmasq ]; then
26 update-rc.d dnsmasq defaults 15 85 >/dev/null
27
28 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
29 if [ -e /var/run/dnsmasq/dnsmasq.pid ]; then
30 ACTION=restart
31 else
32 ACTION=start
33 fi
34
35 if [ -x /usr/sbin/invoke-rc.d ] ; then
36 invoke-rc.d dnsmasq $ACTION || true
37 else
38 /etc/init.d/dnsmasq $ACTION || true
39 fi
40 fi
41fi
42
43# dpkg can botch the change of /usr/share/doc/dnsmasq from
44# directory to symlink. Fix up here.
45if [ ! -h /usr/share/doc/dnsmasq ] && { rmdir /usr/share/doc/dnsmasq; }; then
46 cd /usr/share/doc/
47 ln -s /usr/share/doc/dnsmasq-base dnsmasq
48fi
49