From 8eeb30b51382ccf56b6a684f677e8472843bf8e8 Mon Sep 17 00:00:00 2001 From: Justin Emter Date: Sat, 11 Nov 2017 13:32:21 -0800 Subject: [PATCH] Added update-channels-from-git.sh script to asynchronously clone updates into each channel. --- .../update-channels-from-git.sh | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 multi-channel-bash-scripts/update-channels-from-git.sh diff --git a/multi-channel-bash-scripts/update-channels-from-git.sh b/multi-channel-bash-scripts/update-channels-from-git.sh new file mode 100644 index 0000000..266672e --- /dev/null +++ b/multi-channel-bash-scripts/update-channels-from-git.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# file: update-channels-from-git.sh + +#---- +# Simple script to update every channel with updates from the github repo. +# BACKUP EACH XML/DB IN EACH CHANNEL. +#---- + +#---- +# To Use: +# chmod +x update-channels-from-git.sh +# ./update-channels-from-git.sh +#---- + +#----BEGIN EDITABLE VARS---- + +SCRIPT_TO_EXECUTE_PLUS_ARGS='git clone https://github.com/justinemter/pseudo-channel . --branch develop' + +OUTPUT_PREV_CHANNEL_PATH=. + +CHANNEL_DIR_INCREMENT_SYMBOL="_" + +#----END EDITABLE VARS------- + +# 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") ) + +# If this script see's there are multiple channels, +# then loop through each channel and run clone the repo there +if [ "${#CHANNEL_DIR_ARR[@]}" -gt 1 ]; then + + echo "+++++ There are ${#CHANNEL_DIR_ARR[@]} channels detected." + + for channel in "${CHANNEL_DIR_ARR[@]}" + do + + echo "+++++ Trying to update channel:"./"$channel"/$SCRIPT_TO_EXECUTE_PLUS_ARGS + + cd "$channel" + + mkdir ../.pseudo-temp + + cp ./pseudo-channel.db ../.pseudo-temp + + cp ./pseudo_schedule.xml ../.pseudo-temp + + cp ./pseudo_config.py ../.pseudo-temp + + find -mindepth 1 -delete && $SCRIPT_TO_EXECUTE_PLUS_ARGS + + cp ../.pseudo-temp/pseudo-channel.db . + + cp ../.pseudo-temp/pseudo_schedule.xml . + + cp ../.pseudo-temp/pseudo_config.py . + + echo "+++++ Done." + + sleep 1 + + cd ../ + + sleep 1 + + done + +fi + +exit 0 \ No newline at end of file