#!/bin/sh
set -e
	update-alternatives --install /etc/resolv.conf resolv-conf /etc/resolv-conf.connman 100
if systemctl >/dev/null 2>/dev/null; then
	OPTS=""

	if [ -n "$D" ]; then
		OPTS="--root=$D"
	fi

	if [ "enable" = "enable" ]; then
		for service in connman.service; do
			systemctl ${OPTS} enable "$service"
		done
	fi

	if [ -z "$D" ]; then
		systemctl daemon-reload
		systemctl preset connman.service

		if [ "enable" = "enable" ]; then
			systemctl --no-block restart connman.service
		fi
	fi
fi
