mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-08-19 21:03:19 -07:00
Remove VAR_CL logic in favor of checking config before getopt run
Also: * cleaned up a duplicate `source` line * fixed the logic on the deprecated `.plexupdate` check * removed the "don't allow VERBOSE in config file" logic
This commit is contained in:
parent
11518ed8d1
commit
b1dc95ca13
1 changed files with 39 additions and 52 deletions
|
@ -223,32 +223,57 @@ if [ $? -eq 1 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -- ${GETOPTRES}
|
set -- ${GETOPTRES}
|
||||||
|
|
||||||
|
for i in `seq 1 $#`; do
|
||||||
|
if [ "${!i}" == "--config" ]; then
|
||||||
|
config_index=$((++i))
|
||||||
|
CONFIGFILE=$(trimQuotes ${!config_index})
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
#FIXME: Temporary error checking to notify people of change from .plexupdate to plexupdate.conf
|
||||||
|
# We have to double-check that both files exist before trying to stat them. This is going away soon.
|
||||||
|
if [ -z "${CONFIGFILE}" -a -f ~/.plexupdate -a ! -f /etc/plexupdate.conf ] || \
|
||||||
|
([ -f "${CONFIGFILE}" -a -f ~/.plexupdate ] && [ `stat -Lc %i "${CONFIGFILE}"` == `stat -Lc %i ~/.plexupdate` ]); then
|
||||||
|
warn ".plexupdate has been deprecated. You should move your configuration to /etc/plexupdate.conf"
|
||||||
|
if [ -t 1 ]; then
|
||||||
|
for i in `seq 1 5`; do echo -n .\ ; sleep 1; done
|
||||||
|
echo .
|
||||||
|
fi
|
||||||
|
CONFIGFILE=~/.plexupdate
|
||||||
|
fi
|
||||||
|
#FIXME
|
||||||
|
|
||||||
|
# If a config file was specified, or if /etc/plexupdate.conf exists, we'll use it. Otherwise, just skip it.
|
||||||
|
source "${CONFIGFILE:-"/etc/plexupdate.conf"}" 2>/dev/null
|
||||||
|
|
||||||
while true;
|
while true;
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
(-h) usage;;
|
(-h) usage;;
|
||||||
(-a) AUTOINSTALL_CL=yes;;
|
(-a) AUTOINSTALL=yes;;
|
||||||
(-c) error "CRON option is deprecated, please use cronwrapper (see README.md)"; exit 255;;
|
(-c) error "CRON option is deprecated, please use cronwrapper (see README.md)"; exit 255;;
|
||||||
(-C) error "CRON option is deprecated, please use cronwrapper (see README.md)"; exit 255;;
|
(-C) error "CRON option is deprecated, please use cronwrapper (see README.md)"; exit 255;;
|
||||||
(-d) AUTODELETE_CL=yes;;
|
(-d) AUTODELETE=yes;;
|
||||||
(-f) FORCE_CL=yes;;
|
(-f) FORCE=yes;;
|
||||||
(-F) FORCEALL_CL=yes;;
|
(-F) FORCEALL=yes;;
|
||||||
(-l) LISTOPTS=yes;;
|
(-l) LISTOPTS=yes;;
|
||||||
(-p) PUBLIC_CL=yes;;
|
(-p) PUBLIC=yes;;
|
||||||
(-P) SHOWPROGRESS=yes;;
|
(-P) SHOWPROGRESS=yes;;
|
||||||
(-q) error "QUIET option is deprecated, please redirect to /dev/null instead"; exit 255;;
|
(-q) error "QUIET option is deprecated, please redirect to /dev/null instead"; exit 255;;
|
||||||
(-r) PRINT_URL=yes;;
|
(-r) PRINT_URL=yes;;
|
||||||
(-s) AUTOSTART_CL=yes;;
|
(-s) AUTOSTART=yes;;
|
||||||
(-u) AUTOUPDATE_CL=yes;;
|
(-u) AUTOUPDATE=yes;;
|
||||||
(-U) IGNOREAUTOUPDATE=yes;;
|
(-U) IGNOREAUTOUPDATE=yes;;
|
||||||
(-v) VERBOSE_CL=yes;;
|
(-v) VERBOSE=yes;;
|
||||||
|
|
||||||
(--config) shift; CONFIGFILE="$1"; CONFIGFILE=$(trimQuotes ${CONFIGFILE});;
|
(--config) shift;; #gobble up the paramater and silently continue parsing
|
||||||
(--dldir) shift; DOWNLOADDIR_CL="$1"; DOWNLOADDIR_CL=$(trimQuotes ${DOWNLOADDIR_CL});;
|
(--dldir) shift; DOWNLOADDIR=$(trimQuotes ${1});;
|
||||||
(--email) shift; EMAIL_CL="$1"; EMAIL_CL=$(trimQuotes ${EMAIL_CL});;
|
(--email) shift; EMAIL=$(trimQuotes ${1});;
|
||||||
(--pass) shift; PASS_CL="$1"; PASS_CL=$(trimQuotes ${PASS_CL});;
|
(--pass) shift; PASS=$(trimQuotes ${1});;
|
||||||
(--server) shift; PLEXSERVER_CL="$1"; PLEXSERVER_CL=$(trimQuotes ${PLEXSERVER_CL});;
|
(--server) shift; PLEXSERVER=$(trimQuotes ${1});;
|
||||||
(--port) shift; PLEXPORT_CL="$1"; PLEXPORT_CL=$(trimQuotes ${PLEXPORT_CL});;
|
(--port) shift; PLEXPORT=$(trimQuotes ${1});;
|
||||||
|
|
||||||
(--) ;;
|
(--) ;;
|
||||||
(-*) error "Unrecognized option $1"; usage; exit 1;;
|
(-*) error "Unrecognized option $1"; usage; exit 1;;
|
||||||
|
@ -263,44 +288,6 @@ if ! hash wget 2>/dev/null; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#FIXME: Temporary error checking to notify people of change from .plexupdate to plexupdate.conf
|
|
||||||
# We have to double-check that both files exist before trying to stat them. This is going away soon.
|
|
||||||
if [ -z "${CONFIGFILE}" -a -f ~/.plexupdate -a ! -f /etc/plexupdate.conf ] || \
|
|
||||||
[ -f "${CONFIGFILE}" -a -f ~/.plexupdate ] && [ `stat -Lc %i "${CONFIGFILE}"` == `stat -Lc %i ~/.plexupdate` ]; then
|
|
||||||
warn ".plexupdate has been deprecated. You should move your configuration to /etc/plexupdate.conf"
|
|
||||||
if [ -t 1 ]; then
|
|
||||||
for i in `seq 1 5`; do echo -n .\ ; sleep 1; done
|
|
||||||
echo .
|
|
||||||
fi
|
|
||||||
CONFIGFILE=~/.plexupdate
|
|
||||||
fi
|
|
||||||
#FIXME
|
|
||||||
|
|
||||||
# If a config file was specified, or if /etc/plexupdate.conf exists, we'll use it. Otherwise, just skip it.
|
|
||||||
source "${CONFIGFILE:-"/etc/plexupdate.conf"}" 2>/dev/null
|
|
||||||
|
|
||||||
# DO NOT ALLOW VERBOSE FROM CONFIGURATION FILE!
|
|
||||||
if [ "${VERBOSE_CL}" = "yes" ]; then
|
|
||||||
VERBOSE=yes
|
|
||||||
else
|
|
||||||
VERBOSE=no
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If a config file was specified, or if /etc/plexupdate.conf exists, we'll use it. Otherwise, just skip it.
|
|
||||||
source "${CONFIGFILE:-"/etc/plexupdate.conf"}" 2>/dev/null
|
|
||||||
|
|
||||||
# The way I wrote this, it assumes that whatever we put on the command line is what we want and should override
|
|
||||||
# any values in the configuration file. As a result, we need to check if they've been set on the command line
|
|
||||||
# and overwrite the values that may have been loaded with the config file
|
|
||||||
|
|
||||||
for VAR in AUTOINSTALL AUTODELETE DOWNLOADDIR EMAIL PASS FORCE FORCEALL PUBLIC AUTOSTART AUTOUPDATE PLEXSERVER PLEXPORT
|
|
||||||
do
|
|
||||||
VAR2="$VAR""_CL"
|
|
||||||
if [ ! -z ${!VAR2} ]; then
|
|
||||||
eval $VAR='${!VAR2}'
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "${SHOWPROGRESS}" = "yes" ]; then
|
if [ "${SHOWPROGRESS}" = "yes" ]; then
|
||||||
if ! wget --show-progress -V &>/dev/null; then
|
if ! wget --show-progress -V &>/dev/null; then
|
||||||
warn "Your wget is too old to support --show-progress, ignoring"
|
warn "Your wget is too old to support --show-progress, ignoring"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue