From e6da8ab8423674b7f71cffed308f9f196ecdf1fe Mon Sep 17 00:00:00 2001 From: OoGuru Date: Thu, 21 Dec 2017 12:53:02 +0100 Subject: [PATCH] Add config argument Add config to arguments using --config= or -c=, also quotes can be used for paths with spaces. If config argument is not used it will check for config in the same folder as before. Add config path to log level debug. --- update_ombi.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/update_ombi.sh b/update_ombi.sh index d73f4df..365ee18 100644 --- a/update_ombi.sh +++ b/update_ombi.sh @@ -67,6 +67,16 @@ while [ $# -gt 0 ]; do exit 1 fi ;; + --config|-c=*) + if [[ ${1#*=} =~ ^\"?.*\.conf\"?$ ]]; then + configfile="${1#*=}" + else + printf "******************************\n" + printf "* Error: Invalid config path.*\n" + printf "******************************\n" + exit 1 + fi + ;; *) printf "****************************\n" printf "* Error: Invalid argument. *\n" @@ -103,10 +113,14 @@ unzip-strip() ( ) # Import any custom config to override the defaults, if necessary -configfile="$(dirname $0)/update_ombi.conf" +if [ -z "$configfile" ]; then + configfile="$(dirname $0)/update_ombi.conf" +fi + if [ -e $configfile ]; then source $configfile > /dev/null 2>&1 .log 6 "Script config file found...parsing..." + .log 7 "Config path is: $configfile" if [ $? -ne 0 ] ; then .log 3 "Unable to use config file...using defaults..." else @@ -334,4 +348,4 @@ elif [ $seconds -eq 1 ]; then fi durationmsg="Update complete...elapsed time $duration..." durationmsg="${durationmsg// / }" -.log 6 "$durationmsg" \ No newline at end of file +.log 6 "$durationmsg"