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