Skip to contentSkip to conversation

support adding module-specific parameters

RFC PATCH In review [email protected] 3 participants 13 messages Jan 10, 2012 – Jan 24, 2012 9 messages not in the archive

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/2 support adding module-specific parameters

From: Cong Wang <[email protected]>

ssh-client module needs a specific parameter, --ssh-key, but this parameter is totally useless for other modules. So, introduce a way to let users to pass module-specific parameters, that is, using colons to separate module name and its parameters, like,

--add ssh-client:sshkey=/root/.ssh/kdump_id_rsa.pub

---
 dracut           |   30 ++++++++++++++++++++++++++----
 dracut-functions |   14 ++++++++++++--
 dracut.8.xml     |   22 ++++++++++++++++++----
 3 files changed, 56 insertions(+), 10 deletions(-)
dracut +26 -4
index 8fcdffe..f3fa257 100755
@@ -199,6 +199,13 @@ push_arg() {
     fi
 }
 
+declare -A dracut_module_args
+read_module_args() {
+    local _key="${1%%:*}"
+    local _val="${1#*:}"
+    dracut_module_args["$_key"]="$_val"
+}
+
 verbosity_mod_l=0
 
 while (($# > 0)); do
@@ -319,13 +326,23 @@ fi
 # these optins add to the stuff in the config file
 if (( ${#add_dracutmodules_l[@]} )); then
     while pop add_dracutmodules_l val; do
-        add_dracutmodules+=" $val "
+        if [[ "$val" =~ ":" ]]; then
+            add_dracutmodules+=" ${val%%:*} "
+            read_module_args "$val"
+        else
+            add_dracutmodules+=" $val "
+        fi
     done
 fi
 
 if (( ${#force_add_dracutmodules_l[@]} )); then
     while pop force_add_dracutmodules_l val; do
-        force_add_dracutmodules+=" $val "
+        if [[ "$val" =~ ":" ]]; then
+            force_add_dracutmodules+="${val%%:*} "
+            read_module_args "$val"
+        else
+            force_add_dracutmodules+=" $val "
+        fi
     done
 fi
 
@@ -364,7 +381,12 @@ fi
 if (( ${#dracutmodules_l[@]} )); then
     dracutmodules=''
     while pop dracutmodules_l val; do
-        dracutmodules+="$val "
+        if [[ "$val" =~ ":" ]]; then
+            dracutmodules+="${val%%:*} "
+            read_module_args "$val"
+        else
+            dracutmodules+="$val "
+        fi
     done
 fi
 
@@ -591,7 +613,7 @@ export initdir dracutbasedir dracutmodules drivers \
     add_drivers mdadmconf lvmconf filesystems \
     use_fstab libdir usrlibdir fscks nofscks cttyhack \
     stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
-    debug host_fs_types host_devs sshkey
+    debug host_fs_types host_devs sshkey dracut_module_args
 
 # Create some directory structure first
 [[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
dracut-functions +12 -2
index 3dd72e9..00f8309 100755
@@ -690,14 +690,24 @@ module_check() {
         # if we do not have a check script, we are unconditionally included
         [[ -x $_moddir/check ]] || return 0
         [ $_forced -ne 0 ] && unset hostonly
-        $_moddir/check $hostonly
+        if [ -n "${dracut_module_args["$1"]}" ]; then
+            local _l="${dracut_module_args["$1"]}"
+            eval "(${_l/:/;};$_moddir/check $hostonly;)"
+        else
+            $_moddir/check $hostonly
+        fi
         _ret=$?
     else
         unset check depends install installkernel
         . $_moddir/module-setup.sh
         is_func check || return 0
         [ $_forced -ne 0 ] && unset hostonly
-        check $hostonly
+        if [ -n "${dracut_module_args["$1"]}" ]; then
+            local _l="${dracut_module_args["$1"]}"
+            eval "(${_l/:/;};check $hostonly;)"
+        else
+            check $hostonly
+        fi
         _ret=$?
         unset check depends install installkernel
     fi
dracut.8.xml +18 -4
index 5a5df54..ea24764 100644
@@ -106,13 +106,14 @@ For a complete list of kernel command line options see
             <option>-m</option>
           </term>
           <term>
-            <option>--modules&nbsp;<replaceable>&lt;list of dracut modules&gt;</replaceable></option>
+            <option>--modules&nbsp;<replaceable>&lt;module1:para1=val1:para2=val2 module2 ...&gt;</replaceable></option>
           </term>
           <listitem>
             <para>specify a space-separated list of dracut modules to call
 when building the initramfs.
 Modules are located in
-<filename>/usr/lib/dracut/modules.d</filename>. This parameter can be specified multiple times.</para>
+<filename>/usr/lib/dracut/modules.d</filename>. This parameter can be specified multiple times.
+You can also pass module specific parameters here, using colons, for example, -m ssh-client:sshkey=/root/ssh-key.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
@@ -131,7 +132,7 @@ Modules are located in
             <option>-a</option>
           </term>
           <term>
-            <option>--add&nbsp;<replaceable>&lt;list of dracut modules&gt;</replaceable></option>
+            <option>--add&nbsp;<replaceable>&lt;module1:para1=val1:para2=val2 module2 ...&gt;</replaceable></option>
           </term>
           <listitem>
             <para>add a space-separated list of dracut modules to the default set of modules. This parameter can be specified multiple times.</para>
@@ -139,7 +140,7 @@ Modules are located in
         </varlistentry>
         <varlistentry>
           <term>
-            <option>--force-add&nbsp;<replaceable>&lt;list of dracut modules&gt;</replaceable></option>
+            <option>--force-add&nbsp;<replaceable>&lt;module1:para1=val1:para2=val2 module2 ...&gt;</replaceable></option>
           </term>
           <listitem>
             <para>force to add a space-separated list of dracut modules to the default set of modules, when -H is specified. This parameter can be specified multiple times.</para>
@@ -539,6 +540,19 @@ TARGET directory in the final initramfs. If SOURCE is a file, it will be install
         </varlistentry>
       </variablelist>
     </refsect2>
+    <refsect2>
+     <title>Module Specific Parameters</title>
+     <variablelist>
+        <varlistentry>
+          <term>
+            <option>ssh-client</option>
+          </term>
+          <listitem>
+            <para>sshkey=/path/to/sshkey (specifies the path to your ssh public key which will be used by ssh-client module)</para>
+          </listitem>
+       </varlistentry>
+      </variablelist>
+    </refsect2>
   </refsect1>
   <refsect1>
     <title>Files</title>
Signature · 1 line
1.7.7.5
#2 lore raw

PATCH 2/2 remove the global --sshkey parameter

In reply to a message not in the archive

From: Cong Wang <[email protected]>

---
 dracut       |    4 +---
 dracut.8.xml |    8 --------
 2 files changed, 1 insertions(+), 11 deletions(-)
dracut +1 -3
index f3fa257..58c4fde 100755
@@ -118,7 +118,6 @@ Creates initial ramdisk images for preloading modules
   -M, --show-modules    Print included module's name to standard output during
                          build.
   --keep                Keep the temporary initramfs for debugging purposes
-  --sshkey [SSHKEY]     Add ssh key to initramfs (use with ssh-client module)
   --ctty                Add control tty for emergency shells
 EOF
 }
@@ -242,7 +241,6 @@ while (($# > 0)); do
         --debug)       debug="yes";;
         --profile)     profile="yes";;
         --ctty)        cttyhack="yes";;
-        --sshkey)      read_arg sshkey   "$@" || shift;;
         -v|--verbose)  ((verbosity_mod_l++));;
         -q|--quiet)    ((verbosity_mod_l--));;
         -l|--local)    allowlocal="yes" ;;
@@ -613,7 +611,7 @@ export initdir dracutbasedir dracutmodules drivers \
     add_drivers mdadmconf lvmconf filesystems \
     use_fstab libdir usrlibdir fscks nofscks cttyhack \
     stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
-    debug host_fs_types host_devs sshkey dracut_module_args
+    debug host_fs_types host_devs dracut_module_args
 
 # Create some directory structure first
 [[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
dracut.8.xml +0 -8
index ea24764..0dc6225 100644
@@ -371,14 +371,6 @@ Default:
         </varlistentry>
         <varlistentry>
           <term>
-            <option>--sshkey&nbsp;<replaceable>&lt;sshkey file&gt;</replaceable></option>
-          </term>
-          <listitem>
-            <para>ssh key file used with ssh-client module.</para>
-          </listitem>
-        </varlistentry>
-        <varlistentry>
-          <term>
             <option>-l</option>
           </term>
           <term>
Signature · 1 line
1.7.7.5
#12 lore raw
In reply to a message not in the archive

Hi,

Thanks for the effort, before test it I have two comments

Quoted 8 lines · On 01/10/2012 11:19 PM, [email protected]…

From: Cong Wang <[email protected]>

ssh-client module needs a specific parameter, --ssh-key, but this parameter is totally useless for other modules. So, introduce a way to let users to pass module-specific parameters, that is, using colons to separate module name and its parameters, like,

--add ssh-client:sshkey=/root/.ssh/kdump_id_rsa.pub

Seems no way to add param to modules which is not add explicitly such as simply run
./dracut -l

So also need to find way to add params to the implicit-added modules?

Quoted 14 lines
---
 dracut           |   30 ++++++++++++++++++++++++++----
 dracut-functions |   14 ++++++++++++--
 dracut.8.xml     |   22 ++++++++++++++++++----
 3 files changed, 56 insertions(+), 10 deletions(-)
dracut +0 -0
index 8fcdffe..f3fa257 100755

dracut push_arg() { · line 207

Quoted 9 lines
dracut +5 -0
@@ -199,6 +199,13 @@ push_arg() {
     fi
 }
 
+declare -A dracut_module_args
+read_module_args() {
+    local _key="${1%%:*}"
+    local _val="${1#*:}"
 
+    dracut_module_args["$_key"]="$_val"

[ -z "$_key" ] above will fail

Quoted 144 lines
dracut +2 -0
+}
+
 verbosity_mod_l=0
 

while (($# > 0)); do

dracut +19 -4
@@ -319,13 +326,23 @@ fi
 # these optins add to the stuff in the config file
 if (( ${#add_dracutmodules_l[@]} )); then
     while pop add_dracutmodules_l val; do
-        add_dracutmodules+=" $val "
+        if [[ "$val" =~ ":" ]]; then
+            add_dracutmodules+=" ${val%%:*} "
+            read_module_args "$val"
+        else
+            add_dracutmodules+=" $val "
+        fi
     done
 fi
 
 if (( ${#force_add_dracutmodules_l[@]} )); then
     while pop force_add_dracutmodules_l val; do
-        force_add_dracutmodules+=" $val "
+        if [[ "$val" =~ ":" ]]; then
+            force_add_dracutmodules+="${val%%:*} "
+            read_module_args "$val"
+        else
+            force_add_dracutmodules+=" $val "
+        fi
     done
 fi
 
@@ -364,7 +381,12 @@ fi
 if (( ${#dracutmodules_l[@]} )); then
     dracutmodules=''
     while pop dracutmodules_l val; do
-        dracutmodules+="$val "
+        if [[ "$val" =~ ":" ]]; then
+            dracutmodules+="${val%%:*} "
+            read_module_args "$val"
+        else
+            dracutmodules+="$val "
+        fi
     done
 fi
 
@@ -591,7 +613,7 @@ export initdir dracutbasedir dracutmodules drivers \
     add_drivers mdadmconf lvmconf filesystems \
     use_fstab libdir usrlibdir fscks nofscks cttyhack \
     stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
-    debug host_fs_types host_devs sshkey
+    debug host_fs_types host_devs sshkey dracut_module_args
 
 # Create some directory structure first
 [[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
dracut-functions +12 -2
index 3dd72e9..00f8309 100755
@@ -690,14 +690,24 @@ module_check() {
         # if we do not have a check script, we are unconditionally included
         [[ -x $_moddir/check ]] || return 0
         [ $_forced -ne 0 ] && unset hostonly
-        $_moddir/check $hostonly
+        if [ -n "${dracut_module_args["$1"]}" ]; then
+            local _l="${dracut_module_args["$1"]}"
+            eval "(${_l/:/;};$_moddir/check $hostonly;)"
+        else
+            $_moddir/check $hostonly
+        fi
         _ret=$?
     else
         unset check depends install installkernel
         . $_moddir/module-setup.sh
         is_func check || return 0
         [ $_forced -ne 0 ] && unset hostonly
-        check $hostonly
+        if [ -n "${dracut_module_args["$1"]}" ]; then
+            local _l="${dracut_module_args["$1"]}"
+            eval "(${_l/:/;};check $hostonly;)"
+        else
+            check $hostonly
+        fi
         _ret=$?
         unset check depends install installkernel
     fi
dracut.8.xml +18 -4
index 5a5df54..ea24764 100644
@@ -106,13 +106,14 @@ For a complete list of kernel command line options see
             <option>-m</option>
           </term>
           <term>
-            <option>--modules&nbsp;<replaceable>&lt;list of dracut modules&gt;</replaceable></option>
+            <option>--modules&nbsp;<replaceable>&lt;module1:para1=val1:para2=val2 module2 ...&gt;</replaceable></option>
           </term>
           <listitem>
             <para>specify a space-separated list of dracut modules to call
 when building the initramfs.
 Modules are located in
-<filename>/usr/lib/dracut/modules.d</filename>. This parameter can be specified multiple times.</para>
+<filename>/usr/lib/dracut/modules.d</filename>. This parameter can be specified multiple times.
+You can also pass module specific parameters here, using colons, for example, -m ssh-client:sshkey=/root/ssh-key.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
@@ -131,7 +132,7 @@ Modules are located in
             <option>-a</option>
           </term>
           <term>
-            <option>--add&nbsp;<replaceable>&lt;list of dracut modules&gt;</replaceable></option>
+            <option>--add&nbsp;<replaceable>&lt;module1:para1=val1:para2=val2 module2 ...&gt;</replaceable></option>
           </term>
           <listitem>
             <para>add a space-separated list of dracut modules to the default set of modules. This parameter can be specified multiple times.</para>
@@ -139,7 +140,7 @@ Modules are located in
         </varlistentry>
         <varlistentry>
           <term>
-            <option>--force-add&nbsp;<replaceable>&lt;list of dracut modules&gt;</replaceable></option>
+            <option>--force-add&nbsp;<replaceable>&lt;module1:para1=val1:para2=val2 module2 ...&gt;</replaceable></option>
           </term>
           <listitem>
             <para>force to add a space-separated list of dracut modules to the default set of modules, when -H is specified. This parameter can be specified multiple times.</para>
@@ -539,6 +540,19 @@ TARGET directory in the final initramfs. If SOURCE is a file, it will be install
         </varlistentry>
       </variablelist>
     </refsect2>
+    <refsect2>
+     <title>Module Specific Parameters</title>
+     <variablelist>
+        <varlistentry>
+          <term>
+            <option>ssh-client</option>
+          </term>
+          <listitem>
+            <para>sshkey=/path/to/sshkey (specifies the path to your ssh public key which will be used by ssh-client module)</para>
+          </listitem>
+       </varlistentry>
+      </variablelist>
+    </refsect2>
   </refsect1>
   <refsect1>
     <title>Files</title>
Signature · 2 lines
Thanks
Dave
#4 lore raw

Re: [PATCH 2/2] remove the global --sshkey parameter

In reply to a message not in the archive
Quoted 46 lines · On 01/10/2012 11:19 PM, [email protected]…

From: Cong Wang <[email protected]>

---
 dracut       |    4 +---
 dracut.8.xml |    8 --------
 2 files changed, 1 insertions(+), 11 deletions(-)
dracut +1 -3
index f3fa257..58c4fde 100755
@@ -118,7 +118,6 @@ Creates initial ramdisk images for preloading modules
   -M, --show-modules    Print included module's name to standard output during
                          build.
   --keep                Keep the temporary initramfs for debugging purposes
-  --sshkey [SSHKEY]     Add ssh key to initramfs (use with ssh-client module)
   --ctty                Add control tty for emergency shells
 EOF
 }
@@ -242,7 +241,6 @@ while (($# > 0)); do
         --debug)       debug="yes";;
         --profile)     profile="yes";;
         --ctty)        cttyhack="yes";;
-        --sshkey)      read_arg sshkey   "$@" || shift;;
         -v|--verbose)  ((verbosity_mod_l++));;
         -q|--quiet)    ((verbosity_mod_l--));;
         -l|--local)    allowlocal="yes" ;;
@@ -613,7 +611,7 @@ export initdir dracutbasedir dracutmodules drivers \
     add_drivers mdadmconf lvmconf filesystems \
     use_fstab libdir usrlibdir fscks nofscks cttyhack \
     stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
-    debug host_fs_types host_devs sshkey dracut_module_args
+    debug host_fs_types host_devs dracut_module_args
 
 # Create some directory structure first
 [[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
dracut.8.xml +0 -1
index ea24764..0dc6225 100644
@@ -371,14 +371,6 @@ Default:
         </varlistentry>
         <varlistentry>
           <term>
-            <option>--sshkey&nbsp;<replaceable>&lt;sshkey file&gt;</replaceable></option>

dracut.8.xml Default: · line 376

Quoted 10 lines
dracut.8.xml +0 -7
-          </term>
-          <listitem>
-            <para>ssh key file used with ssh-client module.</para>
-          </listitem>
-        </varlistentry>
-        <varlistentry>
-          <term>
             <option>-l</option>
           </term>
           <term>

Hi,

After removing --sshkey we need to parse dracut_module_args for module use. Maybe in a general function of dracut-lib will be fine.

Also need consider the multi-param case like below:
module:a=b,c=d,e=f,...

Ie. in ssh-client module we need to parse "sshkey=/root/.ssh/id_rsa" for installing sshkey

Signature · 2 lines
Thanks
Dave
#6 lore raw

Re: [PATCH 2/2] remove the global --sshkey parameter

In reply to a message not in the archive
Quoted 62 lines · Dave Young
Quoted 46 lines · On 01/10/2012 11:19 PM, [email protected]…

From: Cong Wang <[email protected]>

---
 dracut       |    4 +---
 dracut.8.xml |    8 --------
 2 files changed, 1 insertions(+), 11 deletions(-)
dracut +1 -3
index f3fa257..58c4fde 100755
@@ -118,7 +118,6 @@ Creates initial ramdisk images for preloading modules
   -M, --show-modules    Print included module's name to standard output during
                          build.
   --keep                Keep the temporary initramfs for debugging purposes
-  --sshkey [SSHKEY]     Add ssh key to initramfs (use with ssh-client module)
   --ctty                Add control tty for emergency shells
 EOF
 }
@@ -242,7 +241,6 @@ while (($# > 0)); do
         --debug)       debug="yes";;
         --profile)     profile="yes";;
         --ctty)        cttyhack="yes";;
-        --sshkey)      read_arg sshkey   "$@" || shift;;
         -v|--verbose)  ((verbosity_mod_l++));;
         -q|--quiet)    ((verbosity_mod_l--));;
         -l|--local)    allowlocal="yes" ;;
@@ -613,7 +611,7 @@ export initdir dracutbasedir dracutmodules drivers \
     add_drivers mdadmconf lvmconf filesystems \
     use_fstab libdir usrlibdir fscks nofscks cttyhack \
     stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
-    debug host_fs_types host_devs sshkey dracut_module_args
+    debug host_fs_types host_devs dracut_module_args
 
 # Create some directory structure first
 [[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
dracut.8.xml +0 -1
index ea24764..0dc6225 100644
@@ -371,14 +371,6 @@ Default:
         </varlistentry>
         <varlistentry>
           <term>
-            <option>--sshkey&nbsp;<replaceable>&lt;sshkey file&gt;</replaceable></option>

dracut.8.xml Default: · line 376

Quoted 10 lines
dracut.8.xml +0 -7
-          </term>
-          <listitem>
-            <para>ssh key file used with ssh-client module.</para>
-          </listitem>
-        </varlistentry>
-        <varlistentry>
-          <term>
             <option>-l</option>
           </term>
           <term>

Hi,

Quoted 9 lines

After removing --sshkey we need to parse dracut_module_args for module use. Maybe in a general function of dracut-lib will be fine.

Also need consider the multi-param case like below:
module:a=b,c=d,e=f,...

Ie. in ssh-client module we need to parse "sshkey=/root/.ssh/id_rsa" for installing sshkey

Seems $sshkey is only limited to check() function, so it will be not available in install(), should add something like below:

(quoted diff) +0 -0

b/modules.d/95ssh-client/module-setup.sh
index ef8effe..352817c 100755

modules.d/95ssh-client/module-setup.sh +3 -0
@@ -39,7 +39,10 @@ inst_sshenv()
     fi
 
     # Copy over ssh key and knowhosts if needed
+    ssharg=${dracut_module_args["ssh-client"]}
+    sshkey=`echo $ssharg|cut --fields=2 -d '='`
     [[ $sshkey ]] && {
+        echo "installing sshkey"
         inst $sshkey
         [[ -f /root/.ssh/known_hosts ]] && inst /root/.ssh/known_hosts
         [[ -f /etc/ssh/ssh_known_hosts ]] && inst /etc/ssh/ssh_known_hosts
Signature · 2 lines
Thanks
Dave
author
#7 lore raw

Re: [PATCH 2/2] remove the global --sshkey parameter

In reply to a message not in the archive
Quoted 2 lines · Dave Young

Hi,

Hi,

Quoted 10 lines

After removing --sshkey we need to parse dracut_module_args for module use. Maybe in a general function of dracut-lib will be fine.

Also need consider the multi-param case like below:
module:a=b,c=d,e=f,...

Ie. in ssh-client module we need to parse "sshkey=/root/.ssh/id_rsa" for installing sshkey

It is already done by the first patch. :)

Note that, I designed to use colons to separate parameters, not commas, even if you pass multiple parameters.

Thanks.

author
#14 lore raw
In reply to a message not in the archive
Quoted 13 lines · Dave Young

Hi,

Thanks for the effort, before test it I have two comments

Quoted 7 lines · On 01/10/2012 11:19 PM, [email protected]…

From: Cong Wang<[email protected]>

ssh-client module needs a specific parameter, --ssh-key, but this parameter is totally useless for other modules. So, introduce a way to let users to pass module-specific parameters, that is, using colons to separate module name and its parameters, like,

Quoted 8 lines
Quoted 1 line

--add ssh-client:sshkey=/root/.ssh/kdump_id_rsa.pub

Seems no way to add param to modules which is not add explicitly such as simply run
./dracut -l

So also need to find way to add params to the implicit-added modules?

I think you mean -H? Yeah, for cases like -H which selects modules automatically, I think we need to add an option in dracut.conf to let users specify the module parameters. I will add this...

Quoted 10 lines

dracut push_arg() {

Quoted 7 lines
dracut +5 -0
+declare -A dracut_module_args
+read_module_args() {
+    local _key="${1%%:*}"
+    local _val="${1#*:}"
 
+    dracut_module_args["$_key"]="$_val"

[ -z "$_key" ] above will fail

Yeah, but only when users forget the module name, right? :)

#9 lore raw

Re: [PATCH 2/2] remove the global --sshkey parameter

In reply to a message not in the archive
Quoted 10 lines · Cong Wang
Quoted 2 lines · Dave Young

Hi,

Hi,

Quoted 4 lines

After removing --sshkey we need to parse dracut_module_args for module use. Maybe in a general function of dracut-lib will be fine.

Quoted 8 lines
Quoted 6 lines

Also need consider the multi-param case like below:
module:a=b,c=d,e=f,...

Ie. in ssh-client module we need to parse "sshkey=/root/.ssh/id_rsa" for installing sshkey

It is already done by the first patch. :)

During my test, the $sshkey is only available in check() function, finally the key was not installed to initramfs. Please see my another reply
before.

Quoted 3 lines

Note that, I designed to use colons to separate parameters, not commas, even if you pass multiple parameters.

I think A:b,c,d looks better, but I have no strong opinion about this because right half of first colon can be seen as param which can be defined and parsed by specific module.

Signature · 2 lines
Thanks
Dave
#16 lore raw
In reply to a message not in the archive
Quoted 21 lines · Cong Wang
Quoted 20 lines · Dave Young

Hi,

Thanks for the effort, before test it I have two comments

Quoted 8 lines · On 01/10/2012 11:19 PM, [email protected]…

From: Cong Wang<[email protected]>

ssh-client module needs a specific parameter, --ssh-key, but this parameter is totally useless for other modules. So, introduce a way to let users to pass module-specific parameters, that is, using colons to separate module name and its parameters, like,

--add ssh-client:sshkey=/root/.ssh/kdump_id_rsa.pub

Seems no way to add param to modules which is not add explicitly such as simply run
./dracut -l

Quoted 6 lines
Quoted 1 line

So also need to find way to add params to the implicit-added modules?

I think you mean -H? Yeah, for cases like -H which selects modules automatically, I think we need to add an option in dracut.conf to let users specify the module parameters. I will add this...

I mean not only -H but also run dracut without any arguments

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
dracut +4 -0
+declare -A dracut_module_args
+read_module_args() {
+    local _key="${1%%:*}"
+    local _val="${1#*:}"
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

+ dracut_module_args["$_key"]="$_val"

[ -z "$_key" ] above will fail

Yeah, but only when users forget the module name, right? :)

Yes

Quoted 5 lines
Signature · 4 lines
-- 
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Thanks
Dave
author
#18 lore raw
In reply to a message not in the archive
Quoted 26 lines · Dave Young
Quoted 24 lines · Cong Wang
Quoted 21 lines · Dave Young

Hi,

Thanks for the effort, before test it I have two comments

Quoted 8 lines · On 01/10/2012 11:19 PM, [email protected]…

From: Cong Wang<[email protected]>

ssh-client module needs a specific parameter, --ssh-key, but this parameter is totally useless for other modules. So, introduce a way to let users to pass module-specific parameters, that is, using colons to separate module name and its parameters, like,

--add ssh-client:sshkey=/root/.ssh/kdump_id_rsa.pub

Seems no way to add param to modules which is not add explicitly such as simply run
./dracut -l

So also need to find way to add params to the implicit-added modules?

Quoted 6 lines
Quoted 3 lines

I think you mean -H? Yeah, for cases like -H which selects modules automatically, I think we need to add an option in dracut.conf to let users specify the module parameters. I will add this...

I mean not only -H but also run dracut without any arguments

Understand.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
(quoted diff) +5 -0
+declare -A dracut_module_args
+read_module_args() {
+    local _key="${1%%:*}"
+    local _val="${1#*:}"
 
+    dracut_module_args["$_key"]="$_val"
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

[ -z "$_key" ] above will fail

Yeah, but only when users forget the module name, right? :)

Yes

Then it is invalid input. :-D But yeah, we could handle this in a better way.

I will update the patch.

author
#11 lore raw

Re: [PATCH 2/2] remove the global --sshkey parameter

In reply to a message not in the archive
Quoted 19 lines · Dave Young
Quoted 17 lines · Cong Wang
Quoted 2 lines · Dave Young

Hi,

Hi,

Quoted 10 lines

After removing --sshkey we need to parse dracut_module_args for module use. Maybe in a general function of dracut-lib will be fine.

Also need consider the multi-param case like below:
module:a=b,c=d,e=f,...

Ie. in ssh-client module we need to parse "sshkey=/root/.ssh/id_rsa" for installing sshkey

Quoted 6 lines
Quoted 1 line

It is already done by the first patch. :)

During my test, the $sshkey is only available in check() function, finally the key was not installed to initramfs. Please see my another reply
before.

Hmm, so sshkey= parameter should be passed to both check() and install()... I think I need to redesign the command line interface.

Quoted 10 lines
Quoted 4 lines

Note that, I designed to use colons to separate parameters, not commas, even if you pass multiple parameters.

I think A:b,c,d looks better, but I have no strong opinion about this because right half of first colon can be seen as param which can be defined and parsed by specific module.

Makes sense, I will check if this is hard to be done.

#19 lore raw
In reply to a message not in the archive

Am 10.01.2012 16:19, schrieb [email protected]:

Quoted 9 lines

From: Cong Wang <[email protected]>

ssh-client module needs a specific parameter, --ssh-key, but this parameter is totally useless for other modules. So, introduce a way to let users to pass module-specific parameters, that is, using colons to separate module name and its parameters, like,

--add ssh-client:sshkey=/root/.ssh/kdump_id_rsa.pub

Quoted 7 lines
---
 dracut           |   30 ++++++++++++++++++++++++++----
 dracut-functions |   14 ++++++++++++--
 dracut.8.xml     |   22 ++++++++++++++++++----
 3 files changed, 56 insertions(+), 10 deletions(-)

Hmm, I would envision another strategy here. Modules could provide a function for command line parsing.

We could source each module-setup.sh and rename the functions prefixed with the module name and store them in an array.

Function renaming could be done via:

$ theirfunc() { echo "do their thing"; }
$ eval "$(echo "orig_theirfunc()"; declare -f theirfunc | tail -n +2)"
$ theirfunc() { echo "do my thing"; orig_theirfunc; }
$ theirfunc
do my thing
do their thing

What do you think?

author
#21 lore raw
In reply to a message not in the archive
Quoted 6 lines · Harald Hoyer

Hmm, I would envision another strategy here. Modules could provide a function for command line parsing.

We could source each module-setup.sh and rename the functions prefixed with the module name and store them in an array.

Sorry, I don't quite understand. For this case, you mean ssh-client module should provide a function like ssh-client_getopt() to parse the command line --add ssh-client:sshkey=/root/.ssh/kdump_id_rsa.pub ?

Thanks.