summaryrefslogtreecommitdiffstats
path: root/modules.d/95cifs/parse-cifsroot.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 13:54:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 13:54:25 +0000
commit9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a (patch)
tree2efb72864cc69e174c9c5ee33efb88a5f1553b48 /modules.d/95cifs/parse-cifsroot.sh
parentInitial commit. (diff)
downloaddracut-9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a.tar.xz
dracut-9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a.zip
Adding upstream version 060+5.upstream/060+5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules.d/95cifs/parse-cifsroot.sh')
-rwxr-xr-xmodules.d/95cifs/parse-cifsroot.sh51
1 files changed, 51 insertions, 0 deletions
diff --git a/modules.d/95cifs/parse-cifsroot.sh b/modules.d/95cifs/parse-cifsroot.sh
new file mode 100755
index 0000000..b88bef4
--- /dev/null
+++ b/modules.d/95cifs/parse-cifsroot.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# root=cifs://[user:pass@]<server>/<folder>
+#
+# This syntax can come from DHCP root-path as well.
+#
+# If a username or password are not specified as part of the root, then they
+# will be pulled from cifsuser and cifspass on the kernel command line,
+# respectively.
+#
+
+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
+. /lib/cifs-lib.sh
+
+# This script is sourced, so root should be set. But let's be paranoid
+[ -z "$root" ] && root=$(getarg root=)
+
+if [ -z "$netroot" ]; then
+ for netroot in $(getargs netroot=); do
+ [ "${netroot%%:*}" = "cifs" ] && break
+ done
+ [ "${netroot%%:*}" = "cifs" ] || unset netroot
+fi
+
+# Root takes precedence over netroot
+if [ "${root%%:*}" = "cifs" ]; then
+ if [ -n "$netroot" ]; then
+ warn "root takes precedence over netroot. Ignoring netroot"
+ fi
+ netroot=$root
+ unset root
+fi
+
+# If it's not cifs we don't continue
+[ "${netroot%%:*}" = "cifs" ] || return
+
+# Check required arguments
+cifs_to_var "$netroot"
+
+# If we don't have a server, we need dhcp
+if [ -z "$server" ]; then
+ # shellcheck disable=SC2034
+ DHCPORSERVER="1"
+fi
+
+# Done, all good!
+# shellcheck disable=SC2034
+rootok=1
+
+# shellcheck disable=SC2016
+echo '[ -e $NEWROOT/proc ]' > "$hookdir"/initqueue/finished/cifsroot.sh