nextcloud-deb/debian/nextcloud-server.postinst

76 lines
2.4 KiB
Bash

#!/bin/sh
# postinst script for nextcloud-server
#
# 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 https://www.debian.org/doc/debian-policy/ or
# the debian-policy package
export APACHE2_MAINTSCRIPT_HELPER_QUIET=1
case "$1" in
configure)
# Apache conf
if [ "a2query -c nextcloud"=~"No conf matches nextcloud" ]; then
a2enconf nextcloud || true
apache2ctl restart || true
fi
# Apache modules
if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then
. /usr/share/apache2/apache2-maintscript-helper
apache2_invoke enmod rewrite || exit $?
apache2_invoke enmod headers || exit $?
apache2_invoke enmod env || exit $?
apache2_invoke enmod dir || exit $?
apache2_invoke enmod mime || exit $?
fi
# Permissions and owners
chown -R www-data:www-data /var/www/nextcloud
chmod 0644 /var/www/nextcloud/.htaccess
chmod +x /var/www/nextcloud/occ
chmod +x /usr/sbin/occ
# Check status
if [ "$(/usr/sbin/occ status | grep 'installed:' | cut -f2 -d ':' | xargs)" = "false" ]; then
echo "Nextcloud is not configured, please use open web browser http://<your_server_ip>/nextcloud"
echo "After configure please run occ config:system:set --value true upgrade.disable-web'"
elif [ "$(/usr/sbin/occ status | grep 'installed:' | cut -f2 -d ':' | xargs)" = "true" ]; then
/usr/sbin/occ maintenance:update:htaccess
/usr/sbin/occ upgrade
/usr/sbin/occ db:add-missing-indices
/usr/sbin/occ config:system:set --value true upgrade.disable-web >/dev/null || true
else
echo "Got unexpect answer, occ status can't to read satus of nextcloud. Check php installation."
fi
;;
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