diff --git a/althea/rita-extender/Makefile b/althea/rita-extender/Makefile new file mode 100644 index 0000000..27033bf --- /dev/null +++ b/althea/rita-extender/Makefile @@ -0,0 +1,58 @@ +# +# Copyright (C) 2017-2018 Justin Kilpatrick, Openwrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +# you must set $RUST_TRIPLE in your env +include $(TOPDIR)/rules.mk + +PKG_NAME:=rita-extender +PKG_VERSION:=0.20.8 +PKG_RELEASE:=0 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/althea-net/althea_rs +PKG_SOURCE_VERSION:=f53562ac1f445449c4d639e7eb5e764c30f3ce48 +PKG_LICENSE:=Apache-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/rita-extender + SECTION:=net + CATEGORY:=Utilities + SUBMENU:=Althea + TITLE:=Althea Rita Extender + URL:=https://github.com/althea-net/althea_rs + MAINTAINER:= Justin Kilpatrick + DEPENDS:=@IPV6 +ca-bundle +ca-certificates +kmod-sched-cake +tc + PKG_BUILD_DEPENDS:=openssl +endef + +define Package/rita-extender/description + Althea Rita Extender +endef + +RITA_PATH:="$(PKG_BUILD_DIR)/target/$(RUST_TRIPLE)/release/rita_extender" + +define Build/Compile + (\ + cd $(PKG_BUILD_DIR) && \ + cargo install cross && \ + cross build --release --target $(RUST_TRIPLE) -p rita_bin --bin rita_extender \ + ) + $(STRIP) $(RITA_PATH) +endef + +define Package/rita-extender/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(RITA_PATH) $(1)/usr/sbin/rita_extender + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/rita_extender.init $(1)/etc/init.d/rita_extender + $(INSTALL_DIR) $(1)/etc/crontabs/ + $(CP) ./files/checkup.ash $(1)/etc/ + $(CP) ./files/root $(1)/etc/crontabs/ +endef + +$(eval $(call BuildPackage,rita-extender)) diff --git a/althea/rita-extender/files/checkup.ash b/althea/rita-extender/files/checkup.ash new file mode 100644 index 0000000..655ec83 --- /dev/null +++ b/althea/rita-extender/files/checkup.ash @@ -0,0 +1,11 @@ +#!/bin/ash +set -eux + +set +e +curl -f --max-time 300 127.0.0.1:4877/status +# if the ping fails we should restart +if [ 0 -ne $? ]; then +/etc/init.d/rita_extender restart +date > /etc/lastcrash +fi +set -e diff --git a/althea/rita-extender/files/rita_extender.init b/althea/rita-extender/files/rita_extender.init new file mode 100755 index 0000000..d76b89f --- /dev/null +++ b/althea/rita-extender/files/rita_extender.init @@ -0,0 +1,20 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2016 OpenWrt.org + +START=90 +PROG=/usr/sbin/rita_extender + +RUST_LOG=INFO + +start() { + [ -f $config_file ] || return 1 + (service_start $PROG &> /dev/null )& +} + +stop() { + service_stop $PROG +} + +reload() { + $PROG2 reload +} diff --git a/althea/rita-extender/files/root b/althea/rita-extender/files/root new file mode 100644 index 0000000..c126fca --- /dev/null +++ b/althea/rita-extender/files/root @@ -0,0 +1,2 @@ +# Every 10 minutes curl Rita and try and restart if there's no response +*/10 * * * * ash /etc/checkup.ash