lib: create a library for useful shell functions

There are several snippits of shell code that are useful to multiple
scripts. Start by moving getarg() into the library.

Signed-off-by: David Dillow <dave@thedillows.org>
This commit is contained in:
David Dillow 2009-05-22 22:29:22 -04:00 committed by Harald Hoyer
parent ce743a71cc
commit df44688f3e
3 changed files with 19 additions and 10 deletions

View File

@ -0,0 +1,16 @@
#!/bin/sh
#
# Licensed under the GPLv2
#
# Copyright 2008, Red Hat, Inc.
# Jeremy Katz <katzj@redhat.com>
getarg() {
local o line
[ "$CMDLINE" ] || read CMDLINE </proc/cmdline;
for o in $CMDLINE; do
[ "$o" = "$1" ] && return 0
[ "${o%%=*}" = "${1%=}" ] && { echo ${o#*=}; return 0; }
done
return 1
}

View File

@ -14,15 +14,6 @@ emergency_shell()
sh -i
}
getarg() {
local o line
for o in $CMDLINE; do
[ "$o" = "$1" ] && return 0
[ "${o%%=*}" = "${1%=}" ] && { echo ${o#*=}; return 0; }
done
return 1
}
source_all() {
local f
[ "$1" ] && [ -d "/$1" ] || return
@ -35,6 +26,8 @@ NEWROOT="/sysroot"
trap "emergency_shell" 0
. /lib/dracut-lib
mknod /dev/null c 1 3
# mount some important things
@ -42,7 +35,6 @@ mount -t proc /proc /proc >/dev/null 2>&1
mount -t sysfs /sys /sys >/dev/null 2>&1
mount -t tmpfs -omode=0755 udev /dev >/dev/null 2>&1
read CMDLINE </proc/cmdline;
getarg ramfsdebug && set -x
# Make some basic devices first, let udev handle the rest
mknod /dev/null c 1 3

View File

@ -9,4 +9,5 @@ if [ ! -x "$moddir/switch_root" ]; then
exit 1
fi
inst "$moddir/switch_root" "/sbin/switch_root"
inst "$moddir/dracut-lib" "/lib/dracut-lib"
inst_hook pre-pivot 50 "$moddir/selinux-loadpolicy.sh"