From 43a8e41e5ab9fd037914c6ffec6eed620dec29c5 Mon Sep 17 00:00:00 2001 From: Guillaume Boudreau Date: Tue, 1 Mar 2016 08:56:18 -0500 Subject: [PATCH] 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 --- plexupdate.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index 6a448d2..259b756 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -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