Add files via upload

This commit is contained in:
mutto233
2018-06-27 03:12:02 -04:00
committed by GitHub
parent 5b33e787a6
commit 12a3a7a4c6
3 changed files with 177 additions and 103 deletions

View File

@@ -60,6 +60,9 @@ done < "$filename"
for i in "${!CHANNEL_DIR_ARR[@]}"
do
CHANNEL_DIR_NUMBERS[i]=$(echo ${CHANNEL_DIR_SORTED[i]} | sed "s/^pseudo-channel${CHANNEL_DIR_INCREMENT_SYMBOL}0*//")
if [ -z ${CHANNEL_DIR_NUMBERS[i]} ]; then
CHANNEL_DIR_NUMBERS[i]=0
fi
done
@@ -93,6 +96,10 @@ if [ "${#CHANNEL_DIR_ARR[@]}" -gt 1 ]; then
# We are now going to do the same thing here, just with previous channel
PREV_CHANNEL=$(echo $(<$OUTPUT_PREV_CHANNEL_PATH/$OUTPUT_PREV_CHANNEL_FILE) | sed "s/^0*//")
if [ -z $PREV_CHANNEL ]; then
PREV_CHANNEL=0
fi
echo "+++++ It looks like the previous channel was: $PREV_CHANNEL"

View File

@@ -71,6 +71,9 @@ done < "$filename"
for i in "${!CHANNEL_DIR_ARR[@]}"
do
CHANNEL_DIR_NUMBERS[i]=$(echo ${CHANNEL_DIR_SORTED[i]} | sed "s/^pseudo-channel${CHANNEL_DIR_INCREMENT_SYMBOL}0*//")
if [ -z ${CHANNEL_DIR_NUMBERS[i]} ]; then
CHANNEL_DIR_NUMBERS[i]=0
fi
done
# If this script see's there are multiple channels,
@@ -89,6 +92,9 @@ if [ "${#CHANNEL_DIR_ARR[@]}" -gt 1 ]; then
# We are now going to do the same thing here, just with previous channel
PREV_CHANNEL=$(echo $(<$OUTPUT_PREV_CHANNEL_PATH/$OUTPUT_PREV_CHANNEL_FILE) | sed "s/^0*//")
if [ -z $PREV_CHANNEL ]; then
PREV_CHANNEL=0
fi
echo "+++++ It looks like the previous channel was: $PREV_CHANNEL"

View File

