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
9f9d32f0f9
commit
3bc53e7f1e
@ -6,9 +6,12 @@ HEADER="VirtualDSM Agent"
|
|||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
|
|
||||||
|
error () { echo -e "\E[1;31m❯ ERROR: $1\E[0m" ; }
|
||||||
|
info () { echo -e "\E[1;34m❯\E[1;36m $HEADER: $1\E[0m" ; }
|
||||||
|
|
||||||
finish() {
|
finish() {
|
||||||
|
|
||||||
echo "$HEADER: Shutting down.."
|
info "Shutting down.."
|
||||||
exit
|
exit
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -20,7 +23,7 @@ function checkNMI {
|
|||||||
|
|
||||||
if [ "$nmi" != "" ]; then
|
if [ "$nmi" != "" ]; then
|
||||||
|
|
||||||
echo "$HEADER: Received shutdown request through NMI.."
|
info "Received shutdown request through NMI.."
|
||||||
|
|
||||||
/usr/syno/sbin/synoshutdown -s > /dev/null
|
/usr/syno/sbin/synoshutdown -s > /dev/null
|
||||||
finish
|
finish
|
||||||
@ -48,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
|
||||||
echo "$HEADER: curl error ($?)" && return
|
info "curl error ($?)" && return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "${TMP}" ]; then
|
if [ ! -f "${TMP}" ]; then
|
||||||
echo "$HEADER: update error, file not found.." && return
|
info "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
|
||||||
echo "$HEADER: update error, invalid header: $line" && return
|
info "update error, invalid header: $line" && return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if cmp --silent -- "${TMP}" "${SCRIPT}"; then
|
if cmp --silent -- "${TMP}" "${SCRIPT}"; then
|
||||||
echo "$HEADER: update file is already equal? (${local_size} / ${remote_size})" && return
|
info "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}"
|
||||||
|
|
||||||
echo "$HEADER: succesfully installed update, please reboot."
|
info "succesfully installed update, please reboot."
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +85,7 @@ function installPackages {
|
|||||||
|
|
||||||
[[ $BASE == "ActiveInsight" ]] && continue
|
[[ $BASE == "ActiveInsight" ]] && continue
|
||||||
|
|
||||||
echo "$HEADER: Installing package ${BASE}.."
|
info "Installing package ${BASE}.."
|
||||||
|
|
||||||
/usr/syno/bin/synopkg install "$filename" > /dev/null
|
/usr/syno/bin/synopkg install "$filename" > /dev/null
|
||||||
/usr/syno/bin/synopkg start "$BASE" > /dev/null &
|
/usr/syno/bin/synopkg start "$BASE" > /dev/null &
|
||||||
@ -97,7 +100,7 @@ function installPackages {
|
|||||||
trap finish SIGINT SIGTERM
|
trap finish SIGINT SIGTERM
|
||||||
|
|
||||||
ts=$(date +%s%N)
|
ts=$(date +%s%N)
|
||||||
echo "$HEADER v$VERSION"
|
info "running v$VERSION"
|
||||||
|
|
||||||
checkNMI
|
checkNMI
|
||||||
|
|
||||||
@ -140,9 +143,9 @@ else
|
|||||||
MSG="http://${IP}:5000"
|
MSG="http://${IP}:5000"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "--------------------------------------------------------"
|
info "--------------------------------------------------------"
|
||||||
echo " You can now login to DSM at ${MSG}"
|
info " You can now login to DSM at ${MSG}"
|
||||||
echo "--------------------------------------------------------"
|
info "--------------------------------------------------------"
|
||||||
|
|
||||||
# Wait for NMI interrupt as a shutdown signal
|
# Wait for NMI interrupt as a shutdown signal
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user