See the following patch which adds the '-C' option to setup-storage.
This allows a dry-run to output the shell commands to be used by the script.

Paul
From 8e3ba3dd0898d0df59281f20d636eb47d68509c1 Mon Sep 17 00:00:00 2001
From: Paul Schulz <p...@mawsonlakes.org>
Date: Fri, 16 Sep 2016 14:22:59 +0930
Subject: [PATCH] Add option to output script commands '-C'

---
 bin/setup-storage         | 9 +++++++--
 lib/setup-storage/Exec.pm | 3 +++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/bin/setup-storage b/bin/setup-storage
index a3aeca3..b973a1e 100755
--- a/bin/setup-storage
+++ b/bin/setup-storage
@@ -59,8 +59,8 @@ $|=1;
 use Getopt::Std;
 $main::VERSION = $version;
 $Getopt::Std::STANDARD_HELP_VERSION = 1;
-our ($opt_X, $opt_f, $opt_h, $opt_d, $opt_s, $opt_D, $opt_L); # the variables for getopt
-(&getopts('Xf:hdsD:L:') && !$opt_h) || die <<EOF;
+our ($opt_X, $opt_f, $opt_h, $opt_d, $opt_s, $opt_D, $opt_L,$opt_C); # the variables for getopt
+(&getopts('Xf:hdsD:L:C') && !$opt_h) || die <<EOF;
 setup-storage version $version
 
 USAGE: [-X]                     no test, your harddisks will be formated
@@ -71,6 +71,7 @@ USAGE: [-X]                     no test, your harddisks will be formated
        [-D<disks>]              override disklist variable by space-separated <disks>
        [-L<logdir>]             use <logdir> instead of LOGDIR variable
        [-h]                     print this help message
+       [-C]                     script command output
 EOF
 
 # include all subparts, which are part of the FAI perl package
@@ -90,6 +91,10 @@ $opt_d and $FAI::debug = 1;
 $opt_X and $FAI::no_dry_run = 1;
 warn "setup-storage is running in test-only mode\n" unless ($FAI::no_dry_run);
 
+# Write script commands
+$opt_C and $FAI::script_output = 1;
+warn "setup-storage is writing script commands\n" unless ($FAI::script_output);
+
 # syntactic checks only
 $opt_s and $FAI::check_only = 1;
 
diff --git a/lib/setup-storage/Exec.pm b/lib/setup-storage/Exec.pm
index 5381a31..68c4a29 100755
--- a/lib/setup-storage/Exec.pm
+++ b/lib/setup-storage/Exec.pm
@@ -359,6 +359,9 @@ sub execute_command_internal {
     print "Executing: $command\n" if $prt;
     `$command 1> $stdout_filename 2> $stderr_filename`;
     $exit_code = ($?>>8);
+  } elsif($FAI::script_output) {
+    print "$command\n";
+    return "";
   } else {
     print "would run command $command; to have it executed, use -X \n";
     return "";
-- 
2.7.4

Antwort per Email an