Skip to content
aegir3-hostmaster.config 2.27 KiB
Newer Older
#! /bin/sh

set -e

# Source debconf library.
. /usr/share/debconf/confmodule

if [ "$DPKG_DEBUG" = "developer" ]; then
anarcat's avatar
anarcat committed
if su -s /bin/sh aegir -c 'drush @hostmaster status' 2>&1 | grep -q 'Drupal bootstrap.*Successful'; then
    # there's already an install, do not go around asking silly questions
    db_fget aegir/makefile "seen" || true
    if [ "$RET" = "false" ]; then
        # ... except if that makefile question was never asked, in
        # which case we're probably upgrading from a custom install,
        # so we need to ask for the custom install makefile
        db_fset aegir/makefile "seen" "false" || true
        db_input medium aegir/makefile || true
        db_go
    fi
db_input medium aegir/email ||true
db_input high aegir/site || true
db_get aegir/email
if [ -z "$RET" ]; then
   db_set aegir/email "aegir@`hostname -f`"
fi
db_get aegir/site
if [ -z "$RET" ]; then
    db_set aegir/site `hostname -f`
fi
db_input low aegir/makefile || true
db_input low aegir/working-copy || true
db_input low aegir/db_host || true
db_input low aegir/db_user || true
# if we got here, it means aegir is not installed and we forgot the
# root password, ask for it again
db_fset aegir/db_password "seen" "false" || true
db_input high aegir/db_password || true

# (taken from the webapps-common httpd functions)
# wc_httpd_installed: test for installed httpds
# usage:
#       wc_httpd_installed [ httpd1 httpd2 ... ]
#
# no arguments implies to test for all servers
wc_httpd_installed(){
        local httpds
        if [ "$*" ]; then
                httpds=$*
        else
                httpds=$wc_httpd_supported
        fi
        for f in $httpds; do
                if test -x /usr/sbin/$f; then
                        echo $f
                fi
        done
}

# list of installed servers to check for
default_servers=`wc_httpd_installed apache2 nginx`
# convert list to comma seperated list
server_list=`echo $default_servers | sed -e 's/[[:space:]][[:space:]]*/, /g'`

# if they haven't already been prompted, preseed the server selection
db_fget aegir/webserver seen
if [ "$RET" = "false" ]; then
        db_set aegir/webserver $server_list
fi
db_input low aegir/webserver || true

# alright, ask the questions that need to be asked