Merge remote-tracking branch 'thingos/dev' into dev

This commit is contained in:
Calin Crisan 2019-03-18 23:57:20 +02:00
commit dc82eeefe2
4 changed files with 34 additions and 12 deletions

View File

@ -15,7 +15,7 @@ case "$1" in
${PROG}
test $? == 0 && msg_done || msg_fail
echo "---- booting ${OS_NAME} ${OS_VERSION} ----" >> ${DMESG_LOG}
${PROG_D} -T -w >> ${DMESG_LOG} &
${PROG_D} -w >> ${DMESG_LOG} &
;;
stop)

View File

@ -33,24 +33,45 @@ source ${CONF}
set_current_date_http() {
date_str=$(curl -v -s -m ${DATE_TIMEOUT} -X GET http://${DATE_HOST} 2>&1 | grep Date | sed -e 's/< Date: //')
test -z "${date_str}" && return 1
${PROG_DATE} -u -D "%a, %d %b %Y %H:%M:%S" -s "${date_str}" > /dev/null
return $?
if [[ -n "${date_str}" ]]; then
${PROG_DATE} -u -D "%a, %d %b %Y %H:%M:%S" -s "${date_str}" > /dev/null
logger -t date -s "current system date/time set to $(date) via HTTP"
return 0
else
logger -t date -s "failed to set current system date/time via HTTP"
return 1
fi
}
set_current_date_ntp() {
cat ${NTP_CONF} | grep server | head -n 1 | cut -d ' ' -f 2 | xargs ${PROG_NTPDATE} -t ${DATE_TIMEOUT} -s
if [[ $? == 0 ]]; then
logger -t date -s "current system date/time set to $(date) via NTP"
return 0
else
logger -t date -s "failed to set current system date/time via NTP"
return 1
fi
}
start_http() {
msg_begin "Setting current date using http"
set_current_date_http || set_current_date_http
test $? == 0 && msg_done "$(${PROG_DATE})" || msg_fail
if set_current_date_http; then
sleep_interval=${DATE_INTERVAL}
msg_done "$(${PROG_DATE})"
else
sleep_interval=${DATE_TIMEOUT}
msg_fail
fi
msg_begin "Starting http date updater"
while true; do
sleep ${DATE_INTERVAL}
set_current_date_http
sleep ${sleep_interval}
if set_current_date_http; then
sleep_interval=${DATE_INTERVAL}
else
sleep_interval=${DATE_TIMEOUT}
fi
done &
msg_done
}

View File

@ -31,7 +31,8 @@ fi;
test -f /data/etc/profile && source /data/etc/profile
# global environment variables
set -a
test -f /etc/environment && source /etc/environment
test -f /data/etc/environment && source /data/etc/environment
test -f /boot/etc/environment && source /boot/etc/environment
set +a

View File

@ -162,9 +162,9 @@ fi
if [ -n "$IP" ] && [ -n "$GW" ] && [ -n "$DNS" ]; then
msg "setting static IP configuration"
conf=$BOOT/static_ip.conf
echo "static_ip=\"$IP\"" > $conf
echo "static_gw=\"$GW\"" >> $conf
echo "static_dns=\"$DNS\"" >> $conf
echo "STATIC_IP=\"$IP\"" > $conf
echo "STATIC_GW=\"$GW\"" >> $conf
echo "STATIC_DNS=\"$DNS\"" >> $conf
fi
msg "unmounting sdcard"