Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d96bd044 authored by Romain Hunault's avatar Romain Hunault 💻
Browse files

lock-cable.sh doesn't choose the color anymore

parent 9a6726fc
Loading
Loading
Loading
Loading
+12 −22
Original line number Diff line number Diff line
@@ -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