mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2026-01-10 12:13:14 +00:00
Installer update
This commit is contained in:
@@ -32,7 +32,17 @@ OUTPUT_PREV_CHANNEL_PATH=.
|
||||
|
||||
CHANNEL_DIR_INCREMENT_SYMBOL="_"
|
||||
|
||||
FIRST_INSTALL=false
|
||||
# This does a check for the pseudo-channel_## directories that manage each channel.
|
||||
# As this script generates those directories on first run, if those directories do
|
||||
# not exist, then logically this is the first run.
|
||||
FIND_CHANNEL_FOLDER=''
|
||||
FIND_CHANNEL_FOLDERS=$(find ./ -name "pseudo-channel_*" -type d)
|
||||
if [[ "$FIND_CHANNEL_FOLDERS" == '' ]]
|
||||
then
|
||||
FIRST_INSTALL=true
|
||||
else
|
||||
FIRST_INSTALL=false
|
||||
fi
|
||||
|
||||
#----END EDITABLE VARS-------
|
||||
|
||||
@@ -54,10 +64,33 @@ FIRST_INSTALL=false
|
||||
|
||||
# If this is our first install, we will now make all necessary directories to prepare for install
|
||||
if [ "$FIRST_INSTALL" == "true" ]; then
|
||||
|
||||
for (( num=1; num<=5; num++ ))
|
||||
echo "This is a FIRST INSTALL, ENTER the NUMBER of PSEUDO CHANNELS to SET UP"
|
||||
read -p 'Number of Channels: ' number_of_channels
|
||||
if (( $number_of_channels >= 1 ))
|
||||
then
|
||||
entry_is_number=yes
|
||||
else
|
||||
entry_is_number=no
|
||||
fi
|
||||
while [[ $entry_is_number == "no" ]]
|
||||
do
|
||||
echo "Enter the number of channels you would like this script to generate?"
|
||||
read -p 'Number of Channels: ' number_of_channels
|
||||
if (( $number_of_channels >= 1 ))
|
||||
then
|
||||
entry_is_number=yes
|
||||
else
|
||||
entry_is_number=no
|
||||
fi
|
||||
done
|
||||
for (( num=1; num<="$number_of_channels"; num++ ))
|
||||
do
|
||||
if [ $num -ge 1 -a $num -le 9 ]
|
||||
then
|
||||
mkdir "pseudo-channel_0$num"
|
||||
else
|
||||
mkdir "pseudo-channel_$num"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -68,14 +101,140 @@ cd github_download
|
||||
$SCRIPT_TO_EXECUTE_PLUS_ARGS
|
||||
|
||||
#### If necessary, install the required elements as defined by requirements.txt
|
||||
if [ "$FIRST_INSTALL" == "true" ]; then
|
||||
#### Also, ask user for information to fill in the plex_token and pseudo_config files
|
||||
if [ "$FIRST_INSTALL" == "true" ]
|
||||
then
|
||||
echo "INSTALLING REQUIREMENTS because this is a FIRST RUN"
|
||||
sudo pip install -r requirements.txt
|
||||
sudo apt-get -y install libxml2-utils
|
||||
cd ..
|
||||
echo "ENTER the IP ADDRESS of your PLEX SERVER"
|
||||
read -p 'Plex Server IP: ' server_ip
|
||||
echo "ENTER the PUBLIC PORT number for your PLEX SERVER"
|
||||
read -p 'Public Port (default: 32400): ' server_port
|
||||
if [ "$server_port" == '' ]
|
||||
then
|
||||
server_port='32400'
|
||||
fi
|
||||
echo "ENTER your PLEX AUTHENTICATION TOKEN"
|
||||
echo "(for help finding token, check here: https://bit.ly/2p7RtOu)"
|
||||
read -p 'Plex Auth Token: ' server_token
|
||||
echo "PLEX SERVER is $server_ip:$server_port"
|
||||
echo "PLEX AUTH TOKEN is $server_token"
|
||||
echo "SELECT the PLEX CLIENT for this install or ENTER one manually"
|
||||
# Gets a list of Plex clients connected and registered with the server
|
||||
clientlist=$(xmllint --xpath "//Server/@name" "http://192.168.1.140:32400/clients" | sed "s|name=||g" | sed "s|^ ||g" && echo -e " Other")
|
||||
eval set $clientlist
|
||||
select ps_client_entry in "$@"
|
||||
do
|
||||
if [[ "$ps_client_entry" == "Other" ]]
|
||||
then
|
||||
read -p 'Client Name: ' ps_client_entry
|
||||
ps_client_entry=$(eval echo $ps_client_entry)
|
||||
fi
|
||||
ps_client="[\"$ps_client_entry\"]"
|
||||
break
|
||||
done
|
||||
# Get the names of Plex libraries for the config
|
||||
echo "ENTER the name of EACH Plex library defined as TV SHOWS"
|
||||
enter_tv_shows=yes
|
||||
echo -n "[" > tv-libraries.temp
|
||||
while [[ "$enter_tv_shows" == @(Y|y|Yes|yes|YES) ]]
|
||||
do
|
||||
read -p 'TV Show Library Name: ' tv_library_entry
|
||||
echo -n "\"$tv_library_entry\"" >> tv-libraries.temp
|
||||
echo "ENTER another LIBRARY?"
|
||||
read -p 'Y/N: ' enter_tv_shows
|
||||
while [[ "$enter_tv_shows" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]]
|
||||
do
|
||||
echo "ENTER another LIBRARY?"
|
||||
read -p 'Y/N: ' enter_tv_shows
|
||||
done
|
||||
if [[ "$enter_tv_shows" == @(Y|y|Yes|yes|YES) ]]
|
||||
then
|
||||
echo -n ", " >> tv-libraries.temp
|
||||
fi
|
||||
done
|
||||
echo -n "]," >> tv-libraries.temp
|
||||
echo "ENTER the name of EACH Plex library defined as MOVIES"
|
||||
enter_movies=yes
|
||||
echo -n "[" > movie-libraries.temp
|
||||
while [[ "$enter_movies" == @(Y|y|Yes|yes|YES) ]]
|
||||
do
|
||||
read -p 'Movie Library Name: ' movie_library_entry
|
||||
echo -n "\"$movie_library_entry\"" >> movie-libraries.temp
|
||||
echo "ENTER another LIBRARY?"
|
||||
read -p 'Y/N: ' enter_movies
|
||||
while [[ "$enter_movies" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]]
|
||||
do
|
||||
echo "ENTER another LIBRARY?"
|
||||
read -p 'Y/N: ' enter_movies
|
||||
done
|
||||
if [[ "$enter_movies" == @(Y|y|Yes|yes|YES) ]]
|
||||
then
|
||||
echo -n ", " >> movie-libraries.temp
|
||||
fi
|
||||
done
|
||||
echo -n "]," >> movie-libraries.temp
|
||||
echo "Use COMMERCIALS in between scheduled content?"
|
||||
read -p 'Y/N: ' enter_commercials
|
||||
while [[ "$enter_commercials" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]]
|
||||
do
|
||||
echo "Use COMMERCIALS in between scheduled content?"
|
||||
read -p 'Y/N: ' enter_commercials
|
||||
done
|
||||
if [[ "$enter_commercials" == @("Y"|"y"|"yes"|"Yes"|"YES") ]]
|
||||
then
|
||||
commercials_true=true
|
||||
echo "ENTER the name of EACH Plex library defined as COMMERCIALS"
|
||||
echo -n "[" > commercial-libraries.temp
|
||||
fi
|
||||
while [[ "$enter_commercials" == @(Y|y|Yes|yes|YES) ]]
|
||||
do
|
||||
read -p 'Commercial Library Name: ' commercial_library_entry
|
||||
echo -n "\"$commercial_library_entry\", " >> commercial-libraries.temp
|
||||
echo "ENTER another LIBRARY?"
|
||||
read -p 'Y/N: ' enter_commercials
|
||||
while [[ "$enter_commercials" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]]
|
||||
do
|
||||
echo "ENTER another LIBRARY?"
|
||||
read -p 'Y/N: ' enter_commercials
|
||||
done
|
||||
done
|
||||
if [[ "$commercials_true" == "true" ]]
|
||||
then
|
||||
truncate -s-2 commercial-libraries.temp
|
||||
echo -n "]," >> commercial-libraries.temp
|
||||
fi
|
||||
echo "Set the TIME for PSEUDO CHANNEL to GENERATE the DAILY SCHEDULE"
|
||||
echo "USE either 24h FORMAT (ex: 23:00) or 12h FORMAT (11:00 PM)"
|
||||
read -p 'Schedule Reset Time: ' reset_time
|
||||
reset_time="\"$reset_time\""
|
||||
echo "token = '$server_token'" > plex_token.py
|
||||
echo "baseurl = 'http://$server_ip:$server_port'" >> plex_token.py
|
||||
tv_libraries=$(cat tv-libraries.temp)
|
||||
sudo sed -i "s/plexClients = .*/plexClients = $ps_client/" github_download/both-dir/pseudo_config.py
|
||||
sudo sed -i "/.\"TV Shows\" :*./c\ \"TV Shows\" : $tv_libraries" github_download/both-dir/pseudo_config.py
|
||||
movie_libraries=$(cat movie-libraries.temp)
|
||||
sudo sed -i "/.\"Movies\" :*./c\ \"Movies\" : $movie_libraries" github_download/both-dir/pseudo_config.py
|
||||
if [[ "$commercials_true" == "true" ]]
|
||||
then
|
||||
commercial_libraries=$(cat commercial-libraries.temp)
|
||||
sudo sed -i "/.\"Commercials\" :*./c\ \"Commercials\" : $commercial_libraries" github_download/both-dir/pseudo_config.py
|
||||
fi
|
||||
sudo sed -i "s/useCommercialInjection =.*/useCommercialInjection = $commercials_true/" github_download/both-dir/pseudo_config.py
|
||||
sudo sed -i "s/dailyUpdateTime =.*/dailyUpdateTime = $reset_time/" github_download/both-dir/pseudo_config.py
|
||||
sudo sed -i "s/controllerServerPath =.*/controllerServerPath = \"\"/" github_download/both-dir/pseudo_config.py
|
||||
sudo sed -i "s/controllerServerPort =.*/controllerServerPort = \"\"/" github_download/both-dir/pseudo_config.py
|
||||
sudo sed -i "s/debug_mode =.*/debug_mode = False/" github_download/both-dir/pseudo_config.py
|
||||
sudo rm movie-libraries.temp
|
||||
sudo rm tv-libraries.temp
|
||||
sudo rm commercial-libraries.temp
|
||||
sudo cp github_download/both-dir/pseudo_config.py ./
|
||||
else
|
||||
cd ..
|
||||
fi
|
||||
|
||||
cd ..
|
||||
|
||||
|
||||
#### With information downloaded, we will first go to each channel folder and update important things
|
||||
#### This will take the following form
|
||||
#### - Enter folder
|
||||
@@ -92,29 +251,29 @@ if [ "${#CHANNEL_DIR_ARR[@]}" -gt 1 ]; then
|
||||
do
|
||||
echo "+++++ Trying to update channel:"./"$channel"
|
||||
cd "$channel"
|
||||
|
||||
|
||||
# Export critical files
|
||||
mkdir ../.pseudo-temp
|
||||
|
||||
|
||||
cp ./pseudo-channel.db ../.pseudo-temp 2>/dev/null
|
||||
|
||||
cp ./pseudo_schedule.xml ../.pseudo-temp 2>/dev/null
|
||||
|
||||
cp ./pseudo_config.py ../.pseudo-temp 2>/dev/null
|
||||
|
||||
|
||||
# Copy new elements
|
||||
|
||||
|
||||
cp -r ../github_download/channel-dir/* .
|
||||
cp -r ../github_download/both-dir/* .
|
||||
|
||||
|
||||
# Replace the files originally moved
|
||||
|
||||
|
||||
cp ../.pseudo-temp/pseudo-channel.db . 2>/dev/null
|
||||
|
||||
cp ../.pseudo-temp/pseudo_schedule.xml . 2>/dev/null
|
||||
|
||||
|
||||
cp ../.pseudo-temp/pseudo_config.py . 2>/dev/null
|
||||
|
||||
|
||||
rm -rf ../.pseudo-temp
|
||||
|
||||
cd ..
|
||||
@@ -124,7 +283,7 @@ fi
|
||||
#### Now we will return to the original file, and ensure that everything is in the main folder
|
||||
#### This will include the following form
|
||||
#### - Return to folder
|
||||
#### - Copy config, db, and tolken file
|
||||
#### - Copy config, db, and token file
|
||||
#### - Copy relevant files from github
|
||||
#### - Replace files originally removed
|
||||
echo "Updating channels folder"
|
||||
|
||||
Reference in New Issue
Block a user