Update to 0.1.1 and add an init script

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2019-04-03 13:21:42 +00:00
parent 880f914256
commit 70a12e18b6
2 changed files with 85 additions and 17 deletions

View File

@@ -1,35 +1,47 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=glorytun
PKG_VERSION:=0.0.28
PKG_RELEASE:=1
PKG_VERSION:=0.1.1
PKG_RELEASE:=0
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/angt/glorytun/releases/download/v$(PKG_VERSION)
PKG_MD5SUM:=f2aa35559f02d9a78bcd48e4ae165c75
PKG_SOURCE_URL:=https://github.com/angt/$(PKG_NAME)/releases/download/v$(PKG_VERSION)
PKG_HASH:=d67a5765fb4d6c43a2e0e3e83887cd036568bbf76f65df9f1561dc82a08800b9
PKG_FIXUP:=autoreconf
include $(INCLUDE_DIR)/package.mk
define Package/glorytun
define Package/$(PKG_NAME)
SECTION:=net
CATEGORY:=Network
SUBMENU:=VPN
TITLE:=Glorytun
DEPENDS:=+kmod-tun +libsodium
DEPENDS:=+kmod-tun +libsodium +librt
URL:=https://github.com/angt/glorytun
endef
define Package/glorytun/description
Glorytun
TARGET_CPPFLAGS += -DGT_RUNDIR=\\\"/var/run/$(PKG_NAME)\\\"
define Package/$(PKG_NAME)/description
Glorytun is a vpn designed to improve your internet connectivity:
- Fast and highly secure.
- Multipath and active failover.
- Traffic shaping.
- Path MTU discovery without ICMP.
endef
TARGET_CFLAGS += -std=c99 -D_GNU_SOURCE
define Package/$(PKG_NAME)/conffiles
/etc/config/$(PKG_NAME)
endef
define Package/glorytun/install
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/glorytun $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) init $(1)/etc/init.d/$(PKG_NAME)
$(INSTALL_DIR) $(1)/etc/config
touch $(1)/etc/config/$(PKG_NAME)
endef
$(eval $(call BuildPackage,glorytun))
$(eval $(call BuildPackage,$(PKG_NAME)))

56
glorytun/init Executable file
View File

@@ -0,0 +1,56 @@
#!/bin/sh /etc/rc.common
START=90
STOP=10
USE_PROCD=1
PROG_NAME=glorytun
PROG=/usr/sbin/$PROG_NAME
validate_section() {
uci_validate_section $PROG_NAME $PROG_NAME "$1" \
'enable:bool:0' \
'key:string' \
'server:host' \
'port:port' \
'dev:string'
}
start_instance() {
local enable key server port dev
validate_section "$1" || return
[ "$enable" = "1" ] || return 0
[ "$key" ] || return
[ "$server" ] || return
[ "$port" ] || return
keyfile="/tmp/$PROG_NAME.key"
( umask 077; echo "$key" > "$keyfile" )
key=""
procd_open_instance
procd_set_param command $PROG \
bind "0.0.0.0" "$port" \
to "$server" "$port" \
keyfile "$keyfile" \
${dev:+dev "$dev"}
procd_set_param respawn 0 30 0
procd_set_param file "$keyfile"
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
start_service() {
config_load glorytun
config_foreach start_instance mud
}
service_triggers() {
procd_add_reload_trigger glorytun
}