From 44e2b93377b49e9ce5130764fe4925ecfbe0ce10 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Thu, 23 May 2019 21:06:49 -0600 Subject: [PATCH] process parameters --- backup_new.sh | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/backup_new.sh b/backup_new.sh index 9846195..a339891 100755 --- a/backup_new.sh +++ b/backup_new.sh @@ -60,7 +60,7 @@ logFile="$scriptPath/${scriptName%.*}.log" # borg output verbosity -- normal borgCreateParams='--stats' borgPruneParams='--list' -detailsFile="$scriptPath/seafbackup.details" +configDetails="$scriptPath/seafbackup.details" # 503 related err503Path="$scriptPath/503_backup.html" @@ -76,6 +76,96 @@ seafDir="/opt/seafile" seafData="/var/seafile" +### process startup parameters +while [ $# -gt 0 ]; do + case "$1" in + -h|-\?|--help) + # display help + scriptHelp + exit 0 + ;; + -l|--log) + # set log file location + if [ -n "$2" ]; then + logFile="${2%/}" + shift + else + badParam "$@" + fi + ;; + -v|--verbose) + # set verbose logging from borg + borgCreateParams='--list --stats' + borgPruneParams='--list' + ;; + -c|--config|--details) + # location of config details file + if [ -n "$2" ]; then + configDetails="${2%/}" + shift + else + badParam "$@" + fi + ;; + -5|--503) + # FULL path to 503 file + if [ -n "$2" ]; then + err503Path="${2%/}" + err503File="${2##*/}" + shift + else + badParam "$@" + fi + ;; + -w|--webroot) + # path to webroot (copy 503) + if [ -n "$2" ]; then + webroot="${2%/}" + shift + else + badParam "$@" + fi + ;; + -p|--seaf|--seafdir) + # path to seafile program directory + if [ -n "$2" ]; then + seafDir="${2%/}" + shift + else + badParam "$@" + fi + ;; + -d|--data|--datadir|--seafdata) + # path to seafile data directory + if [ -n "$2" ]; then + seafData="${2%/}" + shift + else + badParam "$@" + fi + ;; + -o|--offline) + # shutdown seafile during backup + offlineBackup=1 + ;; + -u|--user|--seafuser) + # name of seafile system user + if [ -n "$2" ]; then + seafUser="${2%/}" + shift + else + badParam "$@" + fi + ;; + *) + printf "${err}\nUnknown option: %s\n" "$1" + printf "${cyan}Use '--help' for valid options.{$norm}\n\n" + exit 1 + ;; + esac + shift +done + ### start logging printf "${mag}[%s] --- Start %s execution ---${norm}\n" \