Skip to content

Commit

Permalink
WIP: Add Rita extender definition
Browse files Browse the repository at this point in the history
  • Loading branch information
jkilpatr committed Jan 20, 2023
1 parent b32039b commit d6b03dc
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
58 changes: 58 additions & 0 deletions althea/rita-extender/Makefile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
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))
11 changes: 11 additions & 0 deletions althea/rita-extender/files/checkup.ash
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions althea/rita-extender/files/rita_extender.init
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 2 additions & 0 deletions althea/rita-extender/files/root
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Every 10 minutes curl Rita and try and restart if there's no response
*/10 * * * * ash /etc/checkup.ash

0 comments on commit d6b03dc

Please sign in to comment.