@@ -44,7 +44,34 @@ FIRST_RUN=false
# Scan the dir to see how many channels there are, store them in an arr.
CHANNEL_DIR_ARR=( $(find . -maxdepth 1 -type d -name '*'"$CHANNEL_DIR_INCREMENT_SYMBOL"'[[:digit:]]*' -printf "%P\n" | sort -t"$CHANNEL_DIR_INCREMENT_SYMBOL" -n) )
echo $CHANNEL_DIR_ARR
# Since leading zeros may be an issue, we need to correctly sort the channels. The best way to do this seems to be in python
# So a script will take in the channels as they are, then output them in the correct, sorted order in Channels_Sorted.txt.
# We will run the script, then read in the results.
sudo python ./Channel_Sorter.py ${CHANNEL_DIR_ARR[@]}
filename="./Channels_Sorted.txt"
i=0
while read -r line
do
name="$line"
CHANNEL_DIR_SORTED[i]=$name
i=$((i+1))
done < "$filename"
# We need to add on top of this a "buffer" where we remove all leading zeros to compare everything on the same level
# This simply leaves us with the number at the end. NOTE: We should have already sorted things, so this should not be a problem
for i in "${!CHANNEL_DIR_ARR[@]}"
do
CHANNEL_DIR_NUMBERS[i]=$(echo ${CHANNEL_DIR_SORTED[i]} | sed "s/^pseudo-channel${CHANNEL_DIR_INCREMENT_SYMBOL}0*//")
if [ -z ${CHANNEL_DIR_NUMBERS[i]} ]; then
CHANNEL_DIR_NUMBERS[i]=0
fi
done
# If the previous channel txt file doesn't exist already create it (first run?)
if [ ! -e "$OUTPUT_PREV_CHANNEL_PATH/$OUTPUT_PREV_CHANNEL_FILE" ]; then
@@ -52,7 +79,7 @@ if [ ! -e "$OUTPUT_PREV_CHANNEL_PATH/$OUTPUT_PREV_CHANNEL_FILE" ]; then
#FIRST_RUN_NUM=$((${#CHANNEL_DIR_ARR[@]}))
echo 1 > "$OUTPUT_PREV_CHANNEL_PATH/$OUTPUT_PREV_CHANNEL_FILE"
echo "First run: $FIRST_RUN_NUM"
echo "First run being conducted"
FIRST_RUN=true
@@ -61,25 +88,59 @@ fi
# If this script see's there are multiple channels,
# then read file, get prevchannel and nextchannel, and trigger next channel:
if [ "${#CHANNEL_DIR_ARR[@]}" -gt 1 ]; then
echo "+++++ There are ${#CHANNEL_DIR_ARR[@]} channels detected."
NEXT_CHANNEL=$1
#NEXT_CHANNEL=$1
NEXT_CHANNEL_DIR=( $(find . -maxdepth 1 -type d -name '*'"$CHANNEL_DIR_INCREMENT_SYMBOL""$NEXT_CHANNEL" -printf "%P\n") )
#NEXT_CHANNEL_DIR=( $(find . -maxdepth 1 -type d -name '*'"$CHANNEL_DIR_INCREMENT_SYMBOL""$NEXT_CHANNEL" -printf "%P\n") )
# We now need to read in the next channel and ALSO strip it of any leading zeros for correct comparison
NEXT_CHANNEL=$(echo $1 | sed "s/^0*//")
if [ -z $NEXT_CHANNEL ]; then
NEXT_CHANNEL=0
fi
PREV_CHANNEL_FOUND=false
echo "+++++ There are ${#CHANNEL_DIR_ARR[@]} channels detected."
#PREV_CHANNEL=$(<$OUTPUT_PREV_CHANNEL_PATH/$OUTPUT_PREV_CHANNEL_FILE)
PREV_CHANNEL=$(<$OUTPUT_PREV_CHANNEL_PATH/$OUTPUT_PREV_CHANNEL_FILE)
# PREV_CHANNEL_DIR=( $(find . -maxdepth 1 -type d -name '*'"$CHANNEL_DIR_INCREMENT_SYMBOL""$PREV_CHANNEL" -printf "%P\n") )
PREV_CHANNEL_DIR=( $(find . -maxdepth 1 -type d -name '*'"$CHANNEL_DIR_INCREMENT_SYMBOL""$PREV_CHANNEL" -printf "%P\n") )
# We are now going to do the same thing here, just with previous channel
PREV_CHANNEL=$(echo $(<$OUTPUT_PREV_CHANNEL_PATH/$OUTPUT_PREV_CHANNEL_FILE) | sed "s/^0*//")
if [ -z $PREV_CHANNEL ]; then
PREV_CHANNEL=0
fi
PREV_CHANNEL_DISP=$(echo $PREV_CHANNEL | sed 's/^0*//')
echo "+++++ It looks like the previous channel was: $PREV_CHANNEL_DISP"
echo "+++++ It looks like the previous channel was: $PREV_CHANNEL"
echo "+++++ The next channel is: $NEXT_CHANNEL"
# This is our modified way of searching for the correct directory for the next channel
for i in "${!CHANNEL_DIR_NUMBERS[@]}"
do
item_compare=${CHANNEL_DIR_NUMBERS[i]}
if [ $item_compare -eq $NEXT_CHANNEL ]; then
echo "NEXT CHANNEL MATCH: ${CHANNEL_DIR_SORTED[$i]}"
NEXT_CHANNEL_DIR=${CHANNEL_DIR_SORTED[$i]}
break
fi
done
# This is our modified way of searching for the correct directory for the previous channel
for i in "${!CHANNEL_DIR_NUMBERS[@]}"
do
item_compare=${CHANNEL_DIR_NUMBERS[i]}
if [ $item_compare -eq $PREV_CHANNEL ]; then
echo "PREVIOUS CHANNEL MATCH: ${CHANNEL_DIR_SORTED[$i]}"
PREV_CHANNEL_DIR=${CHANNEL_DIR_SORTED[$i]}
break
fi
done
# Write next channel to previous channel file to reference later
echo "$NEXT_CHANNEL" > "$OUTPUT_PREV_CHANNEL_PATH/$OUTPUT_PREV_CHANNEL_FILE"