# some library functions for phpbb3 maintainer scripts # copyright 2010 J.M. Roth get_webserver_configdata () { local package=$1 local webserver=$2 local prio=$3 case "$webserver" in "lighttpd" ) confdir=conf-available wfile=${prio}-$package.conf ;; "apache2" ) confdir=conf-available wfile=$package.conf ;; * ) echo "$0 $@: webserver $webserver is not supported." 1>&2 return 1 ;; esac } # picked up from https://wiki.debian.org/Apache/PackagingFor24#Making_web_applications_compatible_to_both.2C_Apache_2.2_and_2.4 COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true) APACHE2_MAINTSCRIPT_METHOD=$1 APACHE2_MAINTSCRIPT_ARGUMENT=$2 install_webserver_config () { local package=$1 local webserver=$2 local prio=$3 get_webserver_configdata $@ || return 1 # yields: $confdir, $wfile if [ -d /etc/$webserver/$confdir ] && [ ! -L /etc/$webserver/$confdir/$wfile ] ; then if [ ! -x /usr/sbin/$webserver ] ; then echo "$0 $@: webserver $webserver not found, skipping" 1>&2 else ln -s ../../$package/$webserver.conf /etc/$webserver/$confdir/$wfile if [ "$webserver" = "lighttpd" ] ; then lighty-enable-mod $package >/dev/null elif [ "$webserver" = "apache2" ] ; then if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then . /usr/share/apache2/apache2-maintscript-helper apache2_invoke enconf $package elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then [ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/$package.conf ] && ln -s ../conf-available/$package.conf /etc/apache2/conf.d/$package.conf fi fi fi fi } _purge_webserver_config () { local package=$1 local webserver=$2 local prio=$3 get_webserver_configdata $@ || return 0 # yields: $confdir, $wfile if [ -d /etc/$webserver/$confdir ] && [ -L /etc/$webserver/$confdir/$wfile ] ; then if [ ! -x /usr/sbin/$webserver ] ; then echo "$0 $@: webserver $webserver not installed, skipping" 1>&2 else if [ "$webserver" = "lighttpd" ] ; then lighty-disable-mod $package >/dev/null elif [ "$webserver" = "apache2" ] ; then if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then . /usr/share/apache2/apache2-maintscript-helper apache2_invoke disconf $package elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then [ -L /etc/apache2/conf.d/$package.conf ] && rm /etc/apache2/conf.d/$package.conf fi fi rm /etc/$webserver/$confdir/$wfile fi fi } purge_webserver_config () { local package=$1 local webserver=$2 local prio=$3 case "$webserver" in "all" ) db_metaget $package/httpd Choices for w in $RET ; do _purge_webserver_config $package ${w%,} $prio done ;; * ) _purge_webserver_config $@ ;; esac } _reload_webserver () { local webserver=$1 if [ -x /usr/sbin/$webserver ]; then # Redirection of fd 3 is needed because Debconf uses it and it might # be inherited by webserver. See bug #446324. if [ -x /usr/sbin/invoke-rc.d ]; then invoke-rc.d $webserver reload 3>/dev/null || true else /etc/init.d/$webserver reload 3>/dev/null || true fi echo fi } reload_webserver () { local package=$1 local webserver=$2 case "$webserver" in "all" ) db_metaget $package/httpd Choices for w in $RET ; do _reload_webserver ${w%,} done ;; * ) _reload_webserver ${webserver%,} ;; esac }