File debian.php5-mapi.postinst of Package kopano

#! /bin/sh

set -e

if [ -d /etc/php/7.0 ]; then 
	BASE="/etc/php/7.0"
else
	BASE="/etc/php5"
fi

DIST="/usr/share/kopano/php/mapi/mapi.ini"

if [ -x /usr/sbin/phpenmod -o -x /usr/sbin/php5enmod ]; then
	# modern approach, used by distros with PHP >= 5.4
	echo "php5-mapi: using mods-available directory"
	mkdir -p "$BASE/mods-available" # just in case
	cp "$DIST" "$BASE/mods-available/kopano.ini"
	if [ -x /usr/sbin/phpenmod ]; then
		phpenmod kopano
	else
		php5enmod kopano
	fi
else
	# for older distros, such as Ubuntu 12.04
	echo "php5-mapi: not using mods-available directory"
	mkdir -p "$BASE/apache2/conf.d" # just in case
	cp "$DIST" "$BASE/apache2/conf.d/kopano.ini"
	mkdir -p "$BASE/conf.d" # just in case
	cp "$DIST" "$BASE/conf.d/kopano.ini"
fi

if /usr/sbin/service apache2 status >/dev/null 2>/dev/null; then
	/usr/sbin/service apache2 restart
fi
/bin/echo -e "\n\nIf you use a PHP executor other than Apache (like FPM), you may need to manually restart it.\n\n"
openSUSE Build Service is sponsored by