From e0fe225b67b04cc8185d2fff3bab945ffaff8f3d Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Wed, 15 May 2019 16:33:09 +0200 Subject: [PATCH 1/2] lock-cable.sh doesn't choose the color anymore --- lock-cable.sh | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/lock-cable.sh b/lock-cable.sh index 11627fe..cf42c80 100755 --- a/lock-cable.sh +++ b/lock-cable.sh @@ -26,35 +26,25 @@ # Exit status # - 0 : Lock file created for cable # - 101 : CABLES_LOCKED_FOLDER missing +# - 102 : CABLE_COLOR missing +# - 103 : cable already locked CABLES_LOCKED_FOLDER=$1 +CABLE_COLOR=$2 if [ -z $CABLES_LOCKED_FOLDER ] then exit 101 fi -while [ -z ${CABLE} ] -do - - sleep 1 - - if [ -f ${CABLES_LOCKED_FOLDER}/blue.lock ] && [ -f ${CABLES_LOCKED_FOLDER}/red.lock ] && [ -f ${CABLES_LOCKED_FOLDER}/green.lock ] - then - continue - fi - - CABLE=blue - - if [ -f ${CABLES_LOCKED_FOLDER}/red.lock ] && [ ! -f ${CABLES_LOCKED_FOLDER}/green.lock ] - then - CABLE=green - elif [ -f ${CABLES_LOCKED_FOLDER}/blue.lock ] && [ ! -f ${CABLES_LOCKED_FOLDER}/red.lock ] - then - CABLE=red - fi +if [ -z $CABLE_COLOR ] +then + exit 102 +fi -done +if [ -f ${CABLES_LOCKED_FOLDER}/${CABLE_COLOR}.lock ] +then + exit 103 +fi -echo ${CABLE} -mkdir -p ${CABLES_LOCKED_FOLDER} && touch ${CABLES_LOCKED_FOLDER}/${CABLE}.lock +touch ${CABLES_LOCKED_FOLDER}/${CABLE_COLOR}.lock -- GitLab From 0d45786cf5855b45a4bd7622e8f77cccf4b52b3c Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Fri, 17 May 2019 11:07:37 +0200 Subject: [PATCH 2/2] Fix missing folder creation --- lock-cable.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lock-cable.sh b/lock-cable.sh index cf42c80..1a42ab3 100755 --- a/lock-cable.sh +++ b/lock-cable.sh @@ -47,4 +47,4 @@ then exit 103 fi -touch ${CABLES_LOCKED_FOLDER}/${CABLE_COLOR}.lock +mkdir -p ${CABLES_LOCKED_FOLDER} && touch ${CABLES_LOCKED_FOLDER}/${CABLE_COLOR}.lock -- GitLab