1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

add netmasker

This commit is contained in:
suyuan 2022-09-24 00:00:42 +08:00
parent d155e9a8ad
commit ea3e086b1d
5 changed files with 431 additions and 0 deletions

8
netmaker-openwrt/LICENSE Normal file
View file

@ -0,0 +1,8 @@
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

111
netmaker-openwrt/README.md Normal file
View file

@ -0,0 +1,111 @@
# Netmaker-OpenWRT
[Netmaker](https://github.com/gravitl/netmaker) is a platform for creating and managing fast, secure, and dynamic virtual overlay networks using WireGuard. This project offers OpenWRT packages for Netmaker.
## Installing package
Download the prebuild package and copy it onto your OpenWRT installation, preferably into the `/tmp` folder.
Then install the ipk package file:
```bash
opkg install netmaker_*.ipk
```
Now start `netclient` of Netmaker:
```bash
/etc/init.d/netclient start
```
## Compiling from Sources
To include Netmaker into your OpenWRT image or to create an `.ipk` package (equivalent to Debians .deb files), you have to build an OpenWRT image.
Now prepare OpenWRT:
```bash
git clone https://github.com/openwrt/openwrt
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
```
To build Netmaker for OpenWRT, you need to have Golang with OpenWRT build envirment. Then, you can insert the Netmaker package using a package feed or add the package manually.
### Add package by feed
A feed is the standard way packages are made available to the OpenWRT build system.
Put this line in your feeds list file (e.g. feeds.conf.default)
```bash
src-git netmaker http://github.com/sbilly/netmaker-openwrt.git
```
Update and install the new feed
```bash
./scripts/feeds update netmaker
./scripts/feeds install netmaker
```
Now continue with the building packages section.
## Building Packages
Configure packages:
```bash
make menuconfig
```
Now select the appropiate "Target System" and "Target Profile" depending on what target chipset/router you want to build for. Also mark the Netmaker package under `Network ---> VPN ---> <*> netmaker`.
Now compile/build everything:
```bash
make
```
The images and all *.ipk packages are now inside the bin/ folder, including the netmaker package. You can install the Netmaker .ipk on the target device using opkg install <ipkg-file>.
For details please check the OpenWRT documentation.
## Build bulk packages
For a release, it is useful the build packages at a bulk for multiple targets:
```shell
#!/bin/sh
# dump-target-info.pl is used to get all targets configurations:
# https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=scripts/dump-target-info.pl
./scripts/dump-target-info.pl architectures | while read pkgarch target1 rest; do
echo "CONFIG_TARGET_${target1%/*}=y" > .config
echo "CONFIG_TARGET_${target1%/*}_${target1#*/}=y" >> .config
echo "CONFIG_PACKAGE_example1=y" >> .config
# Debug output
echo "pkgarch: $pkgarch, target1: $target1"
make defconfig
make -j4 tools/install
make -j4 toolchain/install
# Build package
make package/netmaker/{clean,compile}
# Free space (optional)
rm -rf build_dir/target-*
rm -rf build_dir/toolchain-*
done
```
## Thanks
- [netmaker](https://github.com/gravitl/netmaker)
- [zerotier-openwrt](https://github.com/mwarning/zerotier-openwrt)
- [openwrt-golang-package-test-feed](https://github.com/jefferyto/openwrt-golang-package-test-feed)

View file

@ -0,0 +1,93 @@
#
# Copyright (C) 2019 sbilly <superli_1980@hotmail.com>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=netmaker
PKG_VERSION:=0.9.4
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/gravitl/netmaker.git
PKG_SOURCE_VERSION:=e9bce264719f88c30e252ecc754d08f422f4c080
PKG_SOURCE_DATE:=20220117
PKG_MIRROR_HASH:=skip
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=sbilly <superli_1980@hotmail.com>
PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
GO_PKG:=github.com/gravitl/netmaker
GO_PKG_INSTALL_EXTRA:=extra/file extra/dir
GO_PKG_EXCLUDES:=excluded
GO_PKG_LDFLAGS:=-s -w
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
define Package/netmaker
$(call Package/netmaker/Default)
$(call GoPackage/GoSubMenu)
SECTION:=net
CATEGORY:=Network
SUBMENU:=VPN
endef
define Package/netmaker/Default
TITLE:=Netmaker for OpenWRT
URL:=https://github.com/gravitl/netmaker
DEPENDS:=$(GO_ARCH_DEPENDS)
MAINTAINER:=sbilly <superli_1980@hotmail.com>
endef
define Package/netmaker/Default/description
Netmaker is a platform for creating and managing fast, secure, and
dynamic virtual overlay networks using WireGuard. This project offers
OpenWRT packages for Netmaker.
endef
define Package/netmaker/description
$(call Package/netmaker/Default/description)
This package contains the binaries.
endef
define Package/netmaker-dev
TITLE+= (source files)
SECTION:=net
CATEGORY:=Network
SUBMENU:=VPN
PKGARCH:=all
endef
define Package/netmaker-dev/description
$(call Package/netmaker/Default/description)
This package provides the source files.
endef
define Package/netmaker/install
$(INSTALL_DIR) $(1)/etc/netclient/
$(INSTALL_DIR) $(1)/etc/netclient/config
$(INSTALL_DIR) $(1)/etc/systemd/
$(INSTALL_DIR) $(1)/etc/systemd/system
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/netmaker $(1)/usr/bin/
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/netclient $(1)/usr/bin/
$(CP) ./root/* $(1)/
$(LN) netclient $(1)/etc/netclient/netclient
endef
$(eval $(call GoBinPackage,netmaker))
$(eval $(call BuildPackage,netmaker))
$(eval $(call GoSrcPackage,netmaker-dev))
$(eval $(call BuildPackage,netmaker-dev))

View file

@ -0,0 +1,42 @@
#!/bin/sh /etc/rc.common
#Created by oycol<oycol527@outlook.com>
EXTRA_COMMANDS="status"
EXTRA_HELP=" status Check service is running"
START=99
LOG_FILE="/tmp/netclient.logs"
start() {
mkdir -p /etc/netclient/config
mkdir -p /etc/systemd/system
if [ ! -f "${LOG_FILE}" ];then
touch "${LOG_FILE}"
fi
local PID=$(ps|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}')
if [ "${PID}" ];then
echo "service is running"
return
fi
/bin/sh -c "while [ 1 ]; do netclient checkin -n all >> ${LOG_FILE} 2>&1;sleep 15;\
if [ $(ls -l ${LOG_FILE}|awk '{print $5}') -gt 10240000 ];then tar zcf "${LOG_FILE}.tar" -C / "tmp/netclient.logs" && > $LOG_FILE;fi;done &"
echo "start"
}
stop() {
local PID=$(ps|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}')
if [ "${PID}" ];then
kill "${PID}"
fi
echo "stop"
}
status() {
local PID=$(ps|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}')
if [ "${PID}" ];then
echo -e "netclient[${PID}] is running \n"
else
echo -e "netclient is not running \n"
fi
}

View file

@ -0,0 +1,177 @@
#!/bin/bash
# setting working directory
WORK_DIR="/home/user"
# setting branch
if [ "${OPENWRT_BRANCH}" = "" ]
then
DEFAULT_OPENWRT_BRANCH="openwrt-21.02"
else
DEFAULT_OPENWRT_BRANCH="${OPENWRT_BRANCH}"
fi
download_openwrt() {
cd ${WORK_DIR}
# pull code
if [ ! -d "openwrt" ]; then
git clone https://git.openwrt.org/openwrt/openwrt.git
fi
}
change_openwrt_branch() {
cd ${WORK_DIR}/openwrt
if [ "${1}" = "" ]
then
echo "Building ${DEFAULT_OPENWRT_BRANCH}"
git checkout -B ${DEFAULT_OPENWRT_BRANCH} origin/${DEFAULT_OPENWRT_BRANCH}
else
echo "Building ${1}"
git checkout -B ${1} origin/${1}
fi
}
init_openwrt_branch() {
cd ${WORK_DIR}/openwrt
git stash
git pull --all
git pull --tags
}
init_openwrt_link() {
cd ${WORK_DIR}/openwrt
sudo chown 1000:1000 /src -R
mkdir -p /src/dl
mkdir -p /src/staging_dir
mkdir -p /src/build_dir
mkdir -p /src/tmp
mkdir -p /src/bin
ln -s /src/dl ${WORK_DIR}/openwrt/dl
ln -s /src/staging_dir ${WORK_DIR}/openwrt/staging_dir
ln -s /src/build_dir ${WORK_DIR}/openwrt/build_dir
ln -s /src/tmp ${WORK_DIR}/openwrt/tmp
}
update_install_openwrt_feeds() {
cd ${WORK_DIR}/openwrt
./scripts/feeds update -a
./scripts/feeds install -a
}
openwrt_init_config() {
cd ${WORK_DIR}/openwrt
echo "CONFIG_TARGET_x86=y" > ${WORK_DIR}/openwrt/.config
echo "CONFIG_TARGET_x86_64=y" >> ${WORK_DIR}/openwrt/.config
}
openwrt_make_build_env() {
cd ${WORK_DIR}/openwrt
make defconfig
make -j4 download
make -j4 tools/install
make -j4 toolchain/install
}
openwrt_make() {
cd ${WORK_DIR}/openwrt
make -j4
}
openwrt_install_netmaker_feeds() {
cd ${WORK_DIR}/openwrt
echo "src-git netmaker http://github.com/sbilly/netmaker-openwrt.git" >> feeds.conf.default
./scripts/feeds update netmaker
./scripts/feeds install netmaker
}
openwrt_install_package_netmaker_config() {
cd ${WORK_DIR}/openwrt
echo "CONFIG_FEED_netmaker=y" >> ${WORK_DIR}/openwrt/.config
echo "CONFIG_PACKAGE_netmaker=m" >> ${WORK_DIR}/openwrt/.config
echo "CONFIG_PACKAGE_netmaker-dev=m" >> ${WORK_DIR}/openwrt/.config
}
openwrt_patch_golang_host() {
cd ${WORK_DIR}/openwrt
echo "patching ${1}"
if [ "${1}" = "openwrt-19.07" ]
then
sed -i 's/5fb43171046cf8784325e67913d55f88a683435071eef8e9da1aa8a1588fcf5d/2255eb3e4e824dd7d5fcdc2e7f84534371c186312e546fb1086a34c17752f431/g' ${WORK_DIR}/openwrt/feeds/packages/lang/golang/golang/Makefile
sed -i 's/1.13/1.17/g' ${WORK_DIR}/openwrt/feeds/packages/lang/golang/golang-version.mk
sed -i 's/15/2/g' ${WORK_DIR}/openwrt/feeds/packages/lang/golang/golang-version.mk
fi
if [ "${1}" = "openwrt-18.06" ]
then
sed -i 's/6faf74046b5e24c2c0b46e78571cca4d65e1b89819da1089e53ea57539c63491/2255eb3e4e824dd7d5fcdc2e7f84534371c186312e546fb1086a34c17752f431/g' ${WORK_DIR}/openwrt/feeds/packages/lang/golang/golang/Makefile
sed -i 's/1.10/1.17/g' ${WORK_DIR}/openwrt/feeds/packages/lang/golang/golang-version.mk
sed -i 's/8/2/g' ${WORK_DIR}/openwrt/feeds/packages/lang/golang/golang-version.mk
fi
}
openwrt_make_netmaker_package() {
cd ${WORK_DIR}/openwrt
make defconfig
make toolchain/gcc/final/compile
make package/netmaker/clean
find ./ -type d | xargs -n1 sudo chmod 755 -R
make package/netmaker/compile V=s
}
openwrt_copy_pacage() {
echo ${1}
echo > /tmp/copy.sh
cd ${WORK_DIR}/openwrt/bin/packages/x86_64/netmaker/
for ipk in ./*.ipk
do
if [ -f "$ipk" ]
then
echo ${ipk} | gawk -F".ipk" -v BRANCH=${1} '{ print "cp -rfv "$0" /src/bin/"$1"-"BRANCH".ipk" }' >> /tmp/copy.sh
fi
done
/bin/bash /tmp/copy.sh
}
download_openwrt
change_openwrt_branch ${DEFAULT_OPENWRT_BRANCH}
init_openwrt_branch
init_openwrt_link
openwrt_install_netmaker_feeds
update_install_openwrt_feeds
openwrt_init_config
openwrt_install_package_netmaker_config
openwrt_patch_golang_host ${DEFAULT_OPENWRT_BRANCH}
openwrt_make_netmaker_package
openwrt_copy_pacage ${DEFAULT_OPENWRT_BRANCH}
ls -alF ${WORK_DIR}/openwrt/bin/ /src/bin