mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-28 13:46:32 +00:00
a date init script that doesn't use python
This commit is contained in:
parent
87eb68dac9
commit
c6e47de04d
@ -38,22 +38,10 @@ date_interval="900"
|
||||
|
||||
source $conf
|
||||
|
||||
kill_after_timeout() {
|
||||
sleep $date_timeout
|
||||
ps aux | grep httplib | grep -v grep | tr -s ' ' | cut -d ' ' -f 2 | xargs -r kill
|
||||
}
|
||||
|
||||
set_current_date_http() {
|
||||
kill_after_timeout &
|
||||
|
||||
timestamp=$(python -c "import calendar, httplib, email.utils; conn = httplib.HTTPConnection('$date_host'); conn.request('HEAD', '/'); \
|
||||
print calendar.timegm(email.utils.parsedate(conn.getresponse().getheader('date')))")
|
||||
|
||||
if [ -n "$timestamp" ]; then
|
||||
date +%s -s @$timestamp > /dev/null
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
date_str=$(curl -v -s -m $date_timeout -X GET http://$date_host 2>&1 | grep Date | sed -e 's/< Date: //')
|
||||
date -D "%a, %d %b %Y %H:%M:%S" -s "$date_str" > /dev/null
|
||||
return $?
|
||||
}
|
||||
|
||||
set_current_date_ntp() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user