trap "rm -f '$temp'" EXIT
timedatectl > "$temp"
-ut=$(sed '/Universal time:/ { s/^[^:]*: *//; p}; d' t)
-rtc=$(sed '/RTC time:/ { s/^[^:]*: *//; p}; d' t)
+ut=$(sed '/Universal time:/ { s/^[^:]*: *//; p}; d' "$temp")
+rtc=$(sed '/RTC time:/ { s/^[^:]*: *//; p}; d' "$temp")
uts=$(date -d "$ut" +%s)
rtcs=$(date -d "$rtc" +%s)
fi
-sced=$(sed '/NTP synchronized:/ { s/^[^:]*: *//; p}; d' t)
-if [ "$sced" != "yes" ]; then
+bool=$(sed '/NTP enabled:/ { s/^[^:]*: *//; p}; d' "$temp")
+if [ "$bool" != "yes" ]; then
+ echo "Warning: NTP not enabled!"
+ exit 1
+fi
+
+bool=$(sed '/NTP synchronized:/ { s/^[^:]*: *//; p}; d' "$temp")
+if [ "$bool" != "yes" ]; then
echo "Warning: not synced with NTP (but clock is OK for now)."
exit 1
fi