mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-08-20 21:33:16 -07:00
parent
ec5e3b7fa4
commit
09d513a671
1 changed files with 47 additions and 3 deletions
|
@ -8,6 +8,7 @@ CRONWRAPPER="/etc/cron.daily/plexupdate"
|
|||
VERBOSE=yes #to be inherited by get-plex-token, do not save to config
|
||||
|
||||
# default options
|
||||
USEDEFAULTS=false
|
||||
AUTOINSTALL=yes
|
||||
AUTOUPDATE=yes
|
||||
PUBLIC=
|
||||
|
@ -16,6 +17,19 @@ PUBLIC=
|
|||
CONFIGVARS="AUTOINSTALL AUTODELETE DOWNLOADDIR TOKEN FORCE FORCEALL PUBLIC AUTOSTART AUTOUPDATE PLEXSERVER PLEXPORT CHECKUPDATE NOTIFY"
|
||||
CRONVARS="CONF SCRIPT LOGGING"
|
||||
|
||||
usage() {
|
||||
echo "Usage: $(basename $0) [-h] [<long options>]"
|
||||
echo ""
|
||||
echo ""
|
||||
echo " -h This help"
|
||||
echo ""
|
||||
echo " Long Argument Options:"
|
||||
echo " --default Use defaults for all prompts"
|
||||
echo " --help This help"
|
||||
echo ""
|
||||
exit 0
|
||||
}
|
||||
|
||||
install() {
|
||||
echo "'$req' is required but not installed, attempting to install..."
|
||||
sleep 1
|
||||
|
@ -75,7 +89,11 @@ yesno() {
|
|||
fi
|
||||
|
||||
while true; do
|
||||
read -n 1 -p "$prompt" answer
|
||||
if $USEDEFAULTS; then
|
||||
echo "$prompt"
|
||||
else
|
||||
read -n 1 -p "$prompt" answer
|
||||
fi
|
||||
answer=${answer:-$default}
|
||||
answer="$(tr "[:lower:]" "[:upper:]" <<< "$answer")"
|
||||
|
||||
|
@ -193,9 +211,17 @@ configure_plexupdate() {
|
|||
PLEXSERVER="127.0.0.1"
|
||||
fi
|
||||
while true; do
|
||||
read -e -p "Plex Server IP/DNS name: " -i "$PLEXSERVER" PLEXSERVER
|
||||
prompt="Plex Server IP/DNS name:"
|
||||
if $USEDEFAULTS; then
|
||||
echo "$prompt $PLEXSERVER"
|
||||
else
|
||||
read -e -p "$prompt " -i "$PLEXSERVER" PLEXSERVER
|
||||
fi
|
||||
if ! ping -c 1 -w 1 "$PLEXSERVER" &>/dev/null ; then
|
||||
echo -n "Server $PLEXSERVER isn't responding, are you sure you entered it correctly? "
|
||||
if $USEDEFAULTS; then
|
||||
abort
|
||||
fi
|
||||
if yesno N; then
|
||||
break
|
||||
fi
|
||||
|
@ -207,7 +233,12 @@ configure_plexupdate() {
|
|||
PLEXPORT=32400
|
||||
fi
|
||||
while true; do
|
||||
read -e -p "Plex Server Port: " -i "$PLEXPORT" PLEXPORT
|
||||
prompt="Plex Server Port:"
|
||||
if $USEDEFAULTS; then
|
||||
echo "$prompt $PLEXPORT"
|
||||
else
|
||||
read -e -p "$prompt " -i "$PLEXPORT" PLEXPORT
|
||||
fi
|
||||
if ! [[ "$PLEXPORT" =~ ^[1-9][0-9]*$ ]]; then
|
||||
echo "Port $PLEXPORT isn't valid, please try again"
|
||||
PLEXPORT=32400
|
||||
|
@ -323,6 +354,19 @@ for req in wget git; do
|
|||
fi
|
||||
done
|
||||
|
||||
while true;
|
||||
do
|
||||
case "$1" in
|
||||
(-h) usage;;
|
||||
|
||||
(--default) USEDEFAULTS=true;;
|
||||
(--help) usage;;
|
||||
(-*) error "Unrecognized option $1"; usage; exit 1;;
|
||||
(*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -f ~/.plexupdate ]; then
|
||||
echo
|
||||
echo -n "Existing configuration found in ~/.plexupdate, would you like to import these settings? "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue