jilo-web/packaging/deb-postinst

91 lines
2.8 KiB
Plaintext
Raw Normal View History

2024-07-09 10:51:03 +00:00
#!/bin/bash
# postinst script for jilo-web
#
# see: dh_installdeb(1)
set -e
case "$1" in
configure)
# loading debconf
. /usr/share/debconf/confmodule
# get the domain and web folder
db_get jilo-web/domain
if [ -z "$RET" ] ; then
db_get jilo-web/domain "localhost"
db_input critical jilo-web/domain || true
db_go
db_get jilo-web/domain
fi
DOMAIN=$(echo "$RET" | xargs echo -n)
# FIXME use this for subfolder install, if given
db_get jilo-web/folder
2024-07-15 16:37:53 +00:00
if [ -z "$RET" ] ; then
db_get jilo-web/folder "jilo-web"
db_input critical jilo-web/folder || true
db_go
db_get jilo-web/folder
fi
WEB_DIR=$(echo "$RET" | xargs echo -n)
2024-07-09 10:51:03 +00:00
INSTALL_DIR="/usr/share/jilo-web"
2024-07-11 11:24:45 +00:00
DOC_DIR="/usr/share/doc/jilo-web"
2024-07-09 10:51:03 +00:00
# store the info for later reconfiguration
db_set jilo-web/domain $DOMAIN
db_set jilo-web/folder $WEB_DIR
# we need a webserver, check for Apache and Nginx
WEB_SERVER=""
2024-07-10 10:58:44 +00:00
# install and enable apache vhost
2024-07-09 10:51:03 +00:00
if dpkg-query -W -f='${status}' apache2 2>/dev/null | grep -q "ok installed"; then
WEB_SERVER="apache2"
2024-07-11 11:24:45 +00:00
cp "${DOC_DIR}/config.apache" /etc/apache2/sites-available/jilo-web.conf
sed -i -e "s/\$DOMAIN/$DOMAIN/g" /etc/apache2/sites-available/jilo-web.conf
# there is '/' in INSTALL_DIR, we use '%'
sed -i -e "s%\$INSTALL_DIR%$INSTALL_DIR%g" /etc/apache2/sites-available/jilo-web.conf
2024-07-09 10:51:03 +00:00
a2ensite jilo-web.conf
/etc/init.d/apache2 reload
2024-07-10 10:58:44 +00:00
# install and enable nginx vhost
elif dpkg-query -W -f='${status}' nginx 2>/dev/null | grep -q "ok installed"; then
WEB_SERVER="nginx"
2024-07-11 11:24:45 +00:00
cp "${DOC_DIR}/config.nginx" /etc/nginx/sites-available/jilo-web
sed -i -e "s/\$DOMAIN/$DOMAIN/g" /etc/nginx/sites-available/jilo-web
# there is '/' in INSTALL_DIR, we use '%'
sed -i -e "s%\$INSTALL_DIR%$INSTALL_DIR%g" /etc/nginx/sites-available/jilo-web
2024-07-09 10:51:03 +00:00
ln -s /etc/nginx/sites-available/jilo-web /etc/nginx/sites-enabled/
/etc/init.d/nginx reload
2024-07-10 10:58:44 +00:00
else
echo "Nginx or Apache is needed, please install one of them first."
exit 1
2024-07-09 10:51:03 +00:00
fi
# permissions for web folder
chown -R www-data:www-data "$INSTALL_DIR"
chmod -R ug+rw "$INSTALL_DIR"
# stopping debconf
db_stop
;;
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