summaryrefslogtreecommitdiffhomepage
path: root/contrib/package/freifunk-common/files/usr/sbin
diff options
context:
space:
mode:
authorManuel Munz <freifunk@somakoma.de>2011-09-28 00:20:56 +0000
committerManuel Munz <freifunk@somakoma.de>2011-09-28 00:20:56 +0000
commitc3a028c76c294c0578b0449d75f9aeaad209c8d1 (patch)
treeda549085750d64091f3bc43992cf1c8417edd20c /contrib/package/freifunk-common/files/usr/sbin
parent876b191b20a01926657e4d3c618fd2f029f45f4d (diff)
modules/freifunk: Move profiles and common files into seperate packages, this will enable us to build freifunk images without luci.
Diffstat (limited to 'contrib/package/freifunk-common/files/usr/sbin')
-rwxr-xr-xcontrib/package/freifunk-common/files/usr/sbin/ff_olsr_watchdog29
-rwxr-xr-xcontrib/package/freifunk-common/files/usr/sbin/ff_rdate20
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