summaryrefslogtreecommitdiff
path: root/debian/libpam0g.postinst
diff options
context:
space:
mode:
Diffstat (limited to 'debian/libpam0g.postinst')
-rw-r--r--debian/libpam0g.postinst56
1 files changed, 42 insertions, 14 deletions
diff --git a/debian/libpam0g.postinst b/debian/libpam0g.postinst
index 55928557..6279f684 100644
--- a/debian/libpam0g.postinst
+++ b/debian/libpam0g.postinst
@@ -52,7 +52,45 @@ filerc() {
echo ""
}
-installed_services() {
+if test -d /run/systemd/system; then
+ is_service_configured() {
+ systemctl is-enabled --quiet $1 || return 1
+ }
+ restart_service() {
+ if systemctl try-restart $1; then
+ :
+ else
+ failed="$failed $1"
+ fi
+ }
+else # not systemd
+ is_service_configured() {
+ service="$1"
+ idl="/etc/init.d/${service}"
+ if [ -n "$idl" ] && [ -x $idl ]; then
+ return 0
+ else
+ return 1
+ fi
+ }
+
+ restart_service() {
+ service="$1"
+ idl="invoke-rc.d ${service}"
+ echo -n " $service: stopping..." 2>&1
+ $idl stop > /dev/null 2>&1 || true
+ sleep 1
+ echo -n "starting..." 2>&1
+ if $idl start > /dev/null 2>&1; then
+ echo "done." 2>&1
+ else
+ echo "FAILED! ($?)" 2>&1
+ failed="$service $failed"
+ fi
+ }
+fi
+
+ installed_services() {
check="$@"
# Only get the ones that are installed, and configured
@@ -74,11 +112,10 @@ installed_services() {
)
for service in $check; do
- idl="/etc/init.d/${service}"
- if [ -n "$idl" ] && [ -x $idl ]; then
+ if is_service_configured $service; then
services="$service $services"
else
- echo "WARNING: init script for $service not found." >&2
+ echo "WARNING: $service not configured." >&2
fi
done
echo "$services"
@@ -152,16 +189,7 @@ then
continue
;;
esac
- echo -n " $service: stopping..."
- $idl stop > /dev/null 2>&1 || true
- sleep 1
- echo -n "starting..."
- if $idl start > /dev/null 2>&1; then
- echo "done."
- else
- echo "FAILED! ($?)"
- failed="$service $failed"
- fi
+ restart_service "$service"
done
echo
if [ -n "$failed" ]; then