alternc.preinst 2.96 KB
Newer Older
1
#!/bin/bash -x
2 3 4 5 6

set -e

. /usr/share/debconf/confmodule

Alan Garcia's avatar
Alan Garcia committed
7
# Create AlternC Panel user for web server
8
if ! getent group alterncpanel; then
9 10
	addgroup --system --gid 1999 alterncpanel
fi
11
if ! getent passwd alterncpanel; then
Alan Garcia's avatar
Alan Garcia committed
12
adduser --system --home "/etc/alternc/.alterncpanel" \
Alan Garcia's avatar
Alan Garcia committed
13
  --disabled-password --uid 1999 --ingroup alterncpanel alterncpanel
14
fi
15 16 17 18 19
case "$1" in
  install)
    ;;

  upgrade)
Alan Garcia's avatar
Alan Garcia committed
20
    # Set correct rights on files
21 22 23 24
#    echo "/!\ Warning /!\ Defaults ACL will be applied"
#    echo "If error, please remount $ALTERNC_LOC with ACL"
#    echo "and re-run /usr/lib/alternc/fixperms.sh "
#    /usr/lib/alternc/fixperms.sh
Alan Garcia's avatar
Alan Garcia committed
25

26
    if dpkg --compare-versions "$2" lt "0.9.4"; then
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
        echo "Upgrading bind configuration"
        # Move /etc/bind files around
        mkdir -p /var/alternc/bind
        if [ ! -e /var/alternc/bind/automatic.conf -a \
             -f /etc/bind/automatic.conf ]; then
            if [ ! -e /var/alternc/bind/zones ]; then
                mkdir -p /var/alternc/bind/zones
            fi
            for zone in `sed -n -e 's,.*/etc/bind/master/\(.*\)".*,\1,p' \
                             /etc/bind/automatic.conf`; do
                if [ -f /etc/bind/master/$zone ]; then
                    mv /etc/bind/master/$zone /var/alternc/bind/zones
                fi
            done
            cp -a -f /etc/bind/automatic.conf /var/alternc/bind/automatic.conf
            sed -e 's,/etc/bind/master,/var/alternc/bind/zones,g' \
                < /etc/bind/automatic.conf > /var/alternc/bind/automatic.conf
            rm /etc/bind/automatic.conf
        fi
        if [ ! -e /var/alternc/bind/slaveip.conf -a \
             -f /etc/bind/slaveip.conf ]; then
            mv /etc/bind/slaveip.conf /var/alternc/bind/slaveip.conf
        fi
        if [ ! -e /etc/bind/templates ]; then
            mkdir -p /etc/bind/templates
        fi
        if [ ! -e /etc/bind/templates/named.template -a \
             -f /etc/bind/domaines.template ]; then
            mv /etc/bind/domaines.template /etc/bind/templates/named.template
        fi
        if [ ! -e /etc/bind/templates/zone.template -a \
             -f /etc/bind/master/domaines.template ]; then
            mv /etc/bind/master/domaines.template \
               /etc/bind/templates/zone.template
        fi
        if [ -f /etc/bind/master/mx.template ]; then
            rm /etc/bind/master/mx.template
        fi
        if [ -f /etc/bind/master/slave.template ]; then
            rm /etc/bind/master/slave.template
        fi
        rmdir /etc/bind/master 2> /dev/null ||
            echo "/etc/bind/master was not empty. Please remove it manually."
    fi

72
    if [ ! -e /etc/alternc/menulist.txt ]; then
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
        if [ -f /var/alternc/bureau/admin/menulist.txt ]; then
            mv -f /var/alternc/bureau/admin/menulist.txt \
                  /etc/alternc/menulist.txt
        fi
    fi

    ;;

  abort-upgrade)
    ;;

  *)
    echo "preinst called with unknown argument '$1'" >&2
    exit 1
    ;;

esac

#DEBHELPER#

# vim: et sw=4