Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Jul 2001 12:43:34 +0300
From:      Peter Pentchev <roam@orbitel.bg>
To:        arch@FreeBSD.org
Cc:        audit@FreeBSD.org
Subject:   A slight improvement of the rc system
Message-ID:  <20010704124334.F653@ringworld.oblivion.bg>

next in thread | raw e-mail | index | archive | help
Hi,

(And yes, I know that there is work in progress of importing the NetBSD
 rc system; still, I don't think it is going to happen very soon, and
 I don't think it is going to be MFC'd soon, if ever, so here goes..)

Attached is a patch that does two things for the startup/shutdown scripts.

First, a new rc.conf variable is introduced - script_name_sep.  By default,
this is a space, but it should be changed if your startup/shutdown scripts
contain spaces.  This is not a common occurrence, but it might prove
useful, e.g. for people coming from Seattle-OS-based environments, who are
prone to generating long, descriptive file names.

Second, the rc.shutdown logic is changed a little, so shutdown scripts
are executed in reverse alphabetical order.  Thus, dependent services
are shutdown before the ones they depend upon.

G'luck,
Peter

-- 
.siht ekil ti gnidaer eb d'uoy ,werbeH ni erew ecnetnes siht fI

Index: src/etc/rc
===================================================================
RCS file: /home/ncvs/src/etc/rc,v
retrieving revision 1.271
diff -u -r1.271 rc
--- src/etc/rc	2001/06/28 06:43:47	1.271
+++ src/etc/rc	2001/07/04 07:45:15
@@ -793,17 +793,24 @@
 	;;
 *)
 	echo -n 'Local package initialization:'
+	slist=""
 	for dir in ${local_startup}; do
 		if [ -d "${dir}" ]; then
 			for script in ${dir}/*.sh; do
-				if [ -x "${script}" ]; then
-					(set -T
-					 trap 'exit 1' 2
-					 ${script} start)
-				fi
+				slist="${slist}${script_name_sep}${script}"
 			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)
+		fi
+	done
+	IFS="${script_save_sep}"
 	echo '.'
 	;;
 esac
Index: src/etc/rc.shutdown
===================================================================
RCS file: /home/ncvs/src/etc/rc.shutdown,v
retrieving revision 1.16
diff -u -r1.16 rc.shutdown
--- src/etc/rc.shutdown	2000/12/17 08:15:57	1.16
+++ src/etc/rc.shutdown	2001/07/04 07:45:15
@@ -102,17 +102,24 @@
 [Nn][Oo] | '')
 	;;
 *)
+	slist=""
 	for dir in ${local_startup}; do
 		if [ -d "${dir}" ]; then
 			for script in ${dir}/*.sh; do
-				if [ -x "${script}" ]; then
-					(set -T
-					 trap 'exit 1' 2
-					 ${script} stop)
-				fi
+				slist="${script}${script_name_sep}${slist}"
 			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} stop)
+		fi
+	done
+	IFS="${script_save_sep}"
 	echo '.'
 	;;
 esac
Index: src/etc/defaults/rc.conf
===================================================================
RCS file: /home/ncvs/src/etc/defaults/rc.conf,v
retrieving revision 1.116
diff -u -r1.116 rc.conf
--- src/etc/defaults/rc.conf	2001/06/28 21:45:47	1.116
+++ src/etc/defaults/rc.conf	2001/07/04 07:45:15
@@ -31,6 +31,7 @@
 pccard_conf="/etc/defaults/pccard.conf"	# pccardd(8) config file
 removable_interfaces=""	# Removable network interfaces for /etc/pccard_ether.
 local_startup="/usr/local/etc/rc.d /usr/X11R6/etc/rc.d"	# startup script dirs.
+script_name_sep=" "	# Change if your startup scripts' names contain spaces
 rc_conf_files="/etc/rc.conf /etc/rc.conf.local"
 fsck_y_enable="NO" 	# Set to YES to do fsck -y if the initial preen fails.
 background_fsck="YES"	# Attempt to run fsck in the background where possible.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010704124334.F653>