From 0887ea42e2e5585580d4a8a387f24ad6dafb091e Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Tue, 15 Oct 2019 10:41:06 -0700 Subject: [PATCH] vstart: output command strings to stderr This allows redirecting prun/prunb to a file without using another function. Also, write to the terminal if stderr is redirected to give a visual glimpse of vstart's progress. Signed-off-by: Patrick Donnelly --- src/vstart.sh | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/vstart.sh b/src/vstart.sh index 6fd3748e461..ff1fbb51cf4 100755 --- a/src/vstart.sh +++ b/src/vstart.sh @@ -477,23 +477,24 @@ quoted_print() { printf '\n' } +debug() { + if [ -w /dev/tty -a ! -t 2 ]; then + "$@" | tee /dev/tty >&2 + else + "$@" >&2 + fi +} + prunb() { - quoted_print "$@" '&' + debug quoted_print "$@" '&' "$@" & } prun() { - quoted_print "$@" + debug quoted_print "$@" "$@" } -prun_to_file() { - f=$1 - shift - quoted_print "$@" - "$@" >> $f -} - run() { type=$1 shift @@ -1128,17 +1129,6 @@ ceph_adm() { fi } -ceph_adm_to_file() { - f=$1 - shift - - if [ "$cephx" -eq 1 ]; then - prun_to_file $f $SUDO "$CEPH_ADM" -c "$conf_fn" -k "$keyring_fn" "$@" - else - prun_to_file $f $SUDO "$CEPH_ADM" -c "$conf_fn" "$@" - fi -} - if [ $inc_osd_num -gt 0 ]; then start_osd exit @@ -1368,10 +1358,11 @@ do_rgw() for n in $(seq 1 $CEPH_NUM_RGW); do rgw_name="client.rgw.${current_port}" - ceph_adm_to_file $keyring_fn auth get-or-create $rgw_name \ + ceph_adm auth get-or-create $rgw_name \ mon 'allow rw' \ osd 'allow rwx' \ mgr 'allow rw' \ + >> "$keyring_fn" echo start rgw on http${CEPH_RGW_HTTPS}://localhost:${current_port} run 'rgw' $current_port $RGWSUDO $CEPH_BIN/radosgw -c $conf_fn \ -- 2.39.5