style(RESTORE): reformat

This commit is contained in:
Asif Bacchus 2021-02-05 03:11:10 -07:00
parent 1cbbf3d66d
commit 5c7064e2bd
1 changed files with 52 additions and 65 deletions

View File

@ -31,7 +31,6 @@ else
yellow=''
fi
### trap
trap trapExit 1 2 3 6
@ -139,13 +138,11 @@ mcDockerCompose='/opt/mailcow-dockerized/docker-compose.yml'
dockerStartTimeout=180
dockerStopTimeout=120
### check if user is root
if [ "$(id -u)" -ne 0 ]; then
consoleError '2' "This script must be run as ROOT."
fi
### process startup parameters
while [ $# -gt 0 ]; do
case "$1" in
@ -162,7 +159,6 @@ while [ $# -gt 0 ]; do
shift
done
### pre-flight checks
# docker installed?
if ! command -v docker >/dev/null; then
@ -185,14 +181,12 @@ if [ ! -f "$mcDockerCompose" ]; then
consoleError '1' "docker-compose configuration ($mcDockerCompose) cannot be found."
fi
### read mailcow.conf and import vars
# shellcheck source=./mailcow.conf.shellcheck
. "$mcConfig"
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export COMPOSE_HTTP_TIMEOUT="$dockerStartTimeout"
### start logging
# verify logfile specification is valid
if ! printf "%s" "$logfile" | grep -o / >/dev/null; then
@ -222,7 +216,6 @@ if ! printf "%s[%s] --- Start %s execution ---\n%s" "$magenta" "$(stamp)" "$scri
fi
writeLog 'info' "Log located at $logfile"
### get location of docker volumes
dockerVolumeMail=$(docker volume inspect -f '{{ .Mountpoint }}' ${COMPOSE_PROJECT_NAME}_vmail-vol-1)
printf "%s[%s] -- [INFO] Using MAIL volume: %s --%s\n" \
@ -240,7 +233,6 @@ dockerVolumeCrypt=$(docker volume inspect -f '{{ .Mountpoint }}' ${COMPOSE_PROJE
printf "%s[%s] -- [INFO] Using MAILCRYPT volume: %s --%s\n" \
"$cyan" "$(stamp)" "$dockerVolumeCrypt" "$norm" >>"$logfile"
### source configuration details file
case "${configDetails}" in
/*)
@ -256,7 +248,6 @@ case "${configDetails}" in
esac
writeLog 'info' "Configuration file: ${yellow}${configDetails}${info} imported"
### verify borg variables
# verify borg base directory
writeLog 'task' 'Verify details:borgBaseDir'
@ -315,7 +306,6 @@ fi
# export borg remote path, if specified
if [ -n "${borgRemote}" ]; then export BORG_REMOTE_PATH="${borgRemote}"; fi
### create borg temp dir
## python requires a writable temporary directory when unpacking borg and
## executing commands. This defaults to /tmp but many systems mount /tmp with
@ -331,7 +321,6 @@ if [ ! -d "${borgBaseDir}/tmp" ]; then
fi
export TMPDIR="${borgBaseDir}/tmp"
### change to mailcow directory so docker commands run properly
cd "$(dirname ${mcConfig})" || writeLog 'error' '100' "Could not change to mailcow directory." && exitError 100
@ -343,7 +332,6 @@ cd "$(dirname ${mcConfig})" || writeLog 'error' '100' "Could not change to mailc
#TODO: optionally reindex dovecot (parameter)
#TODO: delete downloaded backup (parameter)
### exit gracefully
writeLog 'success' "All processes completed"
printf "%s[%s] --- %s execution completed ---\n%s" "$magenta" "$(stamp)" "$scriptName" "$norm" >>"$logfile"
@ -357,7 +345,6 @@ if [ "$warnCount" -gt 0 ]; then
fi
exit 0
### error codes:
# 1: parameter error
# 2: not run as root