]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
lib: create a library for useful shell functions
authorDavid Dillow <dave@thedillows.org>
Sat, 23 May 2009 02:29:22 +0000 (22:29 -0400)
committerHarald Hoyer <harald@redhat.com>
Mon, 25 May 2009 10:13:54 +0000 (12:13 +0200)
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>
modules.d/99base/dracut-lib [new file with mode: 0644]
modules.d/99base/init
modules.d/99base/install

diff --git a/modules.d/99base/dracut-lib b/modules.d/99base/dracut-lib
new file mode 100644 (file)
index 0000000..1f31933
--- /dev/null
@@ -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
+}
index ac6a2d86d0d80c7156a7bfb8f7d759a4a1aa2649..05cc4b7fb1b72d59510f9e3f98faf8f641de5b27 100755 (executable)
@@ -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
index 00436ae77af04a1e3ed3c31fbb98c37bf01d5493..ce1e2f92cae70be4aa04ceed6249c9a85c17d4f0 100755 (executable)
@@ -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"