Loading lock-cable.sh +12 −22 Original line number Diff line number Diff line Loading @@ -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 ] if [ -z $CABLE_COLOR ] then continue exit 102 fi CABLE=blue if [ -f ${CABLES_LOCKED_FOLDER}/red.lock ] && [ ! -f ${CABLES_LOCKED_FOLDER}/green.lock ] if [ -f ${CABLES_LOCKED_FOLDER}/${CABLE_COLOR}.lock ] then CABLE=green elif [ -f ${CABLES_LOCKED_FOLDER}/blue.lock ] && [ ! -f ${CABLES_LOCKED_FOLDER}/red.lock ] then CABLE=red exit 103 fi done echo ${CABLE} mkdir -p ${CABLES_LOCKED_FOLDER} && touch ${CABLES_LOCKED_FOLDER}/${CABLE}.lock mkdir -p ${CABLES_LOCKED_FOLDER} && touch ${CABLES_LOCKED_FOLDER}/${CABLE_COLOR}.lock Loading
lock-cable.sh +12 −22 Original line number Diff line number Diff line Loading @@ -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 ] if [ -z $CABLE_COLOR ] then continue exit 102 fi CABLE=blue if [ -f ${CABLES_LOCKED_FOLDER}/red.lock ] && [ ! -f ${CABLES_LOCKED_FOLDER}/green.lock ] if [ -f ${CABLES_LOCKED_FOLDER}/${CABLE_COLOR}.lock ] then CABLE=green elif [ -f ${CABLES_LOCKED_FOLDER}/blue.lock ] && [ ! -f ${CABLES_LOCKED_FOLDER}/red.lock ] then CABLE=red exit 103 fi done echo ${CABLE} mkdir -p ${CABLES_LOCKED_FOLDER} && touch ${CABLES_LOCKED_FOLDER}/${CABLE}.lock mkdir -p ${CABLES_LOCKED_FOLDER} && touch ${CABLES_LOCKED_FOLDER}/${CABLE_COLOR}.lock