#!/bin/sh

if [ $# -lt 1 ]; then
  exit 1
fi

init_script=/etc/init.d/$1
rc_script=/etc/rc.d/rc.$1

if [ ! -L $init_script ] && [ ! -e $init_script ]; then
  echo "$init_script not found or broken"
  exit 1
fi

if [ ! -x $init_script ]; then
  chmod 0754 $init_script
fi

if [ -f $rc_script ]; then
  sh $rc_script $2
else
  sh $init_script $2
fi
