From 034a80d44eea827cfa31da05db95dcb843e73aba Mon Sep 17 00:00:00 2001 From: eleksir Date: Sun, 4 Sep 2016 23:02:01 +0300 Subject: [PATCH] cleanup cloud3p.sh --- cloud3p.sh | 59 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/cloud3p.sh b/cloud3p.sh index be978f2..3191342 100755 --- a/cloud3p.sh +++ b/cloud3p.sh @@ -1,49 +1,48 @@ #!/bin/sh -EXE_CLOUD3P=/usr/sbin/cloud3p -DIR_VAULT_CONF=/etc/config/vaultServices -SZF_VAULT_CONF=vaultServices.config -SZP_VAULT_CONF_DEF=/etc/default_config/vaultServices/vaultServices.config +EXE_CLOUD3P="/usr/sbin/cloud3p" +DIR_VAULT_CONF="/etc/config/vaultServices" +SZF_VAULT_CONF="vaultServices.config" +SZP_VAULT_CONF_DEF="/etc/default_config/vaultServices/vaultServices.config" -start() -{ - if [ -f $EXE_CLOUD3P ]; then +start() { + if [ -f "$EXE_CLOUD3P" ]; then echo "Startup all cloud related services..." - [ -d $DIR_VAULT_CONF ] || /usr/bin/install -d $DIR_VAULT_CONF - if [ ! -f $DIR_VAULT_CONF/$SZF_VAULT_CONF ] && [ -f $SZP_VAULT_CONF_DEF ]; then - /bin/cp -p $SZP_VAULT_CONF_DEF $DIR_VAULT_CONF/$SZF_VAULT_CONF + [ -d "$DIR_VAULT_CONF" ] || mkdir "$DIR_VAULT_CONF" + + if [ ! -f "$DIR_VAULT_CONF/$SZF_VAULT_CONF" ] && [ -f "$SZP_VAULT_CONF_DEF" ]; then + /bin/cp -p "$SZP_VAULT_CONF_DEF" "$DIR_VAULT_CONF/$SZF_VAULT_CONF" fi - $EXE_CLOUD3P --start + + "$EXE_CLOUD3P" --start fi } -stop() -{ - if [ -f $EXE_CLOUD3P ]; then +stop(){ + if [ -f "$EXE_CLOUD3P" ]; then echo "Shutting down all cloud related services..." - $EXE_CLOUD3P --stop + "$EXE_CLOUD3P" --stop fi } case "$1" in + "start") + start + ;; -start) - start + "stop") + stop + ;; + + "restart") + stop + sleep 1 + start ;; -stop) - stop - ;; - -restart) - stop - sleep 1 - start - ;; - -*) - echo "Usage: /etc/init.d/cloud3p.sh {start|stop|restart}" - exit 1 + *) + echo "Usage: /etc/init.d/cloud3p.sh {start|stop|restart}" + exit 1 esac exit 0