Index: trunk/init/samhain.startFreeBSD.in
===================================================================
--- trunk/init/samhain.startFreeBSD.in	(revision 591)
+++ trunk/init/samhain.startFreeBSD.in	(revision 1)
@@ -1,44 +1,95 @@
-#!/bin/sh
+#! /bin/sh -
+#
+#    initialization/shutdown script for @install_name@ package
 
-# PROVIDE: @install_name@
-# REQUIRE: LOGIN
-# KEYWORD: shutdown
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
 
-. /etc/rc.subr
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=@sbindir@/@install_name@
+NAME=@install_name@
+pidfile=@mylockfile@
 
-name="@install_name@"
-rcvar=`set_rcvar`
+test -f $DAEMON || exit 0
 
-pidfile="@mylockfile@"
-
-# there are no required_files in general,
-# as they might be downloaded from the server
-#
-# required_files="@myconffile@ @mydatafile@"
-
-extra_commands="reload"
-stop_postcmd="remove_stale_files"
-
-command="@sbindir@/@install_name@"
-
-is_set()
-{
-    eval "[ -n \"\${$1+X}\" ]"
+safe_pidof () {
+    pidval=0
+    if [ -f $pidfile ] ; then
+       pidval=`cat $pidfile | awk '{ print $1 }'`
+       echo "${pidval}" | grep ['[^0123456789]'] >/dev/null 2>&1 && pidval=0
+    fi
+    echo $pidval
+    if [ x"$pidval" = x0 ] ; then
+	return 1
+    else
+	return 0
+    fi
 }
 
-remove_stale_files()
-{
-    if test -f @mylockfile@; then
-	/bin/rm -f @mylockfile@
-    fi
-    /bin/rm -f @mylockdir@/${name}.sock
+log_stat_msg () {
+case "$1" in
+	0)
+	echo "Service $NAME: Running";
+	break;
+	;;
+	1)
+	echo "Service $NAME: Stopped and @mylockfile@ pid file exists";
+	break;
+	;;
+	3)
+	echo "Service $NAME: Stopped";
+	break;
+	;;
+	*)
+	echo "Service $NAME: Status unknown";
+	break;
+	;;
+esac
 }
 
-load_rc_config "$name"
+case "$1" in
+  start)
+	#
+	# Remove a stale lockfile, if found
+	#
+	if test -f @mylockfile@; then
+	    rm -f @mylockfile@
+	fi
+        /bin/rm -f @mylockdir@/${NAME}.sock
+        $DAEMON -D && echo -n " $NAME"
+        ;;
+  stop)
+        PID=`safe_pidof`
+	if test "x$PID" != x0
+	then
+		kill $PID && echo -n " $NAME"
+        fi
+        ;;
+  reload|force-reload)
+        PID=`safe_pidof`
+        if test "x$PID" != x0
+        then
+		echo " Reloading $NAME configuration file."
+                kill -s HUP $PID && echo -n " $NAME"
+	else
+		echo " Cannot determine PID of process $NAME."
+		exit 1
+        fi
+        ;;
+  restart)
+	$0 stop
+        sleep 3
+        $0 start
+        ;;
+    status)
+        $DAEMON  status
+	ERRNUM=$?
+	log_stat_msg ${ERRNUM}
+	exit ${ERRNUM}
+        ;;
+  *)
+        echo " Usage: $0 {start|stop|restart|reload|force-reload}" >&2
+        exit 1
+        ;;
+esac
 
-if ! is_set ${rcvar}; then 
-    eval "${rcvar}=YES"
-fi
-
-run_rc_command "$1"
-
Index: trunk/init/samhain.startGentoo.in
===================================================================
--- trunk/init/samhain.startGentoo.in	(revision 591)
+++ trunk/init/samhain.startGentoo.in	(revision 1)
@@ -11,4 +11,5 @@
 	/sbin/start-stop-daemon --start --quiet  --exec @sbindir@/@install_name@
 	eend $?
+	@sh_insmod_cmd@
 }
 
Index: trunk/init/samhain.startLSB.in
===================================================================
--- trunk/init/samhain.startLSB.in	(revision 591)
+++ trunk/init/samhain.startLSB.in	(revision 1)
@@ -3,6 +3,6 @@
 ### BEGIN INIT INFO
 # Provides: @install_name@
-# Required-Start: $syslog $network $remote_fs
-# Required-Stop: $syslog $network $remote_fs
+# Required-Start: $syslog $network
+# Required-Stop: $syslog $network
 # Default-Start: 2 3 4 5
 # Default-Stop: 0 1 6
