Update build.sh, docker-compose.yml, bird/bird.conf.tmpl files
This commit is contained in:
parent
5631ee8339
commit
c848e78712
@ -85,7 +85,7 @@ function is_lixonet_router_v4()
|
|||||||
|
|
||||||
function is_own_route_v4()
|
function is_own_route_v4()
|
||||||
{
|
{
|
||||||
{{ if len "${routes:-}" }}{{ range "$routes" | split "," }}if net ~ [ {{.}}+ ] then return true;
|
{{ if len "${bgp_routes:-}" }}{{ range "$bgp_routes" | split "," }}if net ~ [ {{.}}+ ] then return true;
|
||||||
{{ end }}{{ end }}
|
{{ end }}{{ end }}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
27
build.sh
27
build.sh
@ -1,5 +1,19 @@
|
|||||||
#!/bin/ash
|
#!/bin/ash
|
||||||
|
|
||||||
|
process_template ( ) {
|
||||||
|
processed_filename=$(dirname $1)/$(basename $1 .tmpl)
|
||||||
|
echo "Processing template $1 -> $processed_filename with args $2"
|
||||||
|
sh -c "sigil -f $1 -p $2 > $processed_filename"
|
||||||
|
rm $1
|
||||||
|
}
|
||||||
|
|
||||||
|
process_templates ( ) {
|
||||||
|
for template_filename in `find $1 -type f -name '*.tmpl'`
|
||||||
|
do
|
||||||
|
process_template $template_filename "$2"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
topdir=`pwd`
|
topdir=`pwd`
|
||||||
|
|
||||||
for dir in `find /etc/lixonet/* -type d -maxdepth 0`
|
for dir in `find /etc/lixonet/* -type d -maxdepth 0`
|
||||||
@ -16,10 +30,11 @@ do
|
|||||||
sigil_vars=$(cat /etc/lixonet/${netname}/lixonet.conf | tr "\\n" " ")
|
sigil_vars=$(cat /etc/lixonet/${netname}/lixonet.conf | tr "\\n" " ")
|
||||||
|
|
||||||
echo "Configuring Lixonet3 network $netname from $git..."
|
echo "Configuring Lixonet3 network $netname from $git..."
|
||||||
|
echo "Variables: $sigil_vars"
|
||||||
|
|
||||||
# Clone and enter the repository
|
# Clone and enter the repository
|
||||||
rm -rf "$(basename "$git" .git)"
|
rm -rf "$(basename "$git" .git)"
|
||||||
git clone $git
|
git clone $git || { echo "clone $git failed, quitting" ; exit 1; }
|
||||||
cd "$(basename "$git" .git)"
|
cd "$(basename "$git" .git)"
|
||||||
|
|
||||||
# Copy default files
|
# Copy default files
|
||||||
@ -33,8 +48,7 @@ do
|
|||||||
find tinc -type d | sed -e "s@tinc@tinc/${netname}@g" | xargs -I '{}' mkdir --verbose -p /etc/{}
|
find tinc -type d | sed -e "s@tinc@tinc/${netname}@g" | xargs -I '{}' mkdir --verbose -p /etc/{}
|
||||||
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/{} /etc/tinc/$netname/{}
|
||||||
# Fill out templates and remove them after
|
# Fill out templates and remove them after
|
||||||
find /etc/tinc/$netname/ -type f -name '*.tmpl' -exec sh -c 'sigil -f {} -p $sigil_vars > "$(dirname {})/$(basename {} .tmpl)"' {} \;
|
process_templates "/etc/tinc/$netname/" "$sigil_vars"
|
||||||
find /etc/tinc/$netname/ -type f -name '*.tmpl' | xargs -I '{}' rm -f {}
|
|
||||||
# Copy private key
|
# Copy private key
|
||||||
cp /etc/lixonet/$netname/tinc.key /etc/tinc/$netname/rsa_key.priv
|
cp /etc/lixonet/$netname/tinc.key /etc/tinc/$netname/rsa_key.priv
|
||||||
# Set permissions for tinc scripts
|
# Set permissions for tinc scripts
|
||||||
@ -50,10 +64,11 @@ do
|
|||||||
find bird -type d | sed -e "s@bird@bird/${netname}@g" | xargs -I '{}' mkdir --verbose -p /etc/{}
|
find bird -type d | sed -e "s@bird@bird/${netname}@g" | xargs -I '{}' mkdir --verbose -p /etc/{}
|
||||||
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/{} /etc/bird/$netname/{}
|
||||||
# Fill out templates and remove them after
|
# Fill out templates and remove them after
|
||||||
find /etc/bird/$netname/ -type f -name '*.tmpl' -exec sh -c 'sigil -f {} -p $sigil_vars > "$(dirname {})/$(basename {} .tmpl)"' {} \;
|
process_templates "/etc/bird/$netname/" "$sigil_vars"
|
||||||
find /etc/bird/$netname/ -type f -name '*.tmpl' | xargs -I '{}' rm -f {}
|
|
||||||
|
|
||||||
docker-compose up -d --build
|
echo "COMPOSE_PROJECT_NAME=$netname" > .env
|
||||||
|
docker-compose -p $netname up -d --build
|
||||||
|
rm .env
|
||||||
|
|
||||||
# Pop directory
|
# Pop directory
|
||||||
cd $topdir
|
cd $topdir
|
||||||
|
@ -9,10 +9,10 @@ services:
|
|||||||
- "655:655/tcp"
|
- "655:655/tcp"
|
||||||
- "655:655/udp"
|
- "655:655/udp"
|
||||||
volumes:
|
volumes:
|
||||||
- /etc/tinc/${netname}:/etc/tinc/${netname}
|
- /etc/tinc/${COMPOSE_PROJECT_NAME}:/etc/tinc/${COMPOSE_PROJECT_NAME}
|
||||||
environment:
|
environment:
|
||||||
- RUNMODE=server
|
- RUNMODE=server
|
||||||
- NETNAME=${netname}
|
- NETNAME=${COMPOSE_PROJECT_NAME}
|
||||||
cap_add:
|
cap_add:
|
||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
devices:
|
devices:
|
||||||
@ -26,7 +26,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "179:179/tcp"
|
- "179:179/tcp"
|
||||||
volumes:
|
volumes:
|
||||||
- /etc/bird/${netname}:/etc/bird/
|
- /etc/bird/${COMPOSE_PROJECT_NAME}/:/etc/bird/
|
||||||
cap_add:
|
cap_add:
|
||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
restart: always
|
restart: always
|
||||||
|
Loading…
x
Reference in New Issue
Block a user