From 59b7562a3e2c635175f739774d362e6b4a5a866a Mon Sep 17 00:00:00 2001 From: deajan Date: Mon, 1 Oct 2018 20:43:27 +0200 Subject: [PATCH] Fixed Logger missing RUN_DIR --- dev/common_batch.sh | 13 +++++++++++-- dev/common_install.sh | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/dev/common_batch.sh b/dev/common_batch.sh index d01d6e7..ed06067 100755 --- a/dev/common_batch.sh +++ b/dev/common_batch.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash SUBPROGRAM=[prgname] PROGRAM="$SUBPROGRAM-batch" # Batch program to run osync / obackup instances sequentially and rerun failed ones -AUTHOR="(L) 2013-2017 by Orsiris de Jong" +AUTHOR="(L) 2013-2018 by Orsiris de Jong" CONTACT="http://www.netpower.fr - ozy@netpower.fr" -PROGRAM_BUILD=2016120401 +PROGRAM_BUILD=2018100101 ## Runs an osync /obackup instance for every conf file found ## If an instance fails, run it again if time permits @@ -26,6 +26,15 @@ else LOG_FILE=./$SUBPROGRAM-batch.log fi +## Default directory where to store temporary run files +if [ -w /tmp ]; then + RUN_DIR=/tmp +elif [ -w /var/tmp ]; then + RUN_DIR=/var/tmp +else + RUN_DIR=. +fi + # No need to edit under this line ############################################################## function _logger { diff --git a/dev/common_install.sh b/dev/common_install.sh index c2d9cb1..26998c0 100755 --- a/dev/common_install.sh +++ b/dev/common_install.sh @@ -2,8 +2,6 @@ ## Installer script suitable for osync / obackup / pmocr -include #### _OFUNCTIONS_BOOTSTRAP SUBSET #### - PROGRAM=[prgname] PROGRAM_VERSION=$(grep "PROGRAM_VERSION=" $PROGRAM.sh) @@ -12,12 +10,15 @@ PROGRAM_BINARY=$PROGRAM".sh" PROGRAM_BATCH=$PROGRAM"-batch.sh" SSH_FILTER="ssh_filter.sh" -SCRIPT_BUILD=2018070201 +SCRIPT_BUILD=2018090301 +INSTANCE_ID="installer-$SCRIPT_BUILD" ## osync / obackup / pmocr / zsnap install script ## Tested on RHEL / CentOS 6 & 7, Fedora 23, Debian 7 & 8, Mint 17 and FreeBSD 8, 10 and 11 ## Please adapt this to fit your distro needs +include #### _OFUNCTIONS_BOOTSTRAP SUBSET #### + # Get current install.sh path from http://stackoverflow.com/a/246128/2635443 SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -85,6 +86,15 @@ else LOG_FILE="./$PROGRAM-install.log" fi +## Default directory where to store temporary run files +if [ -w /tmp ]; then + RUN_DIR=/tmp +elif [ -w /var/tmp ]; then + RUN_DIR=/var/tmp +else + RUN_DIR=. +fi + include #### Logger SUBSET #### include #### UrlEncode SUBSET #### include #### GetLocalOS SUBSET #### @@ -344,6 +354,26 @@ function Usage { exit 127 } +############################## Script entry point + +if [ "$LOGFILE" == "" ]; then + if [ -w /var/log ]; then + LOG_FILE="/var/log/$PROGRAM.$INSTANCE_ID.log" + elif ([ "$HOME" != "" ] && [ -w "$HOME" ]); then + LOG_FILE="$HOME/$PROGRAM.$INSTANCE_ID.log" + else + LOG_FILE="./$PROGRAM.$INSTANCE_ID.log" + fi +else + LOG_FILE="$LOGFILE" +fi +if [ ! -w "$(dirname $LOG_FILE)" ]; then + echo "Cannot write to log [$(dirname $LOG_FILE)]." +else + Logger "Script begin, logging to [$LOG_FILE]." "DEBUG" +fi + + GetLocalOS SetLocalOSSettings GetInit