#!/bin/sh
set -e
	update-alternatives --install /usr/bin/scp scp /usr/sbin/dropbearmulti 20
	update-alternatives --install /usr/bin/ssh ssh /usr/sbin/dropbearmulti 20
if systemctl >/dev/null 2>/dev/null; then
	OPTS=""

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

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

	if [ -z "$D" ]; then
		systemctl daemon-reload
		systemctl preset dropbear.socket

		if [ "enable" = "enable" ]; then
			systemctl --no-block restart dropbear.socket
		fi
	fi
fi
