mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2025-12-24 04:04:29 +00:00
Multi-Box Editing Added
Two new functions added, "update_box <NAME>" will create a new folder that is identical to your master folder, and name it "channels_<NAME>" so it will play to the correct client. "update_box.sh" will go through ALL made boxes and update from gitHub (either master or develop branch, depending on what you want).
This commit is contained in:
53
main-dir/create_box.sh
Normal file
53
main-dir/create_box.sh
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Purpose of the script is to copy the current "master" channel database and create a new set for a named box
|
||||||
|
# As the input, simply give the name of a client, this will be appended in the form "channels_<NAME>"
|
||||||
|
|
||||||
|
# Flow of the script
|
||||||
|
# - Go out of directory, and make a new directory
|
||||||
|
# - Copy from the master folder to this folder
|
||||||
|
# - Find all channels, go in and remove .db, symlink to the original (running with -sf)
|
||||||
|
|
||||||
|
CHANNEL_DIR_INCREMENT_SYMBOL="_"
|
||||||
|
|
||||||
|
MASTERDIRECTORY="channels"
|
||||||
|
|
||||||
|
NEWDIRECTORY="${MASTERDIRECTORY}_${1}"
|
||||||
|
|
||||||
|
# CREATE THE NEW DIRECTORY
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
if [ -d "$NEWDIRECTORY" ]; then
|
||||||
|
sudo rm -R ${NEWDIRECTORY}
|
||||||
|
fi
|
||||||
|
mkdir $NEWDIRECTORY
|
||||||
|
|
||||||
|
|
||||||
|
# COPY THE ELEMENTS INTO HERE, THEN SET CORRECT PROPERTIES
|
||||||
|
sudo cp -r ./${MASTERDIRECTORY}/* ./${NEWDIRECTORY}/
|
||||||
|
sudo chmod -R 777 ./${NEWDIRECTORY}
|
||||||
|
|
||||||
|
|
||||||
|
# GO INTO EACH CHANNEL, DELETE THE .db FILE, AND SYMLINK TO THE ORIGINAL
|
||||||
|
cd ${NEWDIRECTORY}
|
||||||
|
CHANNEL_DIR_ARR=( $(find . -maxdepth 1 -type d -name '*'"$CHANNEL_DIR_INCREMENT_SYMBOL"'[[:digit:]]*' -printf "%P\n" | sort -t"$CHANNEL_DIR_INCREMENT_SYMBOL" -n) )
|
||||||
|
|
||||||
|
|
||||||
|
if [ "${#CHANNEL_DIR_ARR[@]}" -gt 1 ]; then
|
||||||
|
|
||||||
|
echo "+++++ There are ${#CHANNEL_DIR_ARR[@]} channels detected."
|
||||||
|
|
||||||
|
for i in "${!CHANNEL_DIR_ARR[@]}"
|
||||||
|
do
|
||||||
|
echo "+++++ Linking Directories in ${CHANNEL_DIR_ARR[i]}"
|
||||||
|
cd ${CHANNEL_DIR_ARR[i]}
|
||||||
|
MASTER_CHANNEL="../../${MASTERDIRECTORY}/${CHANNEL_DIR_ARR[i]}"
|
||||||
|
|
||||||
|
ln -sf "${MASTER_CHANNEL}/pseudo-channel.db"
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
56
main-dir/update_box.sh
Normal file
56
main-dir/update_box.sh
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Purpose of this script is to update ALL boxes with the most current version of the script.
|
||||||
|
|
||||||
|
# Flow of the script
|
||||||
|
# Go to home directory, identify ALL boxes that need updating
|
||||||
|
# Run "update-channels-from-git.sh" in all of them.
|
||||||
|
# System link all databases when complete
|
||||||
|
CHANNEL_DIR_INCREMENT_SYMBOL="_"
|
||||||
|
MASTERDIRECTORY="channels"
|
||||||
|
BRANCH="develop"
|
||||||
|
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
BOX_DIR_ARR=( $(find . -maxdepth 1 -type d -name 'channels'"$CHANNEL_DIR_INCREMENT_SYMBOL"'*' -printf "%P\n" | sort -t"$CHANNEL_DIR_INCREMENT_SYMBOL" -n) )
|
||||||
|
BOX_DIR_ARR+=("${MASTERDIRECTORY}")
|
||||||
|
echo "+++++ FOUND THE FOLLOWING BOXES: ${BOX_DIR_ARR[@]}"
|
||||||
|
|
||||||
|
for BOX in "${BOX_DIR_ARR[@]}"
|
||||||
|
do
|
||||||
|
cd ${BOX}
|
||||||
|
echo "+++++ CURRENTLY UPDATING ${BOX}"
|
||||||
|
# Sanity check, can we even update?
|
||||||
|
if [ ! -e "update-channels-from-git.sh" ]; then
|
||||||
|
echo "ERROR AT ${BOX}: No file to update with!"
|
||||||
|
exit 75
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update the given box with the gitHub repository branch selected.
|
||||||
|
sudo ./update-channels-from-git.sh ${BRANCH}
|
||||||
|
|
||||||
|
# Now we need to go in and perform the symlink again
|
||||||
|
CHANNEL_DIR_ARR=( $(find . -maxdepth 1 -type d -name '*'"$CHANNEL_DIR_INCREMENT_SYMBOL"'[[:digit:]]*' -printf "%P\n" | sort -t"$CHANNEL_DIR_INCREMENT_SYMBOL" -n) )
|
||||||
|
if [ "${#CHANNEL_DIR_ARR[@]}" -gt 1 ]; then
|
||||||
|
|
||||||
|
echo "+++++ There are ${#CHANNEL_DIR_ARR[@]} channels detected."
|
||||||
|
if [ ! "${BOX}" == "${MASTERDIRECTORY}" ]; then
|
||||||
|
echo "+++++ symlinking channels in ${BOX}"
|
||||||
|
for i in "${!CHANNEL_DIR_ARR[@]}"
|
||||||
|
do
|
||||||
|
echo "+++++ Linking Directories in ${CHANNEL_DIR_ARR[i]}"
|
||||||
|
cd ${CHANNEL_DIR_ARR[i]}
|
||||||
|
MASTER_CHANNEL="../../${MASTERDIRECTORY}/${CHANNEL_DIR_ARR[i]}"
|
||||||
|
|
||||||
|
ln -sf "${MASTER_CHANNEL}/pseudo-channel.db"
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "+++++ NOT symlinking these channels; these are master!!!"
|
||||||
|
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user