| 1 | #!/bin/sh |
| 2 | # postinst script |
| 3 | # |
| 4 | # see: dh_installdeb(1) |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | # summary of how this script can be called: |
| 9 | # * <postinst> `configure' <most-recently-configured-version> |
| 10 | # * <old-postinst> `abort-upgrade' <new version> |
| 11 | # * <conflictor's-postinst> `abort-remove' `in-favour' <package> |
| 12 | # <new-version> |
| 13 | # * <postinst> `abort-remove' |
| 14 | # * <deconfigured's-postinst> `abort-deconfigure' `in-favour' |
| 15 | # <failed-install-package> <version> `removing' |
| 16 | # <conflicting-package> <version> |
| 17 | # for details, see http://www.debian.org/doc/debian-policy/ or |
| 18 | # the debian-policy package |
| 19 | |
| 20 | # . /usr/share/apache2/apache2-maintscript-helper |
| 21 | |
| 22 | # dh_installdeb will replace this with shell code automatically |
| 23 | # generated by other debhelper scripts. |
| 24 | |
| 25 | #DEBHELPER# |
| 26 | |
| 27 | case "$1" in |
| 28 | configure) |
| 29 | if ! getent passwd _qemu-web-desktop >/dev/null 2>&1; then |
| 30 | adduser --system --home /var/lib/qemu-web-desktop --force-badname _qemu-web-desktop |
| 31 | fi |
| 32 | qwdctl download |
| 33 | chown -R _qemu-web-desktop /var/lib/qemu-web-desktop |
| 34 | # log file |
| 35 | touch /var/log/qemu-web-desktop.log |
| 36 | chown _qemu-web-desktop /var/log/qemu-web-desktop.log |
| 37 | chmod 640 /var/log/qemu-web-desktop.log |
| 38 | # cgi include mpm_itk proxy proxy_http proxy_wstunnel rewrite |
| 39 | # Enable modules only if not already enabled |
| 40 | for mod in cgi include proxy proxy_http proxy_wstunnel rewrite; do |
| 41 | if ! apache2ctl -M | grep -q "[[:space:]]${mod}_module"; then |
| 42 | apache2_invoke enmod $mod |
| 43 | fi |
| 44 | done |
| 45 | |
| 46 | # Switch MPM only if needed |
| 47 | if ! apache2ctl -M | grep -q "[[:space:]]mpm_itk"; then |
| 48 | apache2_switch_mpm itk |
| 49 | fi |
| 50 | |
| 51 | # Test config before restarting |
| 52 | if apache2ctl configtest; then |
| 53 | sleep 1 |
| 54 | apache2_reload restart |
| 55 | else |
| 56 | echo "Apache configuration test failed. Not restarting." |
| 57 | exit 1 |
| 58 | fi |
| 59 | ;; |
| 60 | |
| 61 | abort-upgrade|abort-remove|abort-deconfigure) |
| 62 | ;; |
| 63 | |
| 64 | *) |
| 65 | echo "postinst called with unknown argument \`$1'" >&2 |
| 66 | exit 1 |
| 67 | ;; |
| 68 | esac |
| 69 | |
| 70 | exit 0 |