mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-06-08 09:27:45 +08:00
Measure elapsed time
This commit is contained in:
parent
20eabf1b23
commit
068c82faf9
@ -28,6 +28,8 @@ finish() {
|
|||||||
|
|
||||||
trap finish SIGINT SIGTERM
|
trap finish SIGINT SIGTERM
|
||||||
|
|
||||||
|
ts=$(date +%s%N)
|
||||||
|
|
||||||
# Setup serialport
|
# Setup serialport
|
||||||
|
|
||||||
chmod 666 /dev/ttyS0
|
chmod 666 /dev/ttyS0
|
||||||
@ -62,19 +64,18 @@ if [ "$first_run" = true ]; then
|
|||||||
done
|
done
|
||||||
else
|
else
|
||||||
|
|
||||||
# TODO: Auto-update agent
|
|
||||||
echo "Checking for updates.." > /dev/ttyS0
|
|
||||||
|
|
||||||
TMP="/tmp/agent.sh"
|
TMP="/tmp/agent.sh"
|
||||||
rm -f "${TMP}"
|
rm -f "${TMP}"
|
||||||
|
|
||||||
|
# Auto update the agent
|
||||||
|
|
||||||
if curl -s -f -k -m 5 -o "${TMP}" https://raw.githubusercontent.com/kroese/virtual-dsm/master/agent/agent.sh; then
|
if curl -s -f -k -m 5 -o "${TMP}" https://raw.githubusercontent.com/kroese/virtual-dsm/master/agent/agent.sh; then
|
||||||
if [ -f "${TMP}" ]; then
|
if [ -f "${TMP}" ]; then
|
||||||
line=$(head -1 "${TMP}")
|
line=$(head -1 "${TMP}")
|
||||||
if [ "$line" == "#!/usr/bin/env bash" ]; then
|
if [ "$line" == "#!/usr/bin/env bash" ]; then
|
||||||
SCRIPT=$(readlink -f ${BASH_SOURCE[0]})
|
SCRIPT=$(readlink -f ${BASH_SOURCE[0]})
|
||||||
mv -f "${TMP}" "${SCRIPT}"
|
mv -f "${TMP}" "${SCRIPT}"
|
||||||
echo "Moved from ${TMP} to ${SCRIPT}" > /dev/ttyS0
|
chmod +x "${SCRIPT}"
|
||||||
else
|
else
|
||||||
echo "Update error, invalid header: $line" > /dev/ttyS0
|
echo "Update error, invalid header: $line" > /dev/ttyS0
|
||||||
fi
|
fi
|
||||||
@ -85,10 +86,11 @@ else
|
|||||||
echo "Update error, curl error: $?" > /dev/ttyS0
|
echo "Update error, curl error: $?" > /dev/ttyS0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
elapsed=$((($(date +%s%N) - $ts)/1000000))
|
||||||
|
echo "Elapsed time: $elapsed" > /dev/ttyS0
|
||||||
|
|
||||||
# Display message in docker log output
|
# Display message in docker log output
|
||||||
|
|
||||||
echo "-------------------------------------------" > /dev/ttyS0
|
echo "-------------------------------------------" > /dev/ttyS0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user