Better checking of where token came from

This commit is contained in:
Alex Malinovich 2017-02-20 16:01:03 -08:00
commit 53d3086068
2 changed files with 9 additions and 6 deletions

View file

@ -3,12 +3,15 @@
URL_LOGIN='https://plex.tv/users/sign_in.json' URL_LOGIN='https://plex.tv/users/sign_in.json'
getPlexToken() { getPlexToken() {
[ -z "$TOKEN" ] && getPlexServerToken if [ -n "$TOKEN" ]; then
# Check if we're connected to a terminal echo "Fetching token from config"
if [ -z "$TOKEN" -a -n "$EMAIL" -a -n "$PASS" ]; then elif getPlexServerToken
echo "Fetching token from Plex server"
elif [ -z "$TOKEN" -a -n "$EMAIL" -a -n "$PASS" ]; then
#TOFIX #TOFIX
echo "WARNING: Storing your email and password has been deprecated. Please re-run extras/installer.sh or see LINK_TO_FAQ." echo "WARNING: Storing your email and password has been deprecated. Please re-run extras/installer.sh or see LINK_TO_FAQ."
getPlexWebToken getPlexWebToken
# Check if we're connected to a terminal
elif [ -z "$TOKEN" -a -t 0 ]; then elif [ -z "$TOKEN" -a -t 0 ]; then
echo "To continue, you will need to provide your Plex account credentials." echo "To continue, you will need to provide your Plex account credentials."
echo "Your email and password will only be used to retrieve a 'token' and will not be saved anywhere." echo "Your email and password will only be used to retrieve a 'token' and will not be saved anywhere."
@ -30,8 +33,6 @@ getPlexToken() {
fi fi
done done
getPlexWebToken getPlexWebToken
elif [ -n "$TOKEN" ]; then
echo "Fetching token from Plex server"
fi fi
[ -n "$TOKEN" ] # simulate exit status [ -n "$TOKEN" ] # simulate exit status
@ -80,6 +81,8 @@ getPlexServerToken() {
fi fi
fi fi
done done
[ -n "$TOKEN" ] # simulate exit status
} }
getPlexWebToken() { getPlexWebToken() {

View file

@ -347,7 +347,7 @@ if yesno; then
PROGRESS_OPT="-P" PROGRESS_OPT="-P"
fi fi
if [ "$AUTOINSTALL" == "yes" ]; then if [ "$AUTOINSTALL" == "yes" ]; then
sudo "$FULL_PATH/plexupdate.sh" $PROGRESS_OPT --config "$CONFIGFILE" sudo -E "$FULL_PATH/plexupdate.sh" $PROGRESS_OPT --config "$CONFIGFILE"
else else
"$FULL_PATH/plexupdate.sh" $PROGRESS_OPT --config "$CONFIGFILE" "$FULL_PATH/plexupdate.sh" $PROGRESS_OPT --config "$CONFIGFILE"
fi fi