mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-07-15 09:42:58 -07:00
.plexupdate location improved
You can now specify a different file than ~/.plexupdate It now also tries to handle sudo better in respect to the location of this file. This closes #38
This commit is contained in:
parent
f3f24fc97e
commit
4837eded60
2 changed files with 52 additions and 5 deletions
|
@ -28,7 +28,9 @@ Obviously you need to change these three so they match your account information.
|
||||||
|
|
||||||
## 3. advanced options
|
## 3. advanced options
|
||||||
|
|
||||||
There are a few other options for the more enterprising user. Setting any of these to `yes` will enable the function.
|
You can point out a different file than ```.plexupdate``` by providing it as the first argument to the script. It HAS to be the FIRST argument, or it will be ignored.
|
||||||
|
|
||||||
|
There are also a few additional options for the more enterprising user. Setting any of these to `yes` will enable the function.
|
||||||
|
|
||||||
- AUTOUPDATE
|
- AUTOUPDATE
|
||||||
Makes plexupdate.sh automatically update itself using git. Note! This will fail if git isn't available on the command line.
|
Makes plexupdate.sh automatically update itself using git. Note! This will fail if git isn't available on the command line.
|
||||||
|
|
|
@ -72,9 +72,50 @@ if [ $? -eq 127 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load settings from config file if it exists
|
# Allow manual control of configfile
|
||||||
if [ -f ~/.plexupdate ]; then
|
if [ ! "$1" = "" -a ! "${1:0:1}" = "-" ]; then
|
||||||
source ~/.plexupdate
|
if [ -f "$1" ]; then
|
||||||
|
source "$1"
|
||||||
|
else
|
||||||
|
echo "ERROR: Cannot load configuration $1" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Load settings from config file if it exists
|
||||||
|
# Also, respect SUDO_USER and try that first
|
||||||
|
if [ "${SUDO_USER}" != "" ]; then
|
||||||
|
# Make sure nothing bad comes from this (since we use eval)
|
||||||
|
ERROR=0
|
||||||
|
if [[ $SUDO_USER == *";"* ]]; then ERROR=1 ; # Allows more commands
|
||||||
|
elif [[ $SUDO_USER == *" "* ]]; then ERROR=1 ; # Space is not a good thing
|
||||||
|
elif [[ $SUDO_USER == *"&"* ]]; then ERROR=1 ; # Spinning off the command is bad
|
||||||
|
elif [[ $SUDO_USER == *"<"* ]]; then ERROR=1 ; # No redirection
|
||||||
|
elif [[ $SUDO_USER == *">"* ]]; then ERROR=1 ; # No redirection
|
||||||
|
elif [[ $SUDO_USER == *"|"* ]]; then ERROR=1 ; # No pipes
|
||||||
|
elif [[ $SUDO_USER == *"~"* ]]; then ERROR=1 ; # No tilde
|
||||||
|
fi
|
||||||
|
if [ ${ERROR} -gt 0 ]; then
|
||||||
|
echo "ERROR: SUDO_USER variable is COMPROMISED: \"${SUDO_USER}\"" >&2
|
||||||
|
exit 255
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Try using original user's config
|
||||||
|
CONFIGDIR="$( eval cd ~${SUDO_USER} 2>/dev/null && pwd )"
|
||||||
|
if [ "${CONFIGDIR}" == "" ]; then
|
||||||
|
echo "WARNING: SUDO_USER \"${SUDO_USER}\" does not have a valid home directory, ignoring." >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${CONFIGDIR}" != "" -a -f "${CONFIGDIR}/.plexupdate" ]; then
|
||||||
|
#echo "INFO: Using \"${SUDO_USER}\" configuration: ${CONFIGDIR}/.plexupdate"
|
||||||
|
source "${CONFIGDIR}/.plexupdate"
|
||||||
|
elif [ -f ~/.plexupdate ]; then
|
||||||
|
# Fallback for compatibility
|
||||||
|
source ~/.plexupdate
|
||||||
|
fi
|
||||||
|
elif [ -f ~/.plexupdate ]; then
|
||||||
|
# Fallback for compatibility
|
||||||
|
source ~/.plexupdate
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! "${RELEASE}" = "" ]; then
|
if [ ! "${RELEASE}" = "" ]; then
|
||||||
|
@ -97,7 +138,11 @@ cronexit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $(basename $0) [-acfhkopqsSuU]"
|
echo "Usage: $(basename $0) [configfile] [-acfhkopqsSuU]"
|
||||||
|
echo ""
|
||||||
|
echo " configfile overrides the default ~/.plexupdate"
|
||||||
|
echo " If used, it must be the FIRST option or it will be ignored"
|
||||||
|
echo ""
|
||||||
echo " -a Auto install if download was successful (requires root)"
|
echo " -a Auto install if download was successful (requires root)"
|
||||||
echo " -c Cron mode, only fatal errors return non-zero cronexit code"
|
echo " -c Cron mode, only fatal errors return non-zero cronexit code"
|
||||||
echo " -d Auto delete after auto install"
|
echo " -d Auto delete after auto install"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue