From f12076fa6117159c78c1f001ca05e6519aa9b767 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Tue, 15 Oct 2019 10:54:13 -0700 Subject: [PATCH] vstart: redirect some output to stderr Signed-off-by: Patrick Donnelly --- src/vstart.sh | 95 ++++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/src/vstart.sh b/src/vstart.sh index ff1fbb51cf4..8ed75cfc15a 100755 --- a/src/vstart.sh +++ b/src/vstart.sh @@ -5,6 +5,36 @@ # abort on failure set -e +quoted_print() { + for s in "$@"; do + if [[ "$s" =~ \ ]]; then + printf -- "'%s' " "$s" + else + printf -- "$s " + fi + done + printf '\n' +} + +debug() { + if [ -w /dev/tty -a ! -t 2 ]; then + "$@" | tee /dev/tty >&2 + else + "$@" >&2 + fi +} + +prunb() { + debug quoted_print "$@" '&' + "$@" & +} + +prun() { + debug quoted_print "$@" + "$@" +} + + if [ -n "$VSTART_DEST" ]; then SRC_PATH=`dirname $0` SRC_PATH=`(cd $SRC_PATH; pwd)` @@ -147,7 +177,7 @@ pci_id="" with_mgr_dashboard=true if [[ "$(get_cmake_variable WITH_MGR_DASHBOARD_FRONTEND)" != "ON" ]] || [[ "$(get_cmake_variable WITH_RBD)" != "ON" ]]; then - echo "ceph-mgr dashboard not built - disabling." + debug echo "ceph-mgr dashboard not built - disabling." with_mgr_dashboard=false fi @@ -466,35 +496,6 @@ fi ARGS="-c $conf_fn" -quoted_print() { - for s in "$@"; do - if [[ "$s" =~ \ ]]; then - printf -- "'%s' " "$s" - else - printf -- "$s " - fi - done - printf '\n' -} - -debug() { - if [ -w /dev/tty -a ! -t 2 ]; then - "$@" | tee /dev/tty >&2 - else - "$@" >&2 - fi -} - -prunb() { - debug quoted_print "$@" '&' - "$@" & -} - -prun() { - debug quoted_print "$@" - "$@" -} - run() { type=$1 shift @@ -942,7 +943,7 @@ EOF MGR_PORT=$(($MGR_PORT + 1000)) fi - echo "Starting mgr.${name}" + debug echo "Starting mgr.${name}" run 'mgr' $name $CEPH_BIN/ceph-mgr -i $name $ARGS done @@ -950,19 +951,19 @@ EOF # setting login credentials for dashboard if $with_mgr_dashboard; then while ! ceph_adm -h | grep -c -q ^dashboard ; do - echo 'waiting for mgr dashboard module to start' + debug echo 'waiting for mgr dashboard module to start' sleep 1 done ceph_adm dashboard ac-user-create admin admin administrator if [ "$ssl" != "0" ]; then if ! ceph_adm dashboard create-self-signed-cert; then - echo dashboard module not working correctly! + debug echo dashboard module not working correctly! fi fi fi while ! ceph_adm -h | grep -c -q ^restful ; do - echo 'waiting for mgr restful module to start' + debug echo 'waiting for mgr restful module to start' sleep 1 done if ceph_adm restful create-self-signed-cert; then @@ -971,12 +972,12 @@ EOF RESTFUL_SECRET=`cat $SF` rm $SF else - echo MGR Restful is not working, perhaps the package is not installed? + debug echo MGR Restful is not working, perhaps the package is not installed? fi fi if [ "$ssh" -eq 1 ]; then - echo Enabling ssh orchestrator + debug echo Enabling ssh orchestrator ceph_adm config-key set mgr/ssh/ssh_identity_key -i ~/.ssh/id_rsa ceph_adm config-key set mgr/ssh/ssh_identity_pub -i ~/.ssh/id_rsa.pub ceph_adm mgr module enable ssh @@ -1056,7 +1057,7 @@ if [ "$debug" -eq 0 ]; then debug mon = 10 debug ms = 1' else - echo "** going verbose **" + debug echo "** going verbose **" CMONDEBUG=' debug mon = 20 debug paxos = 20 @@ -1141,7 +1142,7 @@ fi if [ $CEPH_NUM_MON -gt 0 ]; then start_mon - echo Populating config ... + debug echo Populating config ... cat < /dev/null # Create S3-test users # See: https://github.com/ceph/s3-tests - echo "setting up s3-test users" + debug echo "setting up s3-test users" $CEPH_BIN/radosgw-admin user create \ --uid 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef \ --access-key ABCDEFGHIJKLMNOPQRST \ @@ -1314,7 +1315,7 @@ do_rgw_create_users() --email tenanteduser@example.com -c $conf_fn > /dev/null # Create Swift user - echo "setting up user tester" + debug echo "setting up user tester" $CEPH_BIN/radosgw-admin user create -c $conf_fn --subuser=test:tester --display-name=Tester-Subuser --key-type=swift --secret=testing --access=full > /dev/null echo "" @@ -1334,7 +1335,7 @@ do_rgw() if [ "$new" -eq 1 ]; then do_rgw_create_users if [ -n "$rgw_compression" ]; then - echo "setting compression type=$rgw_compression" + debug echo "setting compression type=$rgw_compression" $CEPH_BIN/radosgw-admin zone placement modify -c $conf_fn --rgw-zone=default --placement-id=default-placement --compression=$rgw_compression > /dev/null fi fi @@ -1364,7 +1365,7 @@ do_rgw() mgr 'allow rw' \ >> "$keyring_fn" - echo start rgw on http${CEPH_RGW_HTTPS}://localhost:${current_port} + debug echo start rgw on http${CEPH_RGW_HTTPS}://localhost:${current_port} run 'rgw' $current_port $RGWSUDO $CEPH_BIN/radosgw -c $conf_fn \ --log-file=${CEPH_OUT_DIR}/radosgw.${current_port}.log \ --admin-socket=${CEPH_OUT_DIR}/radosgw.${current_port}.asok \ @@ -1383,7 +1384,7 @@ if [ "$CEPH_NUM_RGW" -gt 0 ]; then do_rgw fi -echo "started. stop.sh to stop. see out/* (e.g. 'tail -f out/????') for debug output." +debug echo "vstart cluster complete. Use stop.sh to stop. See out/* (e.g. 'tail -f out/????') for debug output." echo "" if [ "$new" -eq 1 ]; then -- 2.39.5