This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ROOT_DIR=$1 | |
DRIVE_NUM=$2 | |
PORT=$3 | |
printf -v DNAME "%02d" $DRIVE_NUM | |
cd $ROOT_DIR/$DNAME | |
echo Listening in $ROOT_DIR/$DNAME | |
next_dir () { | |
echo "in next_dir" | |
DRIVE_NUM=$((DRIVE_NUM+1)) | |
printf -v DNAME "%02d" $DRIVE_NUM | |
echo switching dir to $ROOT_DIR/$DNAME | |
cd $ROOT_DIR/$DNAME | |
} | |
while true; do | |
nc -p $PORT -l | tar -x | |
echo "Plot saved in $ROOT_DIR/$DNAME" | |
ls plot-k32-2021-0[0-6]*.plot | head -n 1 | xargs rm -- || next_dir | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: ./listener.sh ROOT_DIR DRIVE_NUMBER LISTENER_PORT
requires storage drives be named incrementally from 00 to 99.
ex:
/mnt/plots/00
/mnt/plots/01
/mnt/plots/02
example usage: ./listener.sh /mnt/plots 1 3001
Starts in folder /mnt/plots/01 and increments upwards.