aegir-provision.postinst 2.75 KB
Newer Older
anarcat's avatar
anarcat committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
# postinst script for provision
#
# see: dh_installdeb(1)

set -e

# 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

anarcat's avatar
anarcat committed
20
VARLIB="/var/aegir"
anarcat's avatar
anarcat committed
21
22
23
24
25
26
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

case "$1" in
    configure)
        # add a aegir user if one does not already exist
        if ! getent passwd aegir >/dev/null ; then
            echo "adding aegir user..."
            adduser --quiet --system --no-create-home --group \
                --home "$VARLIB" \
                --shell '/bin/bash' \
                --gecos 'Aegir user,,,' \
                aegir
        fi
        adduser --quiet aegir www-data

        TEMPFILE=`tempfile`
        sedscript=""
        for binary in /usr/sbin/apachectl /usr/sbin/apache2ctl ; do
            if [ -x $binary ] ; then
                sedscript=$sedscript';s#^\#\?\(.*'$binary'.*\)$#\1#'
            else
                sedscript=$sedscript';s#^\#\?\(.*'$binary'.*\)$#\#\1#'
            fi
        done
        if ! [ -z "$sedscript" ]; then
            sed -e "$sedscript" /usr/share/doc/aegir-provision/examples/example.sudoers >> $TEMPFILE
        else
            # this should happend, but still handle gracefully
            cp /usr/share/doc/aegir-provision/examples/examples.sudoers $TEMPFILE
        fi
        
        ucf $TEMPFILE /etc/sudoers.d/aegir
        rm -f $TEMPFILE
        ucfr aegir-provision /etc/sudoers.d/aegir

        # fix permissions on installed directories
        chown aegir:aegir "$VARLIB"
anarcat's avatar
anarcat committed
57
        for dir in /var/aegir ; do
anarcat's avatar
anarcat committed
58
59
60
61
            chown aegir:aegir $dir
            chmod 0700 $dir
        done

anarcat's avatar
anarcat committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
        db_get "aegir/site"
        if [ ! -z "$RET" ]; then
            SITE="$RET"
        fi
        db_get "aegir/db_host"
        AEGIR_DB_HOST="$RET"
        db_get "aegir/email"
        EMAIL="$RET"
        db_get "aegir/makefile"
        if [ ! -z "$RET" ]; then
            MAKEFILE="--makefile='$RET'"
        fi
        db_stop

        su aegir -c "drush hostmaster-install --aegir_db_host='$AEGIR_DB_HOST' --client_email='$EMAIL' $MAKEFILE $SITE"
anarcat's avatar
anarcat committed
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
    ;;

    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