mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2026-03-04 15:54:48 +01:00
Improve formatting of setup output
This commit is contained in:
@@ -49,11 +49,18 @@ dump_file_if_exists() {
|
||||
}
|
||||
|
||||
update_system_time() {
|
||||
if [ ! -x /usr/sbin/ntpdate ]; then
|
||||
wait_for_apt
|
||||
apt-get install -y -qq ntpdate || return 1
|
||||
if systemctl is-active --quiet ntp; then
|
||||
# ntpd is running and running ntpdate will fail with "the NTP
|
||||
# socket is in use"
|
||||
echo "ntpd is already running, not updating time"
|
||||
return 0
|
||||
fi
|
||||
ntpdate -s ntp.ubuntu.com && echo "System time updated"
|
||||
if [ ! -x /usr/sbin/ntpdate ]; then
|
||||
echo "Installing ntpdate"
|
||||
wait_for_apt
|
||||
exec_no_output apt-get install -y ntpdate || return 1
|
||||
fi
|
||||
ntpdate ntp.ubuntu.com
|
||||
}
|
||||
|
||||
set_system_hostname() {
|
||||
@@ -110,3 +117,26 @@ install_docker() {
|
||||
|| return 5
|
||||
}
|
||||
|
||||
|
||||
exec_no_output() {
|
||||
# This function hides the output of a command unless the command
|
||||
# fails
|
||||
local of=$(mktemp)
|
||||
"$@" &> "$of"
|
||||
local code=$?
|
||||
|
||||
if [ $code -ne 0 ]; then
|
||||
echo "" 1>&2
|
||||
echo "FAILED: $@" 1>&2
|
||||
echo "-----------------------------------------" 1>&2
|
||||
echo "Return code: $code" 1>&2
|
||||
echo "Output:" 1>&2
|
||||
cat "$of" 1>&2
|
||||
echo "-----------------------------------------" 1>&2
|
||||
fi
|
||||
|
||||
# Remove temporary file.
|
||||
rm -f "$of"
|
||||
[ $code -ne 0 ] && return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user