summarylogtreecommitdiffstats
path: root/aegir.install
blob: 71ffeb978c0e420173c676ea51928d6644973360 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
57
58
59
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
    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
  }
}

post_upgrade() {
  [ -f /tmp/aegir.target-active ] && {
    rm /tmp/aegir.target-active
    systemctl --system stop --now aegir.target
  }
}

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
}