Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Jun 2005 23:13:57 -0400 (EDT)
From:      "J.R. Oldroyd" <fbsd@opal.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   conf/82059: patch to /etc/rc.d/localpkg to partially sort scripts using rcorder(8)
Message-ID:  <200506090313.j593Dv3O075554@linwhf.opal.com>
Resent-Message-ID: <200506090320.j593K1tD087695@freefall.freebsd.org>

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

>Number:         82059
>Category:       conf
>Synopsis:       patch to /etc/rc.d/localpkg to partially sort scripts using rcorder(8)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 09 03:20:01 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     J.R. Oldroyd
>Release:        FreeBSD 6.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD linwhf.opal.com 6.0-CURRENT FreeBSD 6.0-CURRENT #83: Thu Jun 2 09:20:18 EDT 2005 xxx:/usr/src-current/sys/i386/compile/LINWHF i386
>Description:
Certain local rc.d scripts do not currently start because scripts are
executed in alphabetic order, even though many ports provide rcorder(8)
tags.  This patch modifies /etc/rc.d/localpkg to sort the local scripts
using rcorder tags, if present, while preserving existing semantics
for scripts named 000.foo.sh.
>How-To-Repeat:
Install www/apache2 and net/freenet6.
Configure apache to use a freenet6 IPv6 address.
Reboot and watch apache fail to start because apache2.sh is run before freenet6.sh.
>Fix:
--- /etc/rc.d/localpkg.orig	Fri Oct  8 13:52:43 2004
+++ /etc/rc.d/localpkg	Tue Jun  7 15:19:19 2005
@@ -14,6 +14,9 @@
 start_cmd="pkg_start"
 stop_cmd="pkg_stop"
 
+rcorder_opts=""
+[ `/sbin/sysctl -n security.jail.jailed` -eq 1 ] && rcorder_opts="-s nojail"
+
 pkg_start()
 {
 	# For each dir in $local_startup, search for init scripts matching *.sh
@@ -24,19 +27,14 @@
 	*)
 		echo -n 'Local package initialization:'
 		slist=""
-		if [ -z "${script_name_sep}" ]; then
-			script_name_sep=" "
-		fi
+		zlist=""
 		for dir in ${local_startup}; do
 			if [ -d "${dir}" ]; then
-				for script in ${dir}/*.sh; do
-					slist="${slist}${script_name_sep}${script}"
-				done
+				slist="${slist} ${dir}/[^0-9]*.sh"
+				zlist="${zlist} ${dir}/[0-9]*.sh"
 			fi
 		done
-		script_save_sep="$IFS"
-		IFS="${script_name_sep}"
-		for script in ${slist}; do
+		for script in ${zlist} `rcorder -s nostart ${rcorder_opts} ${slist} 2>/dev/null`; do
 			if [ -x "${script}" ]; then
 				(set -T
 				trap 'exit 1' 2
@@ -45,7 +43,6 @@
 				echo -n " (skipping ${script##*/}, not executable)"
 			fi
 		done
-		IFS="${script_save_sep}"
 		echo '.'
 		;;
 	esac
@@ -61,26 +58,20 @@
 		;;
 	*)
 		slist=""
-		if [ -z "${script_name_sep}" ]; then
-			script_name_sep=" "
-		fi
+		zlist=""
 		for dir in ${local_startup}; do
 			if [ -d "${dir}" ]; then
-				for script in ${dir}/*.sh; do
-					slist="${slist}${script_name_sep}${script}"
-				done
+				slist="${slist} ${dir}/[^0-9]*.sh"
+				zlist="${zlist} ${dir}/[0-9]*.sh"
 			fi
 		done
-		script_save_sep="$IFS"
-		IFS="${script_name_sep}"
-		for script in `reverse_list ${slist}`; do
+		for script in `reverse_list ${zlist} \`rcorder -k shutdown ${rcorder_opts} ${slist} 2>/dev/null\``; do
 			if [ -x "${script}" ]; then
 				(set -T
 				trap 'exit 1' 2
 				${script} stop)
 			fi
 		done
-		IFS="${script_save_sep}"
 		echo '.'
 		;;
 	esac


>Release-Note:
>Audit-Trail:
>Unformatted:



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