reworked error management, added --logfile option, reworked command line analysing
This commit is contained in:
13
init.sh
13
init.sh
@@ -9,7 +9,7 @@ set -o pipefail
|
||||
set -o errtrace
|
||||
|
||||
# set -e : exit the script if any statement returns a non-true return value
|
||||
set -o errexit
|
||||
#set -o errexit
|
||||
|
||||
# set +u : allow undeclared variables
|
||||
set +o nounset
|
||||
@@ -19,7 +19,7 @@ export LC_ALL=C
|
||||
export LANG=C
|
||||
|
||||
# Version of init
|
||||
export VERSION="0.95.2"
|
||||
export VERSION="0.95.4"
|
||||
|
||||
# Store script's path
|
||||
export MYPATH=$(dirname $0)
|
||||
@@ -59,7 +59,7 @@ export KEEPGOING=false
|
||||
export RESUME=false
|
||||
export STAGE_FILE="$MYPATH/stage"
|
||||
|
||||
read_commandline
|
||||
read_commandline $@
|
||||
|
||||
# After this we need to be root
|
||||
# (--help and --version are allowed as unprivileged user)
|
||||
@@ -67,7 +67,11 @@ check_root
|
||||
|
||||
# Logfile variable treatment -- cannot be a function
|
||||
|
||||
export LOGFILE=${LOGFILE:-"$MYPATH/log/init-$(uname -n)-$(stdtime).log"}
|
||||
if [[ -n $NEW_LOGFILE ]]; then
|
||||
export LOGFILE=$NEW_LOGFILE
|
||||
else
|
||||
export LOGFILE=${LOGFILE:-"$MYPATH/log/init-$(uname -n)-$(stdtime).log"}
|
||||
fi
|
||||
|
||||
prnt I "Création du répertoire d'accueil du fichier log..."
|
||||
[[ ! -d $(dirname $LOGFILE) ]] && mkdir -pv $(dirname $LOGFILE)
|
||||
@@ -78,6 +82,7 @@ trap 'exec 2>&4 1>&3' 0 1 2 3
|
||||
exec > >(tee -a $LOGFILE)
|
||||
exec 2> >(tee -a $LOGFILE >&2)
|
||||
prnt I "Démarrage d'init version $VERSION."
|
||||
prnt I "Le fichier de log est $LOGFILE."
|
||||
|
||||
# -- Cannot be a function ends here
|
||||
|
||||
|
||||
Reference in New Issue
Block a user