Update build.sh
This commit is contained in:
parent
9aa82a8008
commit
d6c1c22c65
43
build.sh
43
build.sh
@ -28,6 +28,7 @@ for dir in `find /etc/lixonet/* -type d -maxdepth 0`
|
|||||||
do
|
do
|
||||||
dir=${dir%*/} # remove the trailing "/"
|
dir=${dir%*/} # remove the trailing "/"
|
||||||
netname=${dir##*/} # print everything after the final "/"
|
netname=${dir##*/} # print everything after the final "/"
|
||||||
|
config_out="/etc/lixonet/${netname}/.config/"
|
||||||
|
|
||||||
# Load relevant environment variables from lixonet.conf
|
# Load relevant environment variables from lixonet.conf
|
||||||
unset git
|
unset git
|
||||||
@ -91,47 +92,47 @@ do
|
|||||||
|
|
||||||
# Tinc
|
# Tinc
|
||||||
# Remove existing configuration
|
# Remove existing configuration
|
||||||
rm -v -rf /etc/tinc/$netname/*
|
rm -v -rf $config_out/tinc/*
|
||||||
# Copy all tinc default files to /etc/(tinc)
|
# Copy all tinc default files to /etc/(tinc)
|
||||||
find tinc -type d | sed -e "s@tinc@tinc/${netname}@g" | xargs -I '{}' mkdir --verbose -p /etc/{}
|
find tinc -type d | xargs -I '{}' mkdir --verbose -p $config_out/{}
|
||||||
find tinc -type f | sed -e "s@tinc/@@g" | xargs -I '{}' cp --verbose tinc/{} /etc/tinc/$netname/{}
|
find tinc -type f | sed -e "s@tinc/@@g" | xargs -I '{}' cp --verbose tinc/{} $config_out/tinc{}
|
||||||
# Build list of all peer IP addresses
|
# Build list of all peer IP addresses
|
||||||
tinc_peers=$(cat /etc/tinc/$netname/hosts/* | grep 'Subnet' | grep '/32' | grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])' | sed -e ':a;N;$!ba;s/\n/,/g')
|
tinc_peers=$(cat $config_out/tinc/hosts/* | grep 'Subnet' | grep '/32' | grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])' | sed -e ':a;N;$!ba;s/\n/,/g')
|
||||||
sigil_vars=$(echo "$sigil_vars tinc_peers=$tinc_peers")
|
sigil_vars=$(echo "$sigil_vars tinc_peers=$tinc_peers")
|
||||||
# Fill out templates and remove them after
|
# Fill out templates and remove them after
|
||||||
process_templates "/etc/tinc/$netname/" "$sigil_vars"
|
process_templates "$config_out/tinc/" "$sigil_vars"
|
||||||
# Copy private key
|
# Copy private key
|
||||||
cp -v /etc/lixonet/$netname/tinc.key /etc/tinc/$netname/rsa_key.priv
|
cp -v /etc/lixonet/$netname/tinc.key $config_out/tinc/rsa_key.priv
|
||||||
# Set permissions for tinc scripts
|
# Set permissions for tinc scripts
|
||||||
chmod +x /etc/tinc/$netname/tinc-up /etc/tinc/$netname/tinc-down /etc/tinc/$netname/subnet-up /etc/tinc/$netname/subnet-down /etc/tinc/$netname/host-up /etc/tinc/$netname/host-down /etc/tinc/$netname/check-node
|
chmod +x $config_out/tinc/tinc-up $config_out/tinc/tinc-down $config_out/tinc/subnet-up $config_out/tinc/subnet-down $config_out/tinc/host-up $config_out/tinc/host-down $config_out/tinc/check-node
|
||||||
|
|
||||||
# Bird
|
# Bird
|
||||||
# Remove existing configuration
|
# Remove existing configuration
|
||||||
rm -v -rf /etc/bird/$netname/*
|
rm -v -rf $config_out/bird/*
|
||||||
# Copy all bird default files to /etc/(bird)
|
# Copy all bird default files to /etc/(bird)
|
||||||
find bird -type d | sed -e "s@bird@bird/${netname}@g" | xargs -I '{}' mkdir --verbose -p /etc/{}
|
find bird -type d | xargs -I '{}' mkdir --verbose -p $config_out/{}
|
||||||
find bird -type f | sed -e "s@bird/@@g" | xargs -I '{}' cp --verbose bird/{} /etc/bird/$netname/{}
|
find bird -type f | sed -e "s@bird/@@g" | xargs -I '{}' cp --verbose bird/{} $config_out/bird/{}
|
||||||
# Fill out templates and remove them after
|
# Fill out templates and remove them after
|
||||||
process_templates "/etc/bird/$netname/" "$sigil_vars"
|
process_templates "$config_out/bird/" "$sigil_vars"
|
||||||
|
|
||||||
# BIND
|
# BIND
|
||||||
# Remove existing configuration
|
# Remove existing configuration
|
||||||
rm -v -rf /etc/bind/$netname/*
|
rm -v -rf $config_out/bind/*
|
||||||
# Copy all bind default files to /etc/(bind)
|
# Copy all bind default files to /etc/(bind)
|
||||||
find bind -type d | sed -e "s@bind@bind/${netname}@g" | xargs -I '{}' mkdir --verbose -p /etc/{}
|
find bind -type d | xargs -I '{}' mkdir --verbose -p $config_out/bind/{}
|
||||||
find bind -type f | sed -e "s@bind/@@g" | xargs -I '{}' cp --verbose bind/{} /etc/bind/$netname/{}
|
find bind -type f | sed -e "s@bind/@@g" | xargs -I '{}' cp --verbose bind/{} $config_out/bind/{}
|
||||||
# Fill out templates and remove them after
|
# Fill out templates and remove them after
|
||||||
process_templates "/etc/bind/$netname/" "$sigil_vars"
|
process_templates "$config_out/bind/" "$sigil_vars"
|
||||||
|
|
||||||
# Wireguard
|
# Wireguard
|
||||||
if [ "${wg_enabled:-0}" -eq "1" ]; then
|
if [ "${wg_enabled:-0}" -eq "1" ]; then
|
||||||
# Remove existing configuration
|
# Remove existing configuration
|
||||||
rm -v -rf /etc/wireguard/$netname/*
|
rm -v -rf $config_out/wireguard/*
|
||||||
# Copy all wireguard default files to /etc/(wireguard)
|
# Copy all wireguard default files to /etc/(wireguard)
|
||||||
find wireguard -type d | sed -e "s@wireguard@wireguard/${netname}@g" | xargs -I '{}' mkdir --verbose -p /etc/{}
|
find wireguard -type d | xargs -I '{}' mkdir --verbose -p $config_out/wireguard/{}
|
||||||
find wireguard -type f | sed -e "s@wireguard/@@g" | xargs -I '{}' cp --verbose wireguard/{} /etc/wireguard/$netname/{}
|
find wireguard -type f | sed -e "s@wireguard/@@g" | xargs -I '{}' cp --verbose wireguard/{} $config_out/wireguard/{}
|
||||||
# Fill out templates and remove them after
|
# Fill out templates and remove them after
|
||||||
process_templates "/etc/wireguard/$netname/" "$sigil_vars"
|
process_templates "$config_out/wireguard/" "$sigil_vars"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
@ -159,10 +160,10 @@ do
|
|||||||
echo $sigil_vars | tr ' ' '\n' > .env
|
echo $sigil_vars | tr ' ' '\n' > .env
|
||||||
cat docker-compose.yml
|
cat docker-compose.yml
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
docker-compose -p $netname down
|
docker-compose -p $netname down
|
||||||
docker-compose -p $netname up -d --build --remove-orphans
|
docker-compose -p $netname up -d --build --remove-orphans
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
rm -v .env
|
rm -v .env
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user