From 2468037903a599873c516ab5d49df8e92b2f9b9d Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Wed, 8 May 2013 22:48:23 +0200
Subject: [PATCH] WIP

---
 etc/rc                |  12 +++++-
 etc/rc.d/Makefile     |   2 +-
 etc/rc.d/localdaemons | 114 --------------------------------------------------
 etc/rc.d/netoptions   |   3 +-
 etc/rc.shutdown       |  11 ++++-
 5 files changed, 22 insertions(+), 120 deletions(-)
 delete mode 100644 etc/rc.d/localdaemons

diff --git a/etc/rc b/etc/rc
index e2f30d0..9323b86 100644
--- a/etc/rc
+++ b/etc/rc
@@ -26,7 +26,6 @@
 #
 #	@(#)rc	5.27 (Berkeley) 6/5/91
 # $FreeBSD: src/etc/rc,v 1.329 2003/05/02 05:27:33 dougb Exp $
-# $DragonFly: src/etc/rc,v 1.4 2005/11/19 18:34:02 joerg Exp $
 #
 
 # System startup script run by init on autoboot or after single-user.
@@ -50,6 +49,14 @@ export HOME PATH
 
 . /etc/rc.subr
 
+if [ -r /etc/defaults/rc.conf ]; then
+	. /etc/defaults/rc.conf
+fi
+
+if [ -r /etc/rc.conf ]; then
+	. /etc/rc.conf
+fi
+
 # Note: the system configuration files are loaded as part of
 # the RCNG system (rc.d/rcconf).  Do not load them here as it may
 # interfere with diskless booting.
@@ -63,7 +70,8 @@ else
 	_boot="start"
 fi
 
-files=`rcorder -s nostart /etc/rc.d/* 2>/dev/null`
+files=`rcorder -s nostart /etc/rc.d/* \
+	$(echo ${local_startup} | sed 's#rc.d#rc.d/*#g') 2>/dev/null`
 
 for _rc_elem in ${files}; do
 	run_rc_script ${_rc_elem} ${_boot}
diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile
index 1949d87..722c99e 100644
--- a/etc/rc.d/Makefile
+++ b/etc/rc.d/Makefile
@@ -12,7 +12,7 @@ FILES=	DAEMON LOGIN NETWORKING SERVERS abi accounting addswap adjkerntz \
 	fixbootfile fsck ftpd hostapd hostname hotplugd \
 	inetd initdiskless initrandom ip6fw ipfw ipsec \
 	jail keyserv \
-	ldconfig local localdaemons lockd lpd lvm \
+	ldconfig local lockd lpd lvm \
 	mixer motd mountcritlocal mountcritremote \
 	mountd moused mroute6d mrouted msgs \
 	named netif netoptions newsyslog \
