#!/bin/sh
set -e
	update-alternatives --install /usr/sbin/klogd klogd /usr/bin/busybox.nosuid 50
	update-alternatives --install /usr/sbin/syslogd syslogd /usr/bin/busybox.nosuid 50
if systemctl >/dev/null 2>/dev/null; then
	OPTS=""

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

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

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

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