From 03abc1d1f8e4dd9d8536c3408c53d3d683071cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roni=20V=C3=A4yrynen?= Date: Sat, 1 Jan 2022 19:09:31 +0200 Subject: [PATCH] styling: fix shfmt issues --- .editorconfig | 2 +- xo-install.sh | 374 ++++++++++++++++++++++++------------------------ xo-vm-import.sh | 30 ++-- 3 files changed, 203 insertions(+), 203 deletions(-) diff --git a/.editorconfig b/.editorconfig index 47cced3..9941469 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,5 +5,5 @@ tab_width = 8 end_of_line = lf trim_trailing_whitespace = true insert_final_newline = true -function_next_line = true +function_next_line = false switch_case_indent = true diff --git a/xo-install.sh b/xo-install.sh index 399d3fc..8621d11 100755 --- a/xo-install.sh +++ b/xo-install.sh @@ -595,14 +595,14 @@ function PrepInstall { read -r -p "[y/N]: " answer answer="${answer:-n}" case "$answer" in - y) - : - ;; - n) - printinfo "Cleaning up install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME" - runcmd "rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME" - exit 0 - ;; + y) + : + ;; + n) + printinfo "Cleaning up install directory: $INSTALLDIR/xo-builds/xen-orchestra-$TIME" + runcmd "rm -rf $INSTALLDIR/xo-builds/xen-orchestra-$TIME" + exit 0 + ;; esac else printinfo "No changes to $XO_SVC_DESC since previous install. Skipping build. Use the --force to update anyway." @@ -984,36 +984,36 @@ function HandleArgs { while true; do case "$1" in - --force) - shift - FORCE="true" - ;; - --update) - shift - local UPDATEARG=1 - TASK="Update" - ;; - --install) - shift - local INSTALLARG=1 - TASK="Installation" - ;; - --rollback) - shift - local ROLLBACKARG=1 - ;; - --proxy) - shift - local PROXYARG=1 - ;; - --) - shift - break - ;; - *) - shift - break - ;; + --force) + shift + FORCE="true" + ;; + --update) + shift + local UPDATEARG=1 + TASK="Update" + ;; + --install) + shift + local INSTALLARG=1 + TASK="Installation" + ;; + --rollback) + shift + local ROLLBACKARG=1 + ;; + --proxy) + shift + local PROXYARG=1 + ;; + --) + shift + break + ;; + *) + shift + break + ;; esac done @@ -1079,18 +1079,18 @@ function RollBackInstallation { echo "3. Exit" read -r -p ": " answer case $answer in - 1) - XO_SVC="xo-server" - ;; - 2) - XO_SVC="xo-proxy" - ;; - 3) - exit - ;; - *) - exit - ;; + 1) + XO_SVC="xo-server" + ;; + 2) + XO_SVC="xo-proxy" + ;; + 3) + exit + ;; + *) + exit + ;; esac else XO_SVC="xo-proxy" @@ -1105,36 +1105,36 @@ function RollBackInstallation { local INSTALLATION select INSTALLATION in "${INSTALLATIONS[@]}"; do case $INSTALLATION in - *xen-orchestra*) - echo - if [[ "$XO_SVC" == "xo-server" ]]; then - printinfo "Setting $INSTALLDIR/xo-server symlink to $INSTALLATION/packages/xo-server" - runcmd "ln -sfn $INSTALLATION/packages/xo-server $INSTALLDIR/xo-server" - printinfo "Setting $INSTALLDIR/xo-web symlink to $INSTALLATION/packages/xo-web" - runcmd "ln -sfn $INSTALLATION/packages/xo-web $INSTALLDIR/xo-web" + *xen-orchestra*) echo - printinfo "Replacing xo.server.service systemd configuration file" - runcmd "/bin/cp -f $INSTALLATION/packages/xo-server/xo-server.service /etc/systemd/system/xo-server.service" - runcmd "/bin/systemctl daemon-reload" - echo - printinfo "Restarting xo-server..." - runcmd "/bin/systemctl restart xo-server" - echo - break - fi - if [[ "$XO_SVC" == "xo-proxy" ]]; then - printinfo "Setting $INSTALLDIR/xo-proxy symlink to $INSTALLATION/@xen-orchestra/proxy" - runcmd "ln -sfn $INSTALLATION/@xen-orchestra/proxy $INSTALLDIR/xo-proxy" - echo - printinfo "Restating xo-proxy..." - runcmd "/bin/systemctl restart xo-proxy" - echo - break - fi - ;; - *) - printfail "Try again" - ;; + if [[ "$XO_SVC" == "xo-server" ]]; then + printinfo "Setting $INSTALLDIR/xo-server symlink to $INSTALLATION/packages/xo-server" + runcmd "ln -sfn $INSTALLATION/packages/xo-server $INSTALLDIR/xo-server" + printinfo "Setting $INSTALLDIR/xo-web symlink to $INSTALLATION/packages/xo-web" + runcmd "ln -sfn $INSTALLATION/packages/xo-web $INSTALLDIR/xo-web" + echo + printinfo "Replacing xo.server.service systemd configuration file" + runcmd "/bin/cp -f $INSTALLATION/packages/xo-server/xo-server.service /etc/systemd/system/xo-server.service" + runcmd "/bin/systemctl daemon-reload" + echo + printinfo "Restarting xo-server..." + runcmd "/bin/systemctl restart xo-server" + echo + break + fi + if [[ "$XO_SVC" == "xo-proxy" ]]; then + printinfo "Setting $INSTALLDIR/xo-proxy symlink to $INSTALLATION/@xen-orchestra/proxy" + runcmd "ln -sfn $INSTALLATION/@xen-orchestra/proxy $INSTALLDIR/xo-proxy" + echo + printinfo "Restating xo-proxy..." + runcmd "/bin/systemctl restart xo-proxy" + echo + break + fi + ;; + *) + printfail "Try again" + ;; esac done @@ -1278,15 +1278,15 @@ function CheckMemory { fi read -r -p "continue anyway? y/N: " answer case $answer in - y) - : - ;; - n) - exit 0 - ;; - *) - exit 0 - ;; + y) + : + ;; + n) + exit 0 + ;; + *) + exit 0 + ;; esac fi @@ -1304,15 +1304,15 @@ function CheckDiskFree { fi read -r -p "continue anyway? y/N: " answer case $answer in - y) - : - ;; - n) - exit 0 - ;; - *) - exit 0 - ;; + y) + : + ;; + n) + exit 0 + ;; + *) + exit 0 + ;; esac fi } @@ -1353,105 +1353,105 @@ function StartUpScreen { read -r -p ": " option case $option in - 1) - if [[ $(runcmd_stdout "pgrep -f xo-server") ]]; then - echo "Looks like xo-server process is already running, consider running update instead. Continue anyway?" - read -r -p "[y/N]: " answer - case $answer in - y) - echo "Stopping xo-server..." - runcmd "/bin/systemctl stop xo-server" || - { - printfail "failed to stop service, exiting..." - exit 1 - } - ;; - n) + 1) + if [[ $(runcmd_stdout "pgrep -f xo-server") ]]; then + echo "Looks like xo-server process is already running, consider running update instead. Continue anyway?" + read -r -p "[y/N]: " answer + case $answer in + y) + echo "Stopping xo-server..." + runcmd "/bin/systemctl stop xo-server" || + { + printfail "failed to stop service, exiting..." + exit 1 + } + ;; + n) + exit 0 + ;; + *) + exit 0 + ;; + esac + fi + + TASK="Installation" + XO_SVC="xo-server" + + if [ "$PKG_FORMAT" == "rpm" ]; then + InstallDependenciesRPM + InstallXO exit 0 - ;; - *) + fi + if [ "$PKG_FORMAT" == "deb" ]; then + InstallDependenciesDeb + InstallXO exit 0 - ;; - esac - fi - - TASK="Installation" - XO_SVC="xo-server" - - if [ "$PKG_FORMAT" == "rpm" ]; then - InstallDependenciesRPM - InstallXO + fi + ;; + 2) + TASK="Update" + XO_SVC="xo-server" + UpdateNodeYarn + UpdateXO exit 0 - fi - if [ "$PKG_FORMAT" == "deb" ]; then - InstallDependenciesDeb - InstallXO + ;; + 3) + RollBackInstallation exit 0 - fi - ;; - 2) - TASK="Update" - XO_SVC="xo-server" - UpdateNodeYarn - UpdateXO - exit 0 - ;; - 3) - RollBackInstallation - exit 0 - ;; - 4) - if [[ $(runcmd_stdout "pgrep -f xo-proxy") ]]; then - echo "Looks like xo-proxy process is already running, consider running update instead. Continue anyway?" - read -r -p "[y/N]: " answer - case $answer in - y) - echo "Stopping xo-proxy..." - runcmd "/bin/systemctl stop xo-proxy" || - { - printfail "failed to stop service, exiting..." - exit 1 - } - ;; - n) + ;; + 4) + if [[ $(runcmd_stdout "pgrep -f xo-proxy") ]]; then + echo "Looks like xo-proxy process is already running, consider running update instead. Continue anyway?" + read -r -p "[y/N]: " answer + case $answer in + y) + echo "Stopping xo-proxy..." + runcmd "/bin/systemctl stop xo-proxy" || + { + printfail "failed to stop service, exiting..." + exit 1 + } + ;; + n) + exit 0 + ;; + *) + exit 0 + ;; + esac + fi + + TASK="Installation" + XO_SVC="xo-proxy" + + if [[ "$PKG_FORMAT" == "rpm" ]]; then + InstallDependenciesRPM + InstallXOProxy exit 0 - ;; - *) + fi + if [[ "$PKG_FORMAT" == "deb" ]]; then + InstallDependenciesDeb + InstallXOProxy exit 0 - ;; - esac - fi + fi + ;; - TASK="Installation" - XO_SVC="xo-proxy" - - if [[ "$PKG_FORMAT" == "rpm" ]]; then - InstallDependenciesRPM - InstallXOProxy + 5) + TASK="Update" + XO_SVC="xo-proxy" + UpdateNodeYarn + UpdateXO exit 0 - fi - if [[ "$PKG_FORMAT" == "deb" ]]; then - InstallDependenciesDeb - InstallXOProxy + ;; + 6) exit 0 - fi - ;; - - 5) - TASK="Update" - XO_SVC="xo-proxy" - UpdateNodeYarn - UpdateXO - exit 0 - ;; - 6) - exit 0 - ;; - *) - echo "Please choose one of the options" - echo - exit 0 - ;; + ;; + *) + echo "Please choose one of the options" + echo + exit 0 + ;; esac } diff --git a/xo-vm-import.sh b/xo-vm-import.sh index d823803..6334807 100755 --- a/xo-vm-import.sh +++ b/xo-vm-import.sh @@ -45,11 +45,11 @@ function NetworkChoose { # print a menu where to choose network from case $network in - *) - # save network uuid for later - vifuuid="$networkuuid" - break - ;; + *) + # save network uuid for later + vifuuid="$networkuuid" + break + ;; esac done @@ -81,16 +81,16 @@ function StorageChoose { # print a menu where to choose storage from case $storage in - default) - # this value is handled during import if set to default - sruuid=default - break - ;; - *) - # save storage uuid for later - sruuid=$storageuuid - break - ;; + default) + # this value is handled during import if set to default + sruuid=default + break + ;; + *) + # save storage uuid for later + sruuid=$storageuuid + break + ;; esac done