/[baselayout]/trunk/sbin/functions.sh
Gentoo

Diff of /trunk/sbin/functions.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 388 Revision 389
46# 46#
47# Default values for rc system 47# Default values for rc system
48# 48#
49RC_NET_STRICT_CHECKING="no" 49RC_NET_STRICT_CHECKING="no"
50RC_PARALLEL_STARTUP="no" 50RC_PARALLEL_STARTUP="no"
51RC_USE_CONFIG_PROFILE="yes"
51 52
52# Override defaults with user settings ... 53# Override defaults with user settings ...
53[ -f /etc/conf.d/rc ] && source /etc/conf.d/rc 54[ -f /etc/conf.d/rc ] && source /etc/conf.d/rc
54 55
55 56
130# 'bootlevel' and 'softlevel' via kernel 131# 'bootlevel' and 'softlevel' via kernel
131# parameters. 132# parameters.
132# 133#
133get_bootconfig() { 134get_bootconfig() {
134 local copt= 135 local copt=
135 BOOTLEVEL= 136 local newbootlevel=
136 SOFTLEVEL= 137 local newsoftlevel=
137 138
138 for copt in $(cat /proc/cmdline) 139 for copt in $(< /proc/cmdline)
139 do 140 do
140 case "${copt%=*}" in 141 case "${copt%=*}" in
141 bootlevel) 142 "bootlevel")
142 BOOTLEVEL="${copt##*=}" 143 newbootlevel="${copt##*=}"
143 ;; 144 ;;
144 softlevel) 145 "softlevel")
145 SOFTLEVEL="${copt##*=}" 146 newsoftlevel="${copt##*=}"
146 ;; 147 ;;
147 esac 148 esac
148 done 149 done
149 150
150 if [ -z "${BOOTLEVEL}" -o ! -d "/etc/runlevels/${BOOTLEVEL}" ] 151 if [ -n "${newbootlevel}" ]
151 then
152 if [ -n "${BOOTLEVEL}" ] && [ -L "/etc/runlevels/${BOOTLEVEL}" ]
153 then 152 then
154 continue 153 export BOOTLEVEL="${newbootlevel}"
154 else
155 export BOOTLEVEL="boot"
156 fi
157
158 if [ -n "${newsoftlevel}" ]
159 then
160 export DEFAULTLEVEL="${newsoftlevel}"
161 else
162 export DEFAULTLEVEL="default"
163 fi
164
165 return 0
166}
167
168setup_defaultlevels() {
169 get_bootconfig
170
171 if get_bootparam "noconfigprofile"
172 then
173 export RC_USE_CONFIG_PROFILE="no"
174
175 elif get_bootparam "configprofile"
176 then
177 export RC_USE_CONFIG_PROFILE="yes"
178 fi
179
180 if [ "${RC_USE_CONFIG_PROFILE}" = "yes" -a -n "${DEFAULTLEVEL}" ] && \
181 [ -d "/etc/runlevels/${BOOTLEVEL}.${DEFAULTLEVEL}" -o \
182 -L "/etc/runlevels/${BOOTLEVEL}.${DEFAULTLEVEL}" ]
183 then
184 export BOOTLEVEL="${BOOTLEVEL}.${DEFAULTLEVEL}"
185 fi
186
187 if [ -z "${SOFTLEVEL}" ]
188 then
189 if [ -f "${svcdir}/softlevel" ]
190 then
191 export SOFTLEVEL="$(< ${svcdir}/softlevel)"
155 else 192 else
156 BOOTLEVEL="boot" 193 export SOFTLEVEL="${BOOTLEVEL}"
157 fi
158 fi 194 fi
159
160 export BOOTLEVEL SOFTLEVEL
161
162 return 0
163}
164
165if [ -z "${EBUILD}" -a -e "/proc/cmdline" ]
166then
167 get_bootconfig
168fi 195 fi
196
197 return 0
198}
169 199
170# void esyslog(char* priority, char* tag, char* message) 200# void esyslog(char* priority, char* tag, char* message)
171# 201#
172# use the system logger to log a message 202# use the system logger to log a message
173# 203#
560 fi 590 fi
561 591
562 return 0 592 return 0
563} 593}
564 594
595# char *add_suffix(char * configfile)
596#
597# Returns a config file name with the softlevel suffix
598# appended to it. For use with multi-config services.
599add_suffix () {
600 if [ "${RC_USE_CONFIG_PROFILE}" = "yes" -a -e "$1.${DEFAULTLEVEL}" ]
601 then
602 echo "$1.${DEFAULTLEVEL}"
603 else
604 echo "$1"
605 fi
606
607 return 0
608}
609
565set +a 610set +a
566 611
612if [ -z "${EBUILD}" ]
613then
614 if [ -e "/proc/cmdline" ]
615 then
616 setup_defaultlevels
617 fi
618fi
619
567 620
568# vim:ts=4 621# vim:ts=4

Legend:
Removed from v.388  
changed lines
  Added in v.389

  ViewVC Help
Powered by ViewVC 1.1.20