Browse Source

Merge pull request #14334 from bogdik/master

Add Eoip packege
lilik-openwrt-22.03
Hannu Nyman 4 years ago
committed by GitHub
parent
commit
1059e3cdb8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 177 additions and 0 deletions
  1. +55
    -0
      net/eoip/Makefile
  2. +6
    -0
      net/eoip/files/eoip.config
  3. +105
    -0
      net/eoip/files/eoip.init
  4. +11
    -0
      net/eoip/patches/100-add_LF_to_pidfile.patch

+ 55
- 0
net/eoip/Makefile View File

@ -0,0 +1,55 @@
#
# Copyright (C) 2020 Bogdan Shatik <bogdikxxx@mail.ru>
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=eoip
PKG_VERSION:=0.5
PKG_RELEASE:=1
PKG_MAINTAINER:=Bogdan Shatik <bogdikxxx@mail.ru>
PKG_LICENSE:=GPL-3.0-or-later
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/bogdik/openwrt-linux-eoip/releases/download/0.5/
PKG_HASH:=22f6f3864665adef26c7fbd57543a396108ba2dff1282af8143f18bc2a9912f8
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
define Package/eoip
TITLE:=Mikrotik-compatible userspace EoIP tunnel
URL:=https://code.google.com/p/linux-eoip/
SECTION:=net
CATEGORY:=Network
SUBMENU:=VPN
DEPENDS:=+kmod-tun +libpthread +liblzo
endef
define Package/eoip/conffiles
/etc/config/eoip
endef
define Package/eoip/description
linux-eoip can create ethernet tunnels compatible with Mikrotik EoIP tunnel.
At current moment it is easiest way to create stateless tunnel with Mikrotik.
endef
CONFIGURE_ARGS += \
--with-kernel="$(LINUX_DIR)" \
--with-zlib="$(STAGING_DIR)/usr" \
--with-lzo-include="$(STAGING_DIR)/usr/include/lzo"
define Package/eoip/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/eoip $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/eoip.config $(1)/etc/config/eoip
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/eoip.init $(1)/etc/init.d/eoip
endef
$(eval $(call BuildPackage,eoip))

+ 6
- 0
net/eoip/files/eoip.config View File

@ -0,0 +1,6 @@
config eoip
option enabled 0
option name 0
option idtun 123
option dst '192.168.99.100'
option dynamic 1

+ 105
- 0
net/eoip/files/eoip.init View File

@ -0,0 +1,105 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
INDEX=0
append_bool() {
local section="$1"
local option="$2"
local value="$3"
local _val
config_get_bool _val "$section" "$option" '0'
[ "$_val" -gt 0 ] && append args "$3"
}
append_string() {
local section="$1"
local option="$2"
local value="$3"
local _val
config_get _val "$section" "$option"
[ -n "$_val" ] && append args "$3$_val"
}
service_triggers () {
procd_open_trigger
procd_add_reload_trigger "eoip"
procd_add_config_trigger "config.change" "eoip" /etc/init.d/eoip restart
procd_add_config_trigger "config.change" "/etc/config/eoip" /etc/init.d/eoip restart
procd_close_trigger
}
start_service() {
config_load "eoip"
echo "" > /etc/eoip.cfg
echo "#!/bin/sh" > /etc/afterStart.sh
echo "chkCount=0">> /etc/afterStart.sh
echo "while [ \$chkCount -le 10 ];do">> /etc/afterStart.sh
echo " chkStarted=\$(ip a | grep zeoip | wc -l)">> /etc/afterStart.sh
echo " if [ \$chkStarted -eq 0 ]; then">> /etc/afterStart.sh
echo " chkCount=\$((chkCount+1))">> /etc/afterStart.sh
echo " sleep 2">> /etc/afterStart.sh
echo " else">> /etc/afterStart.sh
echo " chkCount=11">> /etc/afterStart.sh
echo " fi">> /etc/afterStart.sh
echo "done">> /etc/afterStart.sh
echo "now=\$(ip a | grep \"@zeoip\" | awk '{print \$2}' | sed 's/.$//' | cut -d \"@\" -f 1)" >> /etc/afterStart.sh
echo "IFS=\$'\n'" >> /etc/afterStart.sh
echo "for s in \$now ; do" >> /etc/afterStart.sh
echo " ip link delete link dev \$s" >> /etc/afterStart.sh
echo "done" >> /etc/afterStart.sh
echo "rm /etc/afterStart.sh" >> /etc/afterStart.sh
chmod +x /etc/afterStart.sh
config_foreach start_eoip eoip
config_foreach start_eoip_vlan eoip
if [ "$(cat /etc/eoip.cfg | grep zeoip)" != '' ]; then
/etc/afterStart.sh&
procd_open_instance
args=" /etc/eoip.cfg"
procd_set_param command /usr/bin/eoip $args
procd_close_instance
else
rm /etc/afterStart.sh
fi
}
stop_service() {
killall eoip
}
start_eoip() {
local section="$1" runas_root
config_get_bool enabled "$section" enabled
if [ "$enabled" -gt 0 ]; then
config_get name "$section" name
config_get idtun "$section" idtun
config_get dst "$section" dst
config_get_bool dynamic "$section" dynamic 0
if [ "${name}" != '' ] && [ "${dst}" != '' ] && [ "${idtun}" != '' ]; then
cnt=$(cat /etc/eoip.cfg | grep "zeoip${name}" | wc -l)
if [ $cnt -eq 0 ]; then
echo "[zeoip${name}]" >>/etc/eoip.cfg
echo "id=${idtun}" >>/etc/eoip.cfg
echo "dst=${dst}" >>/etc/eoip.cfg
[ "$dynamic" -gt 0 ] && echo "dynamic=${dynamic}" >>/etc/eoip.cfg
INDEX=$((INDEX+1))
else
result=$(uci delete /etc/config/eoip.@eoip[$INDEX])
INDEX=$((INDEX+1))
fi
fi
fi
}
start_eoip_vlan() {
local section="$1" runas_root
config_get name "$section" name
config_list_foreach "$section" vlan handle_vlan ${name}
}
handle_vlan() {
local value="$1"
local name="$2"
echo "ip link add link zeoip${name} name zeoip${name}.${value} type vlan id ${value}" >> /etc/afterStart.sh
}

+ 11
- 0
net/eoip/patches/100-add_LF_to_pidfile.patch View File

@ -0,0 +1,11 @@
--- a/eoip.c 2013-09-25 22:50:48.272763057 +0200
+++ b/eoip.c 2013-09-25 22:51:03.804762840 +0200
@@ -430,7 +430,7 @@
exit(1);
mfd = fopen(pidfile, "w");
- fprintf(mfd,"%d", getpid());
+ fprintf(mfd,"%d\n", getpid());
fclose(mfd);
/* structure of Mikrotik EoIP:

Loading…
Cancel
Save