new file mode 100755
@@ -0,0 +1,40 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=fff-autorestart
+PKG_VERSION:=1
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/fff-autorestart
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/fff-autorestart
+ SECTION:=base
+ CATEGORY:=Freifunk
+ TITLE:= Freifunk-Franken Auto-Restart
+ URL:=http://www.freifunk-franken.de
+ DEPENDS:=+micrond
+endef
+
+define Package/fff-autorestart/description
+ This restarts the router if no connection
+ to gateways is available
+endef
+
+define Build/Prepare
+ echo "all: " > $(PKG_BUILD_DIR)/Makefile
+endef
+
+define Build/Configure
+ # nothing
+endef
+
+define Build/Compile
+ # nothing
+endef
+
+define Package/fff-autorestart/install
+ $(CP) ./files/* $(1)/
+endef
+
+$(eval $(call BuildPackage,fff-autorestart))
new file mode 100644
@@ -0,0 +1 @@
+*/5 * * * * /usr/sbin/offlinerestart
new file mode 100755
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+UPPER_LIMIT='50' # Above this limit the gateway will be considered online
+LOWER_LIMIT='20' # Below this limit the gateway will be considered offline
+# In-between these two values the state is not changed
+
+NOW=$(date +%s)
+
+if [ -s /tmp/gatewayoff ] && grep -q '0' /tmp/gatewayoff ; then
+ exit 0
+fi
+
+GATEWAY_TQ=$(batctl gwl | grep "^=>" | awk -F'[()]' '{print $2}'| tr -d " ") # Grep the connection quality of the gateway which is currently used
+if [ ! "$GATEWAY_TQ" ]; # If there is no gateway there will be errors in the following if clauses
+then
+ GATEWAY_TQ=0 # Just an easy way to get an valid value if there is no gateway
+fi
+if [ $GATEWAY_TQ -gt $UPPER_LIMIT ];
+then
+ echo "Gateway TQ is $GATEWAY_TQ - Node is online"
+ if [ -s /tmp/gatewayoff ] ; then
+ rm -f /tmp/gatewayoff
+ fi
+fi
+if [ $GATEWAY_TQ -lt $LOWER_LIMIT ];
+then
+ echo "Gateway TQ is $GATEWAY_TQ - Node is considered offline"
+ if [ ! -s /tmp/gatewayoff ] ; then
+ echo "$NOW" > /tmp/gatewayoff
+ fi
+ OFFLINESINCE=$(($(date +%s)-1800)) # Restart after 30 minutes
+ if [ "$(cat /tmp/gatewayoff)" -lt "$OFFLINESINCE" ] ; then
+ #rm -f /tmp/gatewayoff
+ reboot && exit
+ fi
+fi
+if [ $GATEWAY_TQ -ge $LOWER_LIMIT ] && [ $GATEWAY_TQ -le $UPPER_LIMIT ]; # This is just to get a clean run if we are in-between the grace periode
+then
+ echo "Gateway TQ is $GATEWAY_TQ - Do nothing"
+fi
@@ -18,6 +18,7 @@ define Package/fff-base
+ip6tables \
+odhcp6c \
+micrond \
+ +fff-autorestart \
+fff-nodewatcher \
+fff-web \
+fff-uradvd \