mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-06-08 01:18:32 +08:00
Colors in log
This commit is contained in:
parent
b134334fed
commit
b7506b2bee
@ -7,11 +7,11 @@ HEADER="VirtualDSM Agent"
|
|||||||
# Functions
|
# Functions
|
||||||
|
|
||||||
error () { echo -e "\E[1;31m❯ ERROR: $1\E[0m" ; }
|
error () { echo -e "\E[1;31m❯ ERROR: $1\E[0m" ; }
|
||||||
info () { echo -e "\E[1;34m❯\E[1;36m $HEADER: $1\E[0m" ; }
|
info () { echo -e "\E[1;34m❯\E[1;36m $1\E[0m" ; }
|
||||||
|
|
||||||
finish() {
|
finish() {
|
||||||
|
|
||||||
info "Shutting down.."
|
echo "$HEADER: Shutting down.."
|
||||||
exit
|
exit
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -51,27 +51,27 @@ function downloadUpdate {
|
|||||||
[[ remote_size -eq local_size ]] && return
|
[[ remote_size -eq local_size ]] && return
|
||||||
|
|
||||||
if ! curl -sfk -m 10 -o "${TMP}" "${URL}"; then
|
if ! curl -sfk -m 10 -o "${TMP}" "${URL}"; then
|
||||||
info "curl error ($?)" && return
|
error "$HEADER: curl error ($?)" && return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "${TMP}" ]; then
|
if [ ! -f "${TMP}" ]; then
|
||||||
info "update error, file not found.." && return
|
error "$HEADER: update error, file not found.." && return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
line=$(head -1 "${TMP}")
|
line=$(head -1 "${TMP}")
|
||||||
|
|
||||||
if [[ "$line" != "#!/usr/bin/env bash" ]]; then
|
if [[ "$line" != "#!/usr/bin/env bash" ]]; then
|
||||||
info "update error, invalid header: $line" && return
|
error "$HEADER: update error, invalid header: $line" && return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if cmp --silent -- "${TMP}" "${SCRIPT}"; then
|
if cmp --silent -- "${TMP}" "${SCRIPT}"; then
|
||||||
info "update file is already equal? (${local_size} / ${remote_size})" && return
|
error "$HEADER: update file is already equal? (${local_size} / ${remote_size})" && return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mv -f "${TMP}" "${SCRIPT}"
|
mv -f "${TMP}" "${SCRIPT}"
|
||||||
chmod 755 "${SCRIPT}"
|
chmod 755 "${SCRIPT}"
|
||||||
|
|
||||||
info "succesfully installed update, please reboot."
|
info "$HEADER: succesfully installed update, please reboot."
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ function installPackages {
|
|||||||
trap finish SIGINT SIGTERM
|
trap finish SIGINT SIGTERM
|
||||||
|
|
||||||
ts=$(date +%s%N)
|
ts=$(date +%s%N)
|
||||||
info "running v$VERSION"
|
echo "Started $HEADER v$VERSION..."
|
||||||
|
|
||||||
checkNMI
|
checkNMI
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user