2 # returns OK if $1 contains $2
4 [ "${1#*$2*}" != "$1" ]
10 if [ -z "$CMDLINE" ]; then
11 if [ -e /etc
/cmdline
]; then
13 CMDLINE_ETC
="$CMDLINE_ETC $line";
16 read CMDLINE
</proc
/cmdline
;
17 CMDLINE
="$CMDLINE $CMDLINE_ETC"
20 if [ "$o" = "$1" ]; then
21 [ "$RDDEBUG" = "yes" ] && set -x;
24 [ "${o%%=*}" = "${1%=}" ] && val=${o#*=};
26 if [ -n "$val" ]; then
28 [ "$RDDEBUG" = "yes" ] && set -x;
31 [ "$RDDEBUG" = "yes" ] && set -x
38 if [ -z "$CMDLINE" ]; then
39 if [ -e /etc/cmdline ]; then
41 CMDLINE_ETC="$CMDLINE_ETC $line";
44 read CMDLINE </proc/cmdline;
45 CMDLINE="$CMDLINE $CMDLINE_ETC"
48 if [ "$o" = "$1" ]; then
49 [ "$RDDEBUG" = "yes" ] && set -x;
52 if [ "${o%%=*}" = "${1%=}" ]; then
57 if [ -n "$found" ]; then
58 [ "$RDDEBUG" = "yes" ] && set -x
61 [ "$RDDEBUG" = "yes" ] && set -x
65 # Prints value of given option. If option is a flag and it's present,
66 # it just returns 0. Otherwise 1 is returned.
67 # $1 = options separated by commas
68 # $2 = option we are interested in
71 # $1 = cipher=aes-cbc-essiv:sha256,hash=sha256,verify
76 local line=",$1,"; local opt="$2"; local tmp
80 tmp="${line#*,${opt}=}"
84 *,${opt},*) return 0 ;;
91 if [ -z "$RDDEBUG" ]; then
92 if [ -e /proc/cmdline ]; then
94 if getarg rdinitdebug || getarg rdnetdebug; then
100 [ "$RDDEBUG" = "yes" ] && set -x
107 [ "$1" ] && [ -d "/$1" ] || return
108 for f in "/$1"/*.sh; do [ -e "$f" ] && . "$f"; done
113 for f in /initqueue-finished/*.sh; do { [ -e "$f" ] && ( . "$f" ) ; } || return 1 ; done
119 [ "$1" ] && [ -d "/$1" ] || return
120 for f in "/$1"/*.conf; do [ -e "$f" ] && . "$f"; done
125 echo "<1>dracut
: FATAL
: $@
";
126 echo "<1>dracut
: Refusing to
continue";
130 echo "dracut
: FATAL
: $@
";
131 echo "dracut
: Refusing to
continue";
138 if [ -z "$DRACUT_QUIET" ]; then
140 getarg rdinfo && DRACUT_QUIET="no
"
141 getarg quiet || DRACUT_QUIET="yes"
147 echo "<4>dracut Warning
: $@
" > /dev/kmsg
148 [ "$DRACUT_QUIET" != "yes" ] && \
149 echo "dracut Warning
: $@
" >&2
154 echo "<6>dracut
: $@
" > /dev/kmsg
155 [ "$DRACUT_QUIET" != "yes" ] && \
166 # Count the number of times the character $ch occurs in $str
167 # Return 0 if the count matches the expected number, 1 otherwise
173 while [ "${str#*$ch}" != "${str}" ]; do
175 count=$(( $count + 1 ))
178 [ $count -eq $expected ]
186 [ -z "$file" ] && return;
187 [ -z "$str" ] && return;
189 while read dummy check restofline; do
190 [ "$check" = "$str" ] && return 0
196 [ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version)
198 if [ $UDEVVERSION -ge 143 ]; then
199 udevadm settle --exit-if-exists=/initqueue/work $settle_exit_if_exists
201 udevadm settle --timeout=30
206 [ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version)
208 if [ $UDEVVERSION -ge 143 ]; then
209 for i in "$@
"; do udevadm control --property=$i; done
211 for i in "$@
"; do udevadm control --env=$i; done
217 while [ $cnt -lt 20 ]; do
218 li=$(ip link show $1)
219 [ -z "${li##*state UP*}" ] && return 0
226 # root=nfs:[<server-ip>:]<root-dir>[:<nfs-options>]
227 # root=nfs4:[<server-ip>:]<root-dir>[:<nfs-options>]
234 # check if we have a server
235 if strstr "$arg" ':/*' ; then
243 options="${arg##$path}"
245 options="${options##:}"
247 options="${options%%:}"
249 # Does it really start with '/'?
250 [ -n "${path%%/*}" ] && path="error
";
252 #Fix kernel legacy style separating path and options with ','
253 if [ "$path" != "${path#*,}" ] ; then
263 while [ -n "$v" ]; do
264 if [ "${v#\[*:*:*\]:}" != "$v" ]; then
265 # handle IPv6 address
271 set -- "$@
" "${v%%:*}"
276 unset ip srv gw mask hostname dev autoconf
278 0) autoconf="error
" ;;
280 2) dev=$1; autoconf=$2 ;;
281 *) ip=$1; srv=$2; gw=$3; mask=$4; hostname=$5; dev=$6; autoconf=$7 ;;
285 # Evaluate command for UUIDs either given as arguments for this function or all
286 # listed in /dev/disk/by-uuid. UUIDs doesn't have to be fully specified. If
287 # beginning is given it is expanded to all matching UUIDs. To pass full UUID
288 # to your command use '${full_uuid}'. Remember to escape '$'!
290 # $1 = command to be evaluated
291 # $2 = list of UUIDs separated by space
293 # The function returns after *first successful evaluation* of the given command
294 # with status 0. If evaluation fails for every UUID function returns with
298 # foreach_uuid_until "mount
-U \
${full_uuid} /mnt
; echo OK
; umount
/mnt
" \
299 # "01234 f512 a235567f-12a3-c123-a1b1-01234567abcb
"
300 foreach_uuid_until() (
303 local cmd="$1"; shift; local uuids_list="$
*"
304 local uuid; local full_uuid
306 [ -n "${cmd}" ] || return 1
308 for uuid in ${uuids_list:-*}; do
309 for full_uuid in ${uuid}*; do
310 [ -e "${full_uuid}" ] || continue
311 eval ${cmd} && return 0