From f7d0bd6558ac02bac51a905a08fae2565f5fe6d3 Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 11 Oct 2018 22:15:41 +0100 Subject: [PATCH] fixed referencing --- scripts/blink | 2 +- scripts/card-backup.sh | 73 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/scripts/blink b/scripts/blink index 1488a3e..3bf924a 100644 --- a/scripts/blink +++ b/scripts/blink @@ -1,6 +1,6 @@ #!/bin/bash -source ./gpio +. /home/pi/little-backup-box/scripts/gpio function blink() { diff --git a/scripts/card-backup.sh b/scripts/card-backup.sh index c37a821..49154d7 100755 --- a/scripts/card-backup.sh +++ b/scripts/card-backup.sh @@ -25,8 +25,9 @@ CARD_DEV="sd[ab]1" # Name of the storage card CARD_MOUNT_POINT="/media/card" # Mount point of the storage card SHUTD="5" # Minutes to wait before shutdown due to inactivity -source gpio -source blink +. /home/pi/little-backup-box/scripts/gpio +. /home/pi/little-backup-box/scripts/blink + gpio mode 5 out gpio mode 6 out @@ -100,6 +101,7 @@ if [ ! -z "${CARD_READER[0]}" ]; then rsync -avh --info=progress2 --exclude "*.id" "$CARD_MOUNT_POINT"/ "$BACKUP_PATH" & pid=$! + COUNTER=0 while kill -0 $pid 2> /dev/null do STORAGE_COUNT=$(find $BACKUP_PATH/ -type f | wc -l) @@ -107,24 +109,69 @@ if [ ! -z "${CARD_READER[0]}" ]; then sudo sh -c "echo $PERCENT" #IF STATEMENTS HERE FOR LEDS if [ $PERCENT -lt 19 ]; then - gpio write 26 1 + if [ "$COUNTER" -eq 0 ]; then + blink 26 0.25 & + blink_pid1=$! + COUNTER=$((COUNTER+1)) + fi + elif [ $PERCENT -gt 20 ] && [ $PERCENT -lt 39 ]; then - gpio write 19 1 + kill $blink_pid1 2> /dev/null + gpio write 26 1 + if [ "$COUNTER" -eq 1 ]; then + blink 19 0.25 & + blink_pid2=$! + COUNTER=$((COUNTER+1)) + fi + elif [ $PERCENT -gt 40 ] && [ $PERCENT -lt 59 ]; then - gpio write 13 1 + kill $blink_pid2 2> /dev/null + gpio write 26 1 + gpio write 19 1 + if [ "$COUNTER" -eq 2 ]; then + blink 13 0.25 & + blink_pid3=$! + COUNTER=$((COUNTER+1)) + fi elif [ $PERCENT -gt 60 ] && [ $PERCENT -lt 79 ]; then - gpio write 6 1 + kill $blink_pid3 2> /dev/null + gpio write 26 1 + gpio write 19 1 + gpio write 13 1 + if [ "$COUNTER" -eq 3 ]; then + blink 6 0.25 & + blink_pid4=$! + COUNTER=$((COUNTER+1)) + fi elif [ $PERCENT -gt 80 ] && [ $PERCENT -lt 100 ]; then - gpio write 5 1 + kill $blink_pid4 2> /dev/null + gpio write 26 1 + gpio write 19 1 + gpio write 13 1 + gpio write 6 1 + if [ "$COUNTER" -eq 3 ]; then + blink 5 0.25 & + blink_pid5=$! + COUNTER=$((COUNTER+1)) + fi fi - # then - #LEDS - #fi + sleep 1 done - sudo sh -c "echo 1 > /sys/class/leds/led0/brightness" - # Turn off the POWER LED to indicate that the backup is completed - sudo sh -c "echo 0 > /sys/class/leds/led1/brightness" + kill $blink_pid5 2> /dev/null + gpio write 26 1 + gpio write 19 1 + gpio write 13 1 + gpio write 6 1 + gpio write 5 1 + + sleep 5 + + gpio clean 5 + gpio clean 6 + gpio clean 13 + gpio clean 19 + gpio clean 26 fi # Shutdown