Subject: misc/16888: hooks to add scripts to rcorder in /etc/rc or /etc/rc.shutdown
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ball@iprotium.com>
List: netbsd-bugs
Date: 05/18/2002 16:24:37
>Number: 16888
>Category: misc
>Synopsis: There are hooks to add scripts to rcorder in /etc/rc or /etc/rc.shutdown.
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: misc-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sat May 18 16:25:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Allen D. Ball
>Release: NetBSD 1.5.3_RC2
>Organization:
N/A
>Environment:
System: NetBSD proton. 1.5.3_RC2 NetBSD 1.5.3_RC2 (INTEL-ISP1100) #0: Fri May 17 22:09:48 PDT 2002 ball@proton.:/usr/src/sys/arch/i386/compile/INTEL-ISP1100 i386
Architecture: i386
Machine: i386
>Description:
There are no hooks in rc.conf to add scripts to the rcorder commands in
/etc/rc and /etc/rc.shutdown. This forces an extra configuration step
when using system services such as apache out of NetBSD packages.
>How-To-Repeat:
Inspect /etc/rc and /etc/rc.shutdown.
>Fix:
This patch proposes a new shell variable, $rcorder_flags, which may be
overridden in /etc/rc.conf.
It also proposes a new flag to rcorder, -D, to add directories to be
searched for start up scripts.
For example, this allows:
if [ -d /usr/pkg/etc/rc.d ]; then
rcorder_flags="$rcorder_flags -D /usr/pkg/etc/rc.d"
fi
to be included in /etc/rc.conf to get package start-up scripts from the
usual place in the package hierarchy.
[The uuencoded patch provides a similar patch for the release-1-5 branch.]
Index: src/etc/rc
diff -c src/etc/rc:1.1.1.2 src/etc/rc:1.1.1.2.4.1
*** src/etc/rc:1.1.1.2 Sat Apr 20 16:24:31 2002
--- src/etc/rc Fri May 17 13:45:29 2002
***************
*** 37,43 ****
date
! files=`rcorder -s nostart /etc/rc.d/*`
for _rc_elem in $files; do
run_rc_script $_rc_elem start
--- 37,43 ----
date
! files=`rcorder -s nostart $rcorder_flags /etc/rc.d/*`
for _rc_elem in $files; do
run_rc_script $_rc_elem start
Index: src/etc/rc.shutdown
diff -c src/etc/rc.shutdown:1.1.1.1 src/etc/rc.shutdown:1.1.1.1.4.1
*** src/etc/rc.shutdown:1.1.1.1 Mon Mar 25 12:59:23 2002
--- src/etc/rc.shutdown Fri May 17 13:45:29 2002
***************
*** 47,53 ****
# Determine the shutdown order of the /etc/rc.d scripts,
# and perform the operation
#
! files=`rcorder -k shutdown /etc/rc.d/*`
for _rc_elem in `reverse_list $files`; do
run_rc_script $_rc_elem stop
--- 47,53 ----
# Determine the shutdown order of the /etc/rc.d scripts,
# and perform the operation
#
! files=`rcorder -k shutdown $rcorder_flags /etc/rc.d/*`
for _rc_elem in `reverse_list $files`; do
run_rc_script $_rc_elem stop
Index: src/etc/defaults/rc.conf
diff -c src/etc/defaults/rc.conf:1.1.1.4 src/etc/defaults/rc.conf:1.1.1.4.2.1
*** src/etc/defaults/rc.conf:1.1.1.4 Tue Apr 30 11:14:35 2002
--- src/etc/defaults/rc.conf Fri May 17 13:45:39 2002
***************
*** 28,33 ****
--- 28,36 ----
#
#rc_fast_and_loose=YES
+ # Additional flags to pass to rcorder in /etc/rc and /etc/rc.shutdown.
+ rcorder_flags=""
+
# If this is set to NO, shutdown(8) will not run /etc/rc.shutdown.
#
do_rcshutdown=YES
Index: src/sbin/rcorder/rcorder.8
diff -c src/sbin/rcorder/rcorder.8:1.1.1.1 src/sbin/rcorder/rcorder.8:1.1.1.1.6.1
*** src/sbin/rcorder/rcorder.8:1.1.1.1 Mon Mar 25 13:03:21 2002
--- src/sbin/rcorder/rcorder.8 Fri May 17 13:45:06 2002
***************
*** 87,92 ****
--- 87,94 ----
.Pp
The options are as follows:
.Bl -tag -width Ds
+ .It Fl D
+ Search the specified directory for start-up scripts.
.It Fl k
Add the specified keyword to the
.Dq keep list .
Index: src/sbin/rcorder/rcorder.c
diff -c src/sbin/rcorder/rcorder.c:1.1.1.2 src/sbin/rcorder/rcorder.c:1.1.1.2.6.1
*** src/sbin/rcorder/rcorder.c:1.1.1.2 Sat Apr 20 16:39:39 2002
--- src/sbin/rcorder/rcorder.c Fri May 17 13:45:07 2002
***************
*** 33,41 ****
--- 33,43 ----
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+ #include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
+ #include <dirent.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
***************
*** 122,127 ****
--- 124,130 ----
filenode fn_head_s, *fn_head;
+ strnodelist *dir_list;
strnodelist *bl_list;
strnodelist *keep_list;
strnodelist *skip_list;
***************
*** 143,148 ****
--- 146,153 ----
void add_keyword __P((filenode *, char *));
void insert_before __P((void));
Hash_Entry *make_fake_provision __P((filenode *));
+ void crunch_directory __P((char *));
+ void crunch_all_directories __P((void));
void crunch_all_files __P((void));
void initialize __P((void));
void generate_ordering __P((void));
***************
*** 155,161 ****
{
int ch;
! while ((ch = getopt(argc, argv, "dk:s:")) != -1)
switch (ch) {
case 'd':
#ifdef DEBUG
--- 160,166 ----
{
int ch;
! while ((ch = getopt(argc, argv, "dD:k:s:")) != -1)
switch (ch) {
case 'd':
#ifdef DEBUG
***************
*** 164,169 ****
--- 169,177 ----
warnx("debugging not compiled in, -d ignored");
#endif
break;
+ case 'D':
+ strnode_add(&dir_list, optarg, 0);
+ break;
case 'k':
strnode_add(&keep_list, optarg, 0);
break;
***************
*** 183,188 ****
--- 191,198 ----
DPRINTF((stderr, "parse_args\n"));
initialize();
DPRINTF((stderr, "initialize\n"));
+ crunch_all_directories();
+ DPRINTF((stderr, "crunch_all_directories\n"));
crunch_all_files();
DPRINTF((stderr, "crunch_all_files\n"));
generate_ordering();
***************
*** 606,611 ****
--- 616,663 ----
free(bl_list);
bl_list = bl;
+ }
+ }
+
+ /*
+ * given a directory name, find the files which may be scripts and crunch
+ */
+ void
+ crunch_directory(dir)
+ char *dir;
+ {
+ DIR *dd;
+ struct dirent *dp;
+ char path[MAXPATHLEN];
+ struct stat sb;
+
+ if ((dd = opendir(dir)) != NULL) {
+ while ((dp = readdir(dd)) != NULL) {
+ (void) strncpy(path, dir, sizeof path);
+ (void) strncat(path, "/", sizeof path);
+ (void) strncat(path, dp->d_name, sizeof path);
+ if (stat(path, &sb) == 0
+ && (! ((sb.st_mode&S_IFDIR) == S_IFDIR)))
+ crunch_file(path);
+ }
+
+ (void) closedir(dd);
+ }
+ else {
+ warn("cannot open directory `%s'.", dir);
+ }
+ }
+
+ /*
+ * loop over all the specified directories looking for files to crunch_file()
+ */
+ void
+ crunch_all_directories()
+ {
+ strnodelist *d;
+
+ for (d = dir_list; d; d = d->next) {
+ crunch_directory(d->s);
}
}
begin 644 release.patch
M26YD97@Z('-R8R]E=&,O<F,*9&EF9B`M8R!S<F,O971C+W)C.C$N,2XU+C$@
M<W)C+V5T8R]R8SHQ+C$N-2XQ+C8N,0HJ*BH@<W)C+V5T8R]R8SHQ+C$N-2XQ
M"4UO;B!-87(@,C4@,30Z-#(Z-#`@,C`P,@HM+2T@<W)C+V5T8R]R8PE&<FD@
M36%Y(#$W(#$T.C4Y.C4V(#(P,#(**BHJ*BHJ*BHJ*BHJ*BHJ"BHJ*B`S,RPS
M.2`J*BHJ"B`@=')A<"`Z(#(*("!T<F%P(")E8VAO("=";V]T(&EN=&5R<G5P
M=&5D+B<[(&5X:70@,2(@,PH@(`HA(&9I;&5S/6!R8V]R9&5R("US(&YO<W1A
M<G0@+V5T8R]R8RYD+RI@"B`@"B`@9F]R(&D@:6X@)&9I;&5S.R!D;PH@(`ER
M=6Y?<F-?<V-R:7!T("1I('-T87)T"BTM+2`S,RPS.2`M+2TM"B`@=')A<"`Z
M(#(*("!T<F%P(")E8VAO("=";V]T(&EN=&5R<G5P=&5D+B<[(&5X:70@,2(@
M,PH@(`HA(&9I;&5S/6!R8V]R9&5R("US(&YO<W1A<G0@)')C;W)D97)?9FQA
M9W,@+V5T8R]R8RYD+RI@"B`@"B`@9F]R(&D@:6X@)&9I;&5S.R!D;PH@(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