Compare commits

...

2 Commits

Author SHA1 Message Date
Asif Bacchus
e495b65b24 check for root 2019-07-26 02:33:57 -06:00
Asif Bacchus
ebc77e8137 test for pilerexport and use found full path 2019-07-26 02:29:05 -06:00

16
pilerBackup/pilerbackup.sh Normal file → Executable file
View File

@ -322,6 +322,17 @@ done
### check pre-requisites and default values
# check if running as root, otherwise exit
if [ $( id -u ) -ne 0 ]; then
printf "\n${err}ERROR: script MUST be run as ROOT${norm}\n\n"
exit 2
fi
# find pilerexport, otherwise this is all pointless
pilerExport=$( command -v pilerexport )
if [ ! "$pilerExport" ]; then
printf "\n${err}ERROR: cannot find 'pilerexport'${norm}\n\n"
exit 4
fi
# does the details file exist?
if [ ! -f "$configDetails" ]; then
badParam dne "(--details default)" "$configDetails"
@ -404,13 +415,13 @@ printf "\n${yellow}%s/${cyan} --${norm}\n" "$exportDir" >> "$logFile"
printf "${cyan}[%s] -- [INFO] Exporting EML files from piler --${norm}\n" \
"$(stamp)" >> "$logFile"
if [ "$exportAll" -eq 1 ]; then
if ! pilerexport -A 2>>"$logFile"; then
if ! ${pilerExport} -A 2>>"$logFile"; then
exitError 115 "There was a problem while exporting EML from piler"
fi
printf "${ok}[%s] -- [SUCCESS] Exported EML files from piler --${norm}\n" \
"$(stamp)" >> "$logFile"
else
if ! pilerexport -a "$exportStart" -b "$exportEnd" 2>>"$logFile"; then
if ! ${pilerExport} -a "$exportStart" -b "$exportEnd" 2>>"$logFile"; then
exitError 115 "There was a problem while exporting EML from piler"
fi
printf "${ok}[%s] -- [SUCCESS] Exported EML files from piler --${norm}\n" \
@ -637,6 +648,7 @@ exit 0
# 1: parameter error
# 2: not run as root
# 3: borg not installed
# 4: cannot find pilerexport executable
# 99: TERM signal trapped
# 111: could not create tmp dir for EML dump from piler-export
# 112: could not set permissions on tmp dir