refactor to use any unknown prefix
This commit is contained in:
parent
7c9a2ca6af
commit
5e60794b42
9 changed files with 27 additions and 21 deletions
|
@ -1,8 +1,8 @@
|
|||
FROM alpine
|
||||
RUN apk add --no-cache openrc udev-init-scripts-openrc wireguard-tools bind-tools bird
|
||||
RUN mkdir -p /var/lib/inet2
|
||||
RUN mkdir -p /var/share/inet2
|
||||
COPY ./bin /usr/local/bin
|
||||
COPY ./lib /var/lib/inet2
|
||||
COPY ./share /usr/local/share/inet2
|
||||
COPY ./deployments/openrc/inet2.initd /etc/init.d/inet2
|
||||
COPY ./deployments/docker/wait.initd /etc/init.d/wait
|
||||
RUN sed -i 's/#rc_sys=""/rc_sys="docker"/' /etc/rc.conf && \
|
||||
|
|
10
Makefile
10
Makefile
|
@ -1,10 +1,12 @@
|
|||
.PHONY: install alpine openwrt
|
||||
|
||||
PREFIX=/usr/local
|
||||
|
||||
install:
|
||||
mkdir -p /usr/local/bin
|
||||
mkdir -p /var/lib/inet2
|
||||
cp ./bin/* /usr/local/bin
|
||||
cp ./lib/* /var/lib/inet2
|
||||
mkdir -p ${PREFIX}/bin
|
||||
mkdir -p ${PREFIX}/share/inet2
|
||||
cp ./bin/* ${PREFIX}/bin
|
||||
cp ./share/* ${PREFIX}/share/inet2
|
||||
|
||||
alpine:
|
||||
apk add --no-cache wireguard-tools bind-tools bird
|
||||
|
|
10
bin/inet2.sh
10
bin/inet2.sh
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
. /var/lib/inet2/inet2.sh
|
||||
. ${INET2_PREFIX}/share/inet2/inet2.sh
|
||||
|
||||
runscripts() {
|
||||
if [ -n "$(getval "interface $2" "$1")" ]; then
|
||||
|
@ -26,7 +26,7 @@ start() {
|
|||
rm -fr /run/inet2/wg 2> /dev/null
|
||||
mkdir -p /run/inet2/wg
|
||||
|
||||
/usr/local/bin/mkbirdconfig.sh
|
||||
${INET2_PREFIX}/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 /usr/local/bin/mkwgconfig.sh "$inter" /run/inet2/wg/"$inter"
|
||||
run ${INET2_PREFIX}/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 /usr/local/bin/mkwgconfig.sh "$inter" /run/inet2/wg/"$inter" /etc/inet2.conf
|
||||
run ${INET2_PREFIX}/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"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
. /var/lib/inet2/inet2.sh
|
||||
. ${INET2_PREFIX}/share/inet2/inet2.sh
|
||||
|
||||
escapebird() {
|
||||
sed -e 's/\\/\\\\/g;s/"/\\"/g'
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
# args: /path/to/interface-config /path/to/output.conf
|
||||
|
||||
inter="$1"
|
||||
configfile=/etc/inet2.conf
|
||||
|
||||
getval() {
|
||||
/var/lib/inet2/config.awk "$configfile" "$@"
|
||||
${INET2_PREFIX}/share/inet2/config.awk "$configfile" "$@"
|
||||
}
|
||||
|
||||
k() {
|
||||
|
|
|
@ -3,13 +3,15 @@
|
|||
START=70
|
||||
STOP=10
|
||||
|
||||
export INET2_PREFIX=/usr/local
|
||||
|
||||
start() {
|
||||
/usr/local/bin/inet2.sh start
|
||||
${INET2_PREFIX}/bin/inet2.sh start
|
||||
/sbin/service bird start
|
||||
}
|
||||
|
||||
stop() {
|
||||
/usr/local/bin/inet2.sh stop
|
||||
${INET2_PREFIX}/bin/inet2.sh stop
|
||||
/sbin/service bird stop
|
||||
}
|
||||
|
||||
|
@ -19,7 +21,7 @@ restart() {
|
|||
}
|
||||
|
||||
reload() {
|
||||
/usr/local/bin/inet2.sh reload
|
||||
${INET2_PREFIX}/bin/inet2.sh reload
|
||||
/sbin/service bird restart
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,15 @@ description="Sets up wireguard interfaces connected via the host's internet conn
|
|||
|
||||
extra_started_commands="reloadwg"
|
||||
|
||||
export INET2_PREFIX=/usr/local
|
||||
|
||||
start() {
|
||||
/usr/local/bin/inet2.sh start
|
||||
${INET2_PREFIX}/bin/inet2.sh start
|
||||
rc-service bird start 2> /dev/null
|
||||
}
|
||||
|
||||
stop() {
|
||||
/usr/local/bin/inet2.sh stop
|
||||
${INET2_PREFIX}/bin/inet2.sh stop
|
||||
rc-service bird stop 2> /dev/null
|
||||
}
|
||||
|
||||
|
@ -20,7 +22,7 @@ restart() {
|
|||
}
|
||||
|
||||
reload() {
|
||||
/usr/local/bin/inet2.sh reload
|
||||
${INET2_PREFIX}/bin/inet2.sh reload
|
||||
rc-service bird restart 2> /dev/null
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ step() {
|
|||
}
|
||||
|
||||
getval() {
|
||||
/var/lib/inet2/config.awk /etc/inet2.conf "$@"
|
||||
${INET2_PREFIX}/share/inet2/config.awk /etc/inet2.conf "$@"
|
||||
}
|
||||
|
||||
haskey() {
|
Loading…
Reference in a new issue