tree: add ntp timeserver

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium
2024-06-01 09:45:45 +02:00
parent 808c081325
commit f5ebbf9704
3 changed files with 17 additions and 3 deletions

View File

@@ -97,6 +97,8 @@ if [ "${OFFLINE}" = "false" ]; then
REGION="$(curl -v http://ip-api.com/line?fields=timezone 2>/dev/null | tr -d '\n' | cut -d '/' -f1)"
TIMEZONE="$(curl -v http://ip-api.com/line?fields=timezone 2>/dev/null | tr -d '\n' | cut -d '/' -f2)"
ln -fs /usr/share/zoneinfo/${REGION}/${TIMEZONE} /etc/localtime
# NTP
ntptime
fi
###############################################################################

View File

@@ -33,7 +33,7 @@ ZIMAGE_HASH_CUR="$(sha256sum "${ORI_ZIMAGE_FILE}" | awk '{print $1}')"
RAMDISK_HASH="$(readConfigKey "ramdisk-hash" "${USER_CONFIG_FILE}")"
RAMDISK_HASH_CUR="$(sha256sum "${ORI_RDGZ_FILE}" | awk '{print $1}')"
OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
if [[ "${ZIMAGE_HASH_CUR}" != "${ZIMAGE_HASH}" || "${RAMDISK_HASH_CUR}" != "${RAMDISK_HASH}" ]]; then
if [ "${ZIMAGE_HASH_CUR}" != "${ZIMAGE_HASH}" ] || [ "${RAMDISK_HASH_CUR}" != "${RAMDISK_HASH}" ]; then
echo -e "\033[1;31mDSM zImage/Ramdisk changed!\033[0m"
livepatch
echo
@@ -50,7 +50,6 @@ CPU="$(echo $(cat /proc/cpuinfo 2>/dev/null | grep 'model name' | uniq | awk -F'
RAMTOTAL=$(($(free -m | grep -i mem | awk '{print$2}') / 1024 + 1))
RAM="${RAMTOTAL}GB"
VENDOR="$(dmesg 2>/dev/null | grep -i "DMI:" | sed 's/\[.*\] DMI: //i')"
BOOTTIME="$(date)"
echo -e "\033[1;37mDSM:\033[0m"
echo -e "Model: \033[1;37m${MODELID:-${MODEL}}\033[0m"
@@ -62,7 +61,6 @@ echo -e "\033[1;37mSystem:\033[0m"
echo -e "VENDOR: \033[1;37m${VENDOR}\033[0m"
echo -e "CPU: \033[1;37m${CPU}\033[0m"
echo -e "MEM: \033[1;37m${RAM}\033[0m"
echo -e "TIME: \033[1;37m${BOOTTIME}\033[0m"
echo
if ! readConfigMap "addons" "${USER_CONFIG_FILE}" | grep -q nvmesystem; then

View File

@@ -489,4 +489,18 @@ function livepatch() {
writeConfigKey "ramdisk-hash" "${RAMDISK_HASH}" "${USER_CONFIG_FILE}"
echo "DSM Image patched - Ready!"
fi
}
###############################################################################
# Timeserver
function ntptime() {
OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
if [ "${OFFLINE}" = "false" ]; then
# Timezone
REGION="$(curl -v http://ip-api.com/line?fields=timezone 2>/dev/null | tr -d '\n' | cut -d '/' -f1)"
TIMEZONE="$(curl -v http://ip-api.com/line?fields=timezone 2>/dev/null | tr -d '\n' | cut -d '/' -f2)"
ln -fs /usr/share/zoneinfo/${REGION}/${TIMEZONE} /etc/localtime
/etc/init.d/S49ntp restart
hwclock -w
fi
}