Index: trunk/init/samhain.startLinux.in
===================================================================
--- trunk/init/samhain.startLinux.in	(revision 591)
+++ trunk/init/samhain.startLinux.in	(revision 1)
@@ -1,4 +1,3 @@
 #!/bin/bash
-
 # chkconfig: 2345 99 10
 # description: File Integrity Checking Daemon
@@ -10,14 +9,4 @@
 #
 
-### BEGIN INIT INFO
-# Provides: @install_name@
-# Required-Start: $syslog $network $remote_fs
-# Required-Stop: $syslog $network $remote_fs
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Keep an eye on stuff
-# Description: Keep an eye on stuff
-### END INIT INFO
-
 # For Debian
 #
@@ -40,13 +29,6 @@
 # and the command to run them.
 if [ -f /etc/redhat-release ]; then
-    if [ -f /etc/init.d/functions ]; then
 	. /etc/init.d/functions
 	DISTRO=redhat
-    elif [ -f /etc/rc.d/init.d/functions ]; then
-	. /etc/rc.d/init.d/functions
-	DISTRO=redhat
-    else
-	DISTRO=generic
-    fi
 elif [ -f /etc/mandrake-release ]; then
 	. /etc/init.d/functions
@@ -81,5 +63,5 @@
 fi
 
-debian_end()
+function debian_end ()
 {
 	if [ $RETVAL -eq 0 ];
@@ -121,5 +103,5 @@
 
 # echo OK in green if is success, FAILED in red is failed
-generic_end()
+function generic_end ()
 {
 	if [ $RETVAL -eq 0 ];
@@ -161,18 +143,11 @@
 	debian)
 		echo -n "Starting ${NAME}"
-		( /sbin/start-stop-daemon --start --oknodo --quiet --exec $DAEMON )
+		( /sbin/start-stop-daemon --start --quiet --exec $DAEMON )
 		RETVAL=$?
 		debian_end
 		;;
 	redhat)
-		if [ -f /etc/sysconfig/${NAME} ]; then
-                       . /etc/sysconfig/${NAME}
-                fi
 		echo -n $"Starting ${NAME}: "
-                if [ -n "$OPTIONS" ]; then
-                        daemon $DAEMON $OPTIONS
-                else
-                        daemon $DAEMON
-                fi
+		daemon $DAEMON
 		RETVAL=$?
 		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/${NAME}
@@ -197,4 +172,10 @@
 		;;
 	esac
+	#
+	# The hiding kernel module
+	#
+	if [ $RETVAL -eq 0 ]; then
+		@sh_insmod_cmd@
+	fi
 	exit $RETVAL
 	;;
@@ -204,5 +185,5 @@
 	debian)
 		echo -n "Stopping $NAME"
-        	( /sbin/start-stop-daemon --stop --oknodo --quiet --exec $DAEMON )
+        	( /sbin/start-stop-daemon --stop --quiet --exec $DAEMON )
 		RETVAL=$? 
 		debian_end
Index: trunk/init/samhain.startMACOSX.in
===================================================================
--- trunk/init/samhain.startMACOSX.in	(revision 591)
+++ 	(revision )
@@ -1,27 +1,0 @@
-#!/bin/sh
-
-. /etc/rc.common
-
-StartService() {
-
-	ConsoleMessage "Starting service @install_name@."
-	@sbindir@/@install_name@ start
-
-}
-
-StopService() {
-
-	ConsoleMessage "Stopping service @install_name@."
-	@sbindir@/@install_name@ stop
-
-}
-
-RestartService() {
-
-	ConsoleMessage "Restarting service @install_name@."
-	@sbindir@/@install_name@ restart
-
-}
-
-
-RunService "$1"
Index: trunk/init/samhain.startSolaris.in
===================================================================
--- trunk/init/samhain.startSolaris.in	(revision 591)
+++ trunk/init/samhain.startSolaris.in	(revision 1)
@@ -9,5 +9,5 @@
 
 
-log_stat_msg() {
+log_stat_msg () {
 case "$1" in
 	0)
Index: trunk/init/samhain.startSystemd.in
===================================================================
--- trunk/init/samhain.startSystemd.in	(revision 591)
+++ 	(revision )
@@ -1,16 +1,0 @@
-
-[Unit]
-Description=The @install_name@ Service
-After=network.target remote-fs.target nss-user-lookup.target
-
-[Service]
-Type=forking
-PIDFile=@mylockfile@
-ExecStart=@sbindir@/@install_name@ start
-ExecStop=@sbindir@/@install_name@ stop
-ExecReload=@sbindir@/@install_name@ reload
-Restart=on-abort
-TimeoutStartSec=infinity
-
-[Install]
-WantedBy=multi-user.target
