From 362ccec7a61834325035d87b77bf1de9c75f97e4 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 24 Dec 2020 22:16:52 +0800 Subject: [PATCH] vstart: format the customized options in ceph.conf better formatted in ceph.conf, no extra spaces and tabs anymore. Signed-off-by: Kefu Chai --- src/vstart.sh | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/src/vstart.sh b/src/vstart.sh index b3f8993c20c..21f26b851a1 100755 --- a/src/vstart.sh +++ b/src/vstart.sh @@ -408,8 +408,7 @@ case $1 in shift ;; -o) - extra_conf="$extra_conf $2 -" + extra_conf+=$'\n'"$2" shift ;; --cache) @@ -549,6 +548,21 @@ done } +format_conf() { + local opts=$1 + local indent=" " + local opt + local formatted + while read -r opt; do + if [ -z "$formatted" ]; then + formatted="${opt}" + else + formatted+=$'\n'${indent}${opt} + fi + done <<< "$opts" + echo "$formatted" +} + prepare_conf() { local DAEMONOPTS=" log file = $CEPH_OUT_DIR/\$name.log @@ -565,22 +579,16 @@ prepare_conf() { local msgr_conf='' if [ $msgr -eq 21 ]; then - msgr_conf=" - ms bind msgr2 = true - ms bind msgr1 = true -"; + msgr_conf="ms bind msgr2 = true + ms bind msgr1 = true" fi if [ $msgr -eq 2 ]; then - msgr_conf=" - ms bind msgr2 = true - ms bind msgr1 = false -"; + msgr_conf="ms bind msgr2 = true + ms bind msgr1 = false" fi if [ $msgr -eq 1 ]; then - msgr_conf=" - ms bind msgr2 = false - ms bind msgr1 = true -"; + msgr_conf="ms bind msgr2 = false + ms bind msgr1 = true" fi wconf <