diff options
Diffstat (limited to 'contrib/package/freifunk-common/files/usr/sbin')
-rwxr-xr-x | contrib/package/freifunk-common/files/usr/sbin/ff_olsr_watchdog | 29 | ||||
-rwxr-xr-x | contrib/package/freifunk-common/files/usr/sbin/ff_rdate | 20 |
2 files changed, 49 insertions, 0 deletions
diff --git a/contrib/package/freifunk-common/files/usr/sbin/ff_olsr_watchdog b/contrib/package/freifunk-common/files/usr/sbin/ff_olsr_watchdog new file mode 100755 index 0000000000..aa8de61622 --- /dev/null +++ b/contrib/package/freifunk-common/files/usr/sbin/ff_olsr_watchdog @@ -0,0 +1,29 @@ +#!/usr/bin/lua + +require "os" +require "io" +require "uci" +local fs = require "nixio.fs" + +if fs.access("/var/run/olsrd.pid") then + local stamp, intv + local x = uci.cursor() + + x:foreach("olsrd", "LoadPlugin", + function(s) + if s.library == "olsrd_watchdog.so.0.1" then + intv = tonumber(s.interval) + stamp = s.file + end + end) + + if intv and fs.access(stamp) then + local systime = os.time() + local wdgtime = tonumber(io.lines(stamp)()) + + if not wdgtime or ( systime - wdgtime ) > ( intv * 2 ) then + os.execute("logger -t 'OLSR watchdog' 'Process died - restarting!'") + os.execute("/etc/init.d/olsrd restart") + end + end +end diff --git a/contrib/package/freifunk-common/files/usr/sbin/ff_rdate b/contrib/package/freifunk-common/files/usr/sbin/ff_rdate new file mode 100755 index 0000000000..dc2c7b2d2c --- /dev/null +++ b/contrib/package/freifunk-common/files/usr/sbin/ff_rdate @@ -0,0 +1,20 @@ +#!/bin/sh + +uci_get_one() { + for var in "$@"; do + uci -P /var/state get "$var" 2>/dev/null && break + done +} + +local servers="$(uci_get_one 'network.wan.lease_timesrv') $(uci show timeserver | sed -ne 's/.*hostname=//p')" + +if [ -n "$servers" ]; then + for server in $servers; do + rdate -s $server >/dev/null 2>/dev/null && \ + logger -t rdate "Synced with $server" && break + + logger -t rdate "Failed to sync with $server" + done +else + logger -t rdate "No usable time server found" +fi |