post_install() { echo -n ">>> Creating the aegir user as an alias of the http user... " [ $(getent passwd aegir &>/dev/null; echo $?) -eq 0 ] && { echo "User already exists; no action taken." } || { useradd --gid $(id --group http) --home-dir /usr/share/webapps/aegir --non-unique --uid $(id --user http) aegir # Replace /etc/passwd with itself having the Aegir user rearranged above the HTTP user. tempfile=$(mktemp) cat <(sed -n '1,/^http/p' /etc/passwd | head -n-1) <(getent passwd aegir) <(sed -n '/^http/,$p' /etc/passwd | head -n-1) >| $tempfile install -m644 $tempfile /etc/passwd echo "Done." } echo -n ">>> Testing that localhost resolves to an IP address assigned to a network interface... " [ $(ip addr | sed --quiet --regexp-extended 's/\s+inet6?\s([^\/]*).*/\1/p' | egrep '^(127.0.0.1|::1)$' | wc -l) -eq 0 ] && echo "Failed." || echo "Passed." echo -n ">>> Testing for successful outgoing mail by PHP... " [ -z "$(php -r 'print_r(mail("example@example.com", "Test email from PHP", "Test email body."));')" ] && echo "Failed." || echo "Passed." echo ">>> Initialise Aegir with the following steps:" echo " 1. Initialise the MariaDB data directory, e.g. with the mysql install db command, and start the MariaDB service:" echo " # mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql && systemctl start mysqld.service" echo " 2. Run mysql_secure_installation to:" echo " - set a root password;" echo " - remove anonymous users;" echo " - disallow remote root logins; and" echo " - remove the test database." echo " 3. Create a database user for Aegir with the 'GRANT OPTION' privilege:" echo " $ mysql --execute=\"GRANT ALL PRIVILEGES ON *.* TO 'aegir'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;\"" echo " 4. Install Aegir's frontend with the drush command, hostmaster-install, e.g.:" echo " # sudo -Hu aegir drush hostmaster-install --web_group=http --http_service_type=nginx \\" echo " --root=/usr/share/webapps/hostmaster \\" echo " --aegir_db_user=aegir --aegir_db_pass=password \\" echo " --client_email=aegir@$(hostname) \\" echo " --aegir_host=$(hostname) aegir.$(hostname)" echo " 5. Reconfigure Aegir's nginx configuration to use UNIX sockets instead of a network loopback port:" echo " # sed -i 's#127.0.0.1:9000#unix:/run/php-fpm/php-fpm.sock#' /usr/share/webapps/aegir/config/includes/nginx_vhost_common.conf" echo " 6. Start and start on boot the Aegir stack target:" echo " # systemctl enable --now aegir.target" echo " 7. Enable the hosting_queued module/hosting feature, unmask the queue daemon service unit, and restart the Aegir stack:" echo " # drush @hostmaster pm-enable hosting_queued" echo " # drush @hostmaster vset --exact --format=integer hosting_feature_queued 1" echo " # systemctl restart aegir.target" } pre_upgrade() { [ $(systemctl --system is-active aegir.target) = active ] && { touch /tmp/aegir.target-active systemctl --system stop --now aegir.target } true } post_upgrade() { [ -f /tmp/aegir.target-active ] && { rm /tmp/aegir.target-active systemctl --system stop --now aegir.target } true } pre_remove() { [ $(systemctl --system is-enabled aegir.target) = enabled ] && systemctl --system disable --now aegir.target [ $(systemctl --system is-active aegir.target) = enabled ] && systemctl --system stop --now aegir.target [ $(getent passwd aegir &>/dev/null; echo $?) -eq 0 ] && userdel aegir echo ">>> There are still files related to Aegir at: /usr/share/webapps/aegir." }