add openwrt

This commit is contained in:
root 2024-08-23 15:51:21 +00:00
parent eaa5a1bec2
commit 7c9a2ca6af
3 changed files with 35 additions and 4 deletions

View file

@ -1,6 +1,7 @@
.PHONY: install
.PHONY: install alpine openwrt
install:
mkdir -p /usr/local/bin
mkdir -p /var/lib/inet2
cp ./bin/* /usr/local/bin
cp ./lib/* /var/lib/inet2
@ -9,3 +10,8 @@ alpine:
apk add --no-cache wireguard-tools bind-tools bird
cp ./deployments/openrc/inet2.initd /etc/init.d/inet2
rc-update add inet2
openwrt:
opkg install wireguard-tools bind-tools bird2
cp ./deployments/initd/inet2.initd /etc/init.d/inet2
service inet2 enable

View file

@ -26,7 +26,7 @@ start() {
rm -fr /run/inet2/wg 2> /dev/null
mkdir -p /run/inet2/wg
mkbirdconfig.sh
/usr/local/bin/mkbirdconfig.sh
step "Setting loopback addresses"
getval Loopback | while read -r addr; do
@ -35,7 +35,7 @@ start() {
getval interface | while read -r inter; do
step "Generating config for $inter"
run mkwgconfig.sh "$inter" /run/inet2/wg/"$inter"
run /usr/local/bin/mkwgconfig.sh "$inter" /run/inet2/wg/"$inter"
# create the wireguard interface *in the default namespace*
step "Adding Wireguard interface $inter"
@ -90,7 +90,7 @@ stop() {
reload() {
getval interface | while read -r inter; do
step "Generating config for $inter"
run mkwgconfig.sh "$inter" /run/inet2/wg/"$inter" /config/inet2.conf
run /usr/local/bin/mkwgconfig.sh "$inter" /run/inet2/wg/"$inter" /etc/inet2.conf
step "Setting Wireguard config for $inter"
run wg setconf "$inter" /run/inet2/wg/"$inter"

25
deployments/initd/inet2.initd Executable file
View file

@ -0,0 +1,25 @@
#!/bin/sh /etc/rc.common
START=70
STOP=10
start() {
/usr/local/bin/inet2.sh start
/sbin/service bird start
}
stop() {
/usr/local/bin/inet2.sh stop
/sbin/service bird stop
}
restart() {
stop
start
}
reload() {
/usr/local/bin/inet2.sh reload
/sbin/service bird restart
}