Allow script to run with sudo

Load .plexupdate file from the user's home folder, instead of /root/, when script is executed using sudo.
Fixes #38
This commit is contained in:
Guillaume Boudreau 2016-03-01 08:56:18 -05:00
commit 43a8e41e5a

View file

@ -65,8 +65,12 @@ if [ $? -eq 127 ]; then
fi
# Load settings from config file if it exists
if [ -f ~/.plexupdate ]; then
source ~/.plexupdate
CONFIG_FILE="${HOME}/.plexupdate"
if [[ ! -z ${SUDO_USER} ]] ; then
CONFIG_FILE="`eval echo ~${SUDO_USER}`/.plexupdate"
fi
if [ -f ${CONFIG_FILE} ]; then
source ${CONFIG_FILE}
fi
if [ "${RELEASE}" = "64-bit" ]; then