diff --git a/extra/tarantool_expand.sh b/extra/tarantool_expand.sh index dec14581583f8b0fdc72f1b5289d9ef0d663447e..489d133c211ef0a87ec50f3cc89bac5939fc94f5 100755 --- a/extra/tarantool_expand.sh +++ b/extra/tarantool_expand.sh @@ -43,7 +43,7 @@ error() { } log() { - echo "$prompt_name > $*" + echo "$prompt_name: $*" } usage() { @@ -64,6 +64,12 @@ usage() { exit $1 } +is_numeric() { + num=$1 + [ $num -eq $num ] 2>/dev/null && [ $num -ge 0 ] 2>/dev/null || \ + return 1 +} + rollback_instance() { id=$1 workdir="${prefix_var}/tarantool$id" @@ -166,6 +172,10 @@ deploy_current=0 if [ -f $deploy_cfg ]; then deploy_exists=1 deploy_current=`cat $deploy_cfg` + [ $? -eq 0 ] || error "failed to read deploy config" + # validating instance number + is_numeric $deploy_current + [ $? -eq 0 ] || error "bad deploy config instance number" # dont' change deploy if it said so in configuration file if [ $deploy_current -eq 0 ]; then log "skipping deploy setup (cancel by config)" @@ -184,8 +194,8 @@ if [ $act_status -ne 0 ]; then fi # validating instance number -[ $deploy_count -eq $deploy_count ] 2>/dev/null && [ $deploy_count -gt 0 ] || \ - error "bad instance number" +is_numeric $deploy_count +[ $? -eq 0 ] && [ $deploy_count -gt 0 ] || error "bad instance number" if [ $deploy_count -le $deploy_current ]; then error "expand only is supported (required instances number $deploy_count" \