#!/bin/bash
set -e

if [ $# -ne 2 ]
then
	echo "usage: sysd2sysv <command> <deamon>"
	exit 1
fi

if [ ! -f /etc/init.d/$2 ]
then
	sed "s/%PROG%/$2/" /var/sysd2sysv/sysd2sysv.tpl > /etc/init.d/$2
	chmod 755 /etc/init.d/$2
fi

if [ $1 = "enable" ]
then
	update-rc.d $2 defaults 99
elif [ $1 = "disable" ]
then
	update-rc.d -f $2 remove
else
	/etc/init.d/$2 $1
fi