diff --git a/etc/rc.d/localdaemons b/etc/rc.d/localdaemons
deleted file mode 100644
index b19d98f..0000000
--- a/etc/rc.d/localdaemons
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD: src/etc/rc.d/localdaemons,v 1.2 2003/05/05 15:38:41 mtm Exp $
-# $DragonFly: src/etc/rc.d/localdaemons,v 1.5 2005/12/30 21:01:49 dillon Exp $
-#
-
-# PROVIDE: localdaemons
-# REQUIRE: abi
-# BEFORE:  securelevel
-# KEYWORD: shutdown
-
-. /etc/rc.subr
-
-name="localdaemons"
-start_cmd="locald_start"
-stop_cmd="locald_stop"
-
-# Returns true (0) if the passed argument is a valid name
-# for a script, false (1) otherwise.
-#
-valid_scriptname()
-{
-	case ${1##*.} in
-	orig)
-		return 1
-		;;
-	sample)
-		return 1
-		;;
-	dist)
-		return 1
-		;;
-	esac
-	return 0
-}
-
-locald_start()
-{
-	# For each dir in $local_startup, search for init scripts matching *
-	#
-	case ${local_startup} in
-	[Nn][Oo] | '')
-		;;
-	*)
-		echo -n 'Local package initialization:'
-		slist=""
-		if [ -z "${script_name_sep}" ]; then
-			script_name_sep=" "
-		fi
-		for dir in ${local_startup}; do
-			if [ -d "${dir}" ]; then
-				for script in ${dir}/*; do
-					if valid_scriptname ${script}; then
-						slist="${slist}${script_name_sep}${script}"
-					fi
-				done
-			fi
-		done
-		script_save_sep="$IFS"
-		IFS="${script_name_sep}"
-		for script in ${slist}; do
-			if [ -x "${script}" ]; then
-				(set -T
-				trap 'exit 1' 2
-				${script} start)
-			elif [ -f "${script}" -o -L "${script}" ]; then
-				echo -n " (skipping ${script##*/}, not executable)"
-			fi
-		done
-		IFS="${script_save_sep}"
-		echo '.'
-		;;
-	esac
-}
-
-locald_stop()
-{
-	echo -n 'Shutting down daemon processes:'
-
-	# For each dir in $local_startup, search for init scripts matching *
-	case ${local_startup} in
-	[Nn][Oo] | '')
-		;;
-	*)
-		slist=""
-		if [ -z "${script_name_sep}" ]; then
-			script_name_sep=" "
-		fi
-		for dir in ${local_startup}; do
-			if [ -d "${dir}" ]; then
-				for script in ${dir}/*; do
-					if valid_scriptname ${script}; then
-						slist="${slist}${script_name_sep}${script}"
-					fi
-				done
-			fi
-		done
-		script_save_sep="$IFS"
-		IFS="${script_name_sep}"
-		for script in `reverse_list ${slist}`; do
-			if [ -x "${script}" ]; then
-				(set -T
-				trap 'exit 1' 2
-				${script} stop)
-			fi
-		done
-		IFS="${script_save_sep}"
-		echo '.'
-		;;
-	esac
-}
-
-load_rc_config $name
-run_rc_command "$1"
diff --git a/etc/rc.d/netoptions b/etc/rc.d/netoptions
index 1cd4e64..b44b4d8 100644
--- a/etc/rc.d/netoptions
+++ b/etc/rc.d/netoptions
@@ -1,11 +1,10 @@
 #!/bin/sh
 #
 # $FreeBSD: src/etc/rc.d/netoptions,v 1.138 2003/06/29 05:09:48 mtm Exp $
-# $DragonFly: src/etc/rc.d/netoptions,v 1.4 2005/11/19 21:47:32 swildner Exp $
 #
 
 # PROVIDE: netoptions
-# REQUIRE: localdaemons
+# REQUIRE: abi
 # BEFORE:  securelevel
 
 . /etc/rc.subr
diff --git a/etc/rc.shutdown b/etc/rc.shutdown
index 3a4888a..d8d6bb6 100644
--- a/etc/rc.shutdown
+++ b/etc/rc.shutdown
@@ -45,6 +45,14 @@ export HOME PATH
 
 . /etc/rc.subr
 
+if [ -r /etc/defaults/rc.conf ]; then
+	. /etc/defaults/rc.conf
+fi
+
+if [ -r /etc/rc.conf ]; then
+	. /etc/rc.conf
+fi
+
 load_rc_config 'XXX'
 
 # reverse_list list
@@ -77,7 +85,8 @@ if [ -n "$rcshutdown_timeout" ]; then
 	_rcshutdown_watchdog=$!
 fi
 
-files=`rcorder -k shutdown /etc/rc.d/* 2>/dev/null`
+files=`rcorder -k shutdown /etc/rc.d/* \
+	$(echo ${local_startup} | sed 's#rc.d#rc.d/*#g') 2>/dev/null`
 
 for _rc_elem in `reverse_list $files`; do
 	debug "run_rc_script $_rc_elem stop"
-- 
1.9.3

