custom-site-mahara-langpacks.postinst 2.92 KB
Newer Older
Richard Hector's avatar
Richard Hector committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/bin/sh
# postinst script for custom-site-mahara-langpacks

set -e

. /usr/share/debconf/confmodule

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

case "$1" in
    configure)
22 23 24 25 26 27 28 29
        adduser --system --quiet maharabot

        if [ ! -d /home/maharabot/.ssh ] ; then
            mkdir /home/maharabot/.ssh
            ssh-keygen -q -t rsa -N '' -f /home/maharabot/.ssh/id_rsa
            chown -R maharabot /home/maharabot/.ssh
        fi

Richard Hector's avatar
Richard Hector committed
30 31 32
        if [ ! -d /var/www/mahara-langpacks ]; then
            mkdir /var/www/mahara-langpacks
        fi
33 34 35 36 37

        if [ `stat -c %U /var/www/mahara-langpacks` != 'maharabot' ]; then
            chown -R maharabot /var/www/mahara-langpacks
        fi

Richard Hector's avatar
Richard Hector committed
38 39
        if [ ! -d /var/lib/mahara-langpacks ]; then
            mkdir /var/lib/mahara-langpacks
40 41
        else
            rm -rf /var/lib/mahara-langpacks/*
Richard Hector's avatar
Richard Hector committed
42
        fi
43 44 45 46 47

        if [ `stat -c %U /var/lib/mahara-langpacks` != 'maharabot' ]; then
            chown -R maharabot /var/lib/mahara-langpacks
        fi

48 49
        if [ ! -d /var/log/apache2/mahara-langpacks ]; then
            mkdir /var/log/apache2/mahara-langpacks
Richard Hector's avatar
Richard Hector committed
50 51
        fi

52 53 54 55 56
        if [ ! -d /var/log/mahara-langpacks ]; then
            mkdir /var/log/mahara-langpacks
            chown maharabot /var/log/mahara-langpacks
        fi

Richard Hector's avatar
Richard Hector committed
57 58 59
        echo "DATA=/var/lib/mahara-langpacks" > /etc/mahara-langpacks.conf
        echo "SCRIPTS=/usr/lib/mahara-langpacks" >> /etc/mahara-langpacks.conf
        echo "DOCROOT=/var/www/mahara-langpacks" >> /etc/mahara-langpacks.conf
60 61 62 63
        echo "PROJDIR='git@git.mahara.org:mahara/mahara.git'" >> /etc/mahara-langpacks.conf
        DOMAINNAME="langpacks.mahara.org"
        echo "WWWROOT='http://${DOMAINNAME}'" >> /etc/mahara-langpacks.conf

Richard Hector's avatar
Richard Hector committed
64 65 66
        NVH=`apache2ctl -S 2>&1 |grep "is a NameVirtualHost"|sed 's/ .*//'|head -1`
        cat <<EOF > /etc/apache2/sites-available/mahara-langpacks.conf
<VirtualHost ${NVH}>
67
  ServerName ${DOMAINNAME}
Richard Hector's avatar
Richard Hector committed
68
  DocumentRoot /var/www/mahara-langpacks
69 70
  CustomLog /var/log/apache2/custom-site-mahara-langpacks-access.log combined
  ErrorLog  /var/log/apache2/custom-site-mahara-langpacks-error.log
Richard Hector's avatar
Richard Hector committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
</VirtualHost>
EOF
        a2ensite mahara-langpacks.conf
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0