Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | set -e |
| 3 | |
| 4 | # create a user to run as (code stolen from dovecot-common) |
| 5 | if [ "$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 |
| 23 | fi |
| 24 | |
| 25 | if [ -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 |
| 41 | fi |
| 42 | |
| 43 | # dpkg can botch the change of /usr/share/doc/dnsmasq from |
| 44 | # directory to symlink. Fix up here. |
| 45 | if [ ! -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 |
| 48 | fi |
| 49 | |