Skip to content
aegir3-provision.postinst 2.62 KiB
Newer Older
#!/bin/sh
anarcat's avatar
anarcat committed
# 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
# Source debconf library.
. /usr/share/debconf/confmodule

if [ "$DPKG_DEBUG" = "developer" ]; then
anarcat's avatar
anarcat committed
VARLIB="/var/aegir"
anarcat's avatar
anarcat committed

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

anarcat's avatar
anarcat committed
        if [ -d /etc/sudoers.d ]; then
            ucf --debconf-ok /usr/share/doc/aegir3-provision/examples/example.sudoers /etc/sudoers.d/aegir
anarcat's avatar
anarcat committed
            ucfr aegir-provision /etc/sudoers.d/aegir
            chmod 440 /etc/sudoers.d/aegir
        else
            echo "running an older version of sudo"
            echo "copy content of /usr/share/doc/aegir3-provision/examples/example.sudoers into /etc/sudoers for aegir to run properly"
anarcat's avatar
anarcat committed
        fi
        # fix permissions on installed directories
        chown aegir:aegir "$VARLIB"

        # Install composer.
        curl -sS https://getcomposer.org/installer | php
        mv composer.phar /usr/local/bin/composer

        # Install Drush.
        su -c "composer global require drush/drush:6.*" aegir

        # Add composer's bin dir to the $PATH.
        echo "export PATH=\"\$HOME/.composer/vendor/bin:\$PATH\"" >>  ~aegir/.bashrc

        # Rename an old drush executable.
        if [ -f /usr/local/bin/drush ]; then
          mv /usr/local/bin/drush /usr/local/bin/drush-old-$(date +'%Y-%m-%d')
        fi

        # Symlink Drush for other users to use.
        ln -s ~aegir/.composer/vendor/bin/drush /usr/local/bin
anarcat's avatar
anarcat committed
    ;;

    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