Gentoo Archives: gentoo-dev

From: Francesco R <vivo@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] init.d-scripts don't see stuff from /etc/profile.env
Date: Tue, 30 Aug 2005 22:58:26
Message-Id: 4314DF64.5030402@gentoo.org
In Reply to: Re: [gentoo-dev] init.d-scripts don't see stuff from /etc/profile.env by Roy Marples
1 Roy Marples wrote:
2
3 >I just love replying to myself!
4 >
5 >On Tue, 2005-08-30 at 22:32 +0100, Roy Marples wrote:
6 >
7 >
8 >>#!/bin/sh
9 >>
10 >>/bin/env -i \
11 >> CONSOLETYPE="${CONSOLETYPE}" \
12 >> IN_BACKGROUND="${IN_BACKGROUND}" \
13 >> IN_HOTPLUG="${IN_HOTPLUG}" \
14 >> /lib/rcscripts/sh/runscript.sh $*
15 >>
16 >>
17 >
18 >A quick reboot shows we need much more. Here's what works on my system
19 >
20 >/bin/env -i \
21 > BOOT="${BOOT}" \
22 > CONSOLETYPE="${CONSOLETYPE}" \
23 > CRITICAL_SERVICES="${CRITICAL_SERVICES}" \
24 > START_CRITICAL="${START_CRITICAL}" \
25 > STOP_CRTIICAL="${STOP_CRITICAL}" \
26 > OLDSOFTLEVEL="${OLDSOFTLEVEL}" \
27 > SOFTLEVEL="${SOFTLEVEL}" \
28 > IN_BACKGROUND="${IN_BACKGROUND}" \
29 > IN_HOTPLUG="${IN_HOTPLUG}" \
30 > /lib/rcscripts/sh/runscript.sh $*
31 >
32 >
33 >
34 >
35 >>Right away we can see that we actually do need some to keep some env
36 >>vars and the list would be constantly updated. There's also nothing to
37 >>stop the user from setting them and then running a script which kind of
38 >>defeats the purpose here anyway.
39 >>
40 >>Personally I'm against this.I'd like to know what Azarah and Vapier
41 >>think of this though. Others too!
42 >>
43 >>
44 >
45 >I think I just added a few more reasons why I don't like this ....
46 >
47 >Roy
48 >
49 >
50 >
51 Read only the last three messages of the thread, hoping to not say
52 idiotic things.
53 Rewriting the previous script in the following manner:
54
55 [code]
56 VARS_TO_EXPORT="BOOT CONSOLETYPE CRITICAL_SERVICES START_CRITICAL
57 STOP_CRITICAL OLDSOFTLEVEL SOFTLEVEL IN_BACKGROUND IN_HOTPLUG"
58
59 RUNSCRIPT="/bin/env -i"
60 for i in ${VARS_TO_EXPORT} ; do
61 RUNSCRIPT="${RUNSCRIPT} ${i}=\${${i}}"
62 done
63 RUNSCRIPT="${RUNSCRIPT} /lib/rcscripts/sh/runscript.sh $*"
64 eval $RUNSCRIPT
65 [/code]
66
67 should make it easyer to maintain, also "VARS_TO_EXPORT" could be placed
68 in /etc/rc.conf (with a better name) .
69 Running the rc scripts from a clean environment make easyer to debug
70 things, it caused at least one headheache to me installing SuSE + apache
71 + php + informix some years ago.
72
73 just my 2 cents.
74
75 --
76 gentoo-dev@g.o mailing list