mirror of
https://github.com/dracutdevs/dracut.git
synced 2024-10-29 03:25:33 +03:00
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:
parent
ce743a71cc
commit
df44688f3e
16
modules.d/99base/dracut-lib
Normal file
16
modules.d/99base/dracut-lib
Normal 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
|
||||
}
|
@ -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
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user