mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-28 13:46:32 +00:00
Merge remote-tracking branch 'thingos/dev' into dev
This commit is contained in:
commit
30bfb09f74
@ -1,6 +1,6 @@
|
||||
date_timeout=10
|
||||
date_method=http
|
||||
date_host="google.com"
|
||||
date_interval=900
|
||||
date_ntp_server=""
|
||||
DATE_TIMEOUT=10
|
||||
DATE_METHOD=http
|
||||
DATE_HOST="google.com"
|
||||
DATE_INTERVAL=900
|
||||
DATE_NTP_SERVER=""
|
||||
|
||||
|
36
board/common/overlay/etc/init.d/S10sysctl
Executable file
36
board/common/overlay/etc/init.d/S10sysctl
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
SYS_CONF="/etc/sysctl.conf"
|
||||
BOOT_CONF="/boot/sysctl.conf"
|
||||
CONF="/data/etc/sysctl.conf"
|
||||
|
||||
PROG="/sbin/sysctl"
|
||||
|
||||
|
||||
test -n "${OS_VERSION}" || source /etc/init.d/base
|
||||
|
||||
if [[ ! -f ${CONF} && ! -f ${SYS_CONF} && ! -f ${BOOT_CONF} ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
msg_begin "Applying sysctl parameters"
|
||||
test -f ${SYS_CONF} && sysctl -q -p ${SYS_CONF}
|
||||
test -f ${CONF} && sysctl -q -p ${CONF}
|
||||
test -f ${BOOT_CONF} && sysctl -q -p ${BOOT_CONF}
|
||||
msg_done
|
||||
;;
|
||||
|
||||
stop)
|
||||
true
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
@ -1,7 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Date executable points to /bin/busybox\ date explicitly in the cases that date binary gets overwritten
|
||||
DATE_PROG=/bin/busybox\ date
|
||||
PROG_DATE="/bin/date"
|
||||
PROG_NTPD="/usr/sbin/ntpd"
|
||||
PROG_NTPDATE="/usr/sbin/ntpdate"
|
||||
|
||||
SYS_CONF="/etc/date.conf"
|
||||
BOOT_CONF="/boot/date.conf"
|
||||
@ -21,33 +22,34 @@ test -f ${CONF} || exit 0
|
||||
|
||||
test "${OS_NETWORKLESS}" == "true" && exit 0
|
||||
|
||||
date_timeout=10
|
||||
date_method=http
|
||||
date_host="google.com"
|
||||
date_interval="900"
|
||||
DATE_TIMEOUT=10
|
||||
DATE_METHOD=http
|
||||
DATE_HOST="google.com"
|
||||
DATE_INTERVAL="900"
|
||||
DATE_NTP_SERVER=""
|
||||
|
||||
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: //')
|
||||
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
|
||||
${DATE_PROG} -u -D "%a, %d %b %Y %H:%M:%S" -s "${date_str}" > /dev/null
|
||||
${PROG_DATE} -u -D "%a, %d %b %Y %H:%M:%S" -s "${date_str}" > /dev/null
|
||||
return $?
|
||||
}
|
||||
|
||||
set_current_date_ntp() {
|
||||
cat ${NTP_CONF} | grep server | head -n 1 | cut -d ' ' -f 2 | xargs ntpdate -t ${date_timeout} -s
|
||||
cat ${NTP_CONF} | grep server | head -n 1 | cut -d ' ' -f 2 | xargs ${PROG_NTPDATE} -t ${DATE_TIMEOUT} -s
|
||||
}
|
||||
|
||||
start_http() {
|
||||
msg_begin "Setting current date using http"
|
||||
set_current_date_http || set_current_date_http
|
||||
test $? == 0 && msg_done "$(${DATE_PROG})" || msg_fail
|
||||
test $? == 0 && msg_done "$(${PROG_DATE})" || msg_fail
|
||||
|
||||
msg_begin "Starting http date updater"
|
||||
while true; do
|
||||
sleep ${date_interval}
|
||||
sleep ${DATE_INTERVAL}
|
||||
set_current_date_http
|
||||
done &
|
||||
msg_done
|
||||
@ -58,8 +60,8 @@ start_ntp() {
|
||||
|
||||
cat ${NTP_CONF} | grep -v iburst > ${NTP_CONF}.tmp
|
||||
|
||||
if [[ -n "${date_ntp_server}" ]]; then
|
||||
echo "server ${date_ntp_server} iburst" > ${NTP_CONF}
|
||||
if [[ -n "${DATE_NTP_SERVER}" ]]; then
|
||||
echo "server ${DATE_NTP_SERVER} iburst" > ${NTP_CONF}
|
||||
else
|
||||
cat ${SYS_NTP_CONF} | grep iburst > ${NTP_CONF}
|
||||
fi
|
||||
@ -69,10 +71,10 @@ start_ntp() {
|
||||
|
||||
msg_begin "Setting current date using ntp"
|
||||
set_current_date_ntp || set_current_date_ntp
|
||||
test $? == 0 && msg_done "$(${DATE_PROG})" || msg_fail
|
||||
test $? == 0 && msg_done "$(${PROG_DATE})" || msg_fail
|
||||
|
||||
msg_begin "Starting ntpd"
|
||||
ntpd -g -c ${NTP_CONF}
|
||||
${PROG_NTPD} -g -c ${NTP_CONF}
|
||||
test $? == 0 && msg_done || msg_fail
|
||||
}
|
||||
|
||||
@ -84,22 +86,22 @@ stop_http() {
|
||||
|
||||
stop_ntp() {
|
||||
msg_begin "Stopping ntpd"
|
||||
killall ntpd &>/dev/null
|
||||
killall -q $(basename ${PROG_NTPD})
|
||||
test $? == 0 && msg_done || msg_fail
|
||||
}
|
||||
|
||||
start() {
|
||||
if [[ "${date_method}" == "http" ]]; then
|
||||
if [[ "${DATE_METHOD}" == "http" ]]; then
|
||||
start_http
|
||||
else
|
||||
start_ntp
|
||||
fi
|
||||
|
||||
echo "system date is $(${DATE_PROG} '+%Y-%m-%d %H:%M:%S')" > /dev/kmsg
|
||||
echo "system date is $(${PROG_DATE} '+%Y-%m-%d %H:%M:%S')" > /dev/kmsg
|
||||
}
|
||||
|
||||
stop() {
|
||||
if [[ "${date_method}" == "http" ]]; then
|
||||
if [[ "${DATE_METHOD}" == "http" ]]; then
|
||||
stop_http
|
||||
else
|
||||
stop_ntp
|
||||
|
Loading…
x
Reference in New Issue
Block a user