Commit b70f793f authored by Jan Moskyto Matejka's avatar Jan Moskyto Matejka

Another variant of testing script

this closes #4
parent a1ca9f42
#!/bin/bash
REV=$1
cd $GIT_WORK_TREE
pushd /var/lib/virt/nfs
rsync -a --exclude=.git $(readlink -f $GIT_WORK_TREE) /var/lib/virt/nfs/bird-test-$REV
rm -f net/misc-at{d1,o1,f1,n1,d2}-conf
touch net/misc-at{d1,o1,f1,n1,d2}-conf
declare -a TOK=( d1 o1 f1 n1 d2 )
declare -A IPA=( [d1]=10.55.0.1 [o1]=10.55.0.2 [f1]=10.55.0.3 [n1]=10.55.0.4 [d2]=10.55.0.5 )
declare -A SR4=( [d1]="10.56.1.0/24 via 10.55.1.2" [o1]="10.56.2.0/24 via 10.55.1.6" [f1]="10.56.3.0/24 via 10.55.1.10" [n1]="10.56.4.0/24 via 10.55.1.14" [d2]="10.56.5.0/24 via 10.55.1.18" )
declare -A SR6=( [d1]="fd01:56:0::/64 via fd01:55::1" [o1]="fd01:56:2::/64 via fd01:55::3" [f1]="fd01:56:4::/64 via fd01:55::5" [n1]="fd01:56:6::/64 via fd01:55::7" [d2]="fd01:56:8::/64 via fd01:55::9" )
function cf() {
local -a AR
while [ "$1" != "--" ]; do
AR+=( $1 )
shift
done
if [ -z "${AR[@]}" ]; then
AR=( ${TOK[@]} )
fi
shift
# echo tee -a $( for F in ${AR[@]}; do echo net/misc-at$F-conf; done )
"$@" | tee -a $( for F in ${AR[@]}; do echo net/misc-at$F-conf; done ) #> /dev/null
}
function cfe() {
cf -- echo "$@"
}
function cfc() {
cf -- cat
}
for T in ${TOK[@]}; do
cf $T -- echo "log \"/mnt/nfs/tmp/bird-at$T.log\" all;"
cf $T -- echo "router id ${IPA[$T]};"
done
cfe "# marker"
cfc <<EOF
debug protocols all;
ipv4 table m4;
ipv6 table m6;
protocol device {
scan time 10;
}
protocol kernel k4 {
# learn;
# persist;
ipv4 { table m4; import all; export all; };
scan time 20;
debug all;
}
protocol kernel k6 {
# learn;
# persist;
ipv6 { table m6; import all; export all; };
scan time 20;
debug all;
}
protocol direct d4 { ipv4 { table m4; import all; }; }
protocol direct d6 { ipv6 { table m6; import all; }; }
EOF
for T in ${TOK[@]}; do
cf $T -- cat <<EOF
protocol static s4 {
debug all;
ipv4 { table m4; import all; };
route ${SR4[$T]};
}
protocol static s6 {
debug all;
ipv6 { table m6; import all; };
route ${SR6[$T]};
}
EOF
done
cfc <<EOF
protocol ospf2 o4 {
ipv4 { table m4; import all; export all; };
debug all;
area 0 {
interface "INAME" { hello 5; type ptp; cost ICOST; bfd; };
};
}
protocol ospf3 o6 {
ipv6 { table m6; import all; export all; };
debug all;
area 0 {
interface "INAME" { hello 5; type ptp; cost ICOST; bfd; };
};
}
EOF
for T in ${TOK[@]}; do
cat <<'EOF' > net/rc-at$T
OSPF_INAME_SED="x;"
echo "Interface list:" ${INTERFACES[@]}
for I in ${INTERFACES[@]}; do
case $UNAME in
netbsd|openbsd|freebsd) COST=$((0x$(ifconfig ${I%%;*} | md5) % 75 + 150)) ;;
linux) COST=$((0x$(ip addr show dev ${I%%;*} | md5) % 75 + 150)) ;;
esac
OSPF_INAME_SED="$OSPF_INAME_SED G; s/INAME/${I%%;*}/; s/ICOST/$COST/;"
done
OSPF_INAME_SED="$OSPF_INAME_SED x; s/.*//; x;"
SED_PATTERN="$SED_PATTERN /INAME/ { $OSPF_INAME_SED };"
echo "Sed pattern: $SED_PATTERN"
CONFFILE="/mnt/nfs/net/misc-$HOSTNAME-conf"
sed "$SED_PATTERN" $CONFFILE > /etc/bird.conf
EOF
echo "rsync --exclude=.git -av /mnt/nfs/bird-test-$REV/ /tmp/bird" >> net/rc-at$T
cat <<'EOF' >> net/rc-at$T
cd /tmp/bird
$AUTOCONF
./configure
#./configure --enable-debug
#sed -e 's/-g -O2/-g3 -O0/' -i obj/Rules
$MAKE
$MAKE install
PATH=$PATH:/usr/local/sbin
ulimit -c unlimited
bird -c /etc/bird.conf
EOF
done
vctl restart -m $( for T in ${TOK[@]}; do echo at$T; done )
#!/bin/bash
REV=$1
cd /var/lib/virt/nfs
rm -f net/misc-at{d1,o1,f1,n1,d2}-{4,6}-conf
touch net/misc-at{d1,o1,f1,n1,d2}-{4,6}-conf
declare -a MACH=( d1 o1 f1 n1 d2 )
declare -a TOK=( {d1,o1,f1,n1,d2}-{4,6} )
declare -A IPA=( [d1]=10.55.0.1 [o1]=10.55.0.2 [f1]=10.55.0.3 [n1]=10.55.0.4 [d2]=10.55.0.5 )
declare -A SR=( [d1-4]="10.56.1.0/24 via 10.55.1.2" [o1-4]="10.56.2.0/24 via 10.55.1.6" [f1-4]="10.56.3.0/24 via 10.55.1.10" [n1-4]="10.56.4.0/24 via 10.55.1.14" [d2-4]="10.56.5.0/24 via 10.55.1.18" [d1-6]="fd01:56:0::/64 via fd01:55::1" [o1-6]="fd01:56:2::/64 via fd01:55::3" [f1-6]="fd01:56:4::/64 via fd01:55::5" [n1-6]="fd01:56:6::/64 via fd01:55::7" [d2-6]="fd01:56:8::/64 via fd01:55::9" )
function cf() {
local -a AR
while [ "$1" != "--" ]; do
AR+=( $1 )
shift
done
if [ -z "${AR[@]}" ]; then
AR=( ${TOK[@]} )
fi
shift
(echo "# marker $@"; "$@") | tee -a $( for F in ${AR[@]}; do echo net/misc-at$F-conf; done ) #> /dev/null
}
function cfe() {
cf -- echo "$@"
}
function cfc() {
cf -- cat
}
for T in ${TOK[@]}; do
cf $T -- echo "log \"/mnt/nfs/tmp/bird-at$T.log\" all;"
cf $T -- echo "router id ${IPA[${T%%-*}]};"
done
cfc <<EOF
debug protocols all;
protocol device {
scan time 10;
}
protocol kernel {
# learn;
# persist;
import all;
export all;
scan time 20;
debug all;
}
protocol direct {
import all;
}
EOF
for T in ${TOK[@]}; do
cf $T -- cat <<EOF
protocol static {
debug all;
import all;
route ${SR[$T]};
}
EOF
done
cfc <<EOF
protocol ospf {
import all;
export all;
debug all;
area 0 {
interface "INAME" { hello 5; type ptp; cost ICOST; }; #bfd; };
};
}
EOF
cf d1-4 -- cat <<EOF
table b4;
protocol bgp {
local 192.168.225.162 as 65123;
neighbor 192.168.192.1 as 65534;
import all;
table b4;
}
protocol bgp {
local 10.55.1.1 as 65123;
neighbor 10.55.1.17 as 65123;
export all;
table b4;
}
EOF
cf d2-4 -- cat <<EOF
protocol bgp {
local 10.55.1.17 as 65123;
neighbor 10.55.1.1 as 65123;
import filter { if net ~ 64.0.0.0/7 then accept; reject; };
}
EOF
for T in ${MACH[@]}; do
cat <<'EOF' > net/rc-at$T
OSPF_INAME_SED="x;"
echo "Interface list:" ${INTERFACES[@]}
for I in ${INTERFACES[@]}; do
case $UNAME in
netbsd|openbsd|freebsd) COST=$((0x$(ifconfig ${I%%;*} | md5) % 75 + 150)) ;;
linux) COST=$((0x$(ip addr show dev ${I%%;*} | md5) % 75 + 150)) ;;
esac
OSPF_INAME_SED="$OSPF_INAME_SED G; s/INAME/${I%%;*}/; s/ICOST/$COST/;"
done
OSPF_INAME_SED="$OSPF_INAME_SED x; s/.*//; x;"
SED_PATTERN="$SED_PATTERN /INAME/ { $OSPF_INAME_SED };"
echo "Sed pattern: $SED_PATTERN"
CF4="/mnt/nfs/net/misc-$HOSTNAME-4-conf"
CF6="/mnt/nfs/net/misc-$HOSTNAME-6-conf"
sed "$SED_PATTERN" $CF4 > /etc/bird4.conf
sed "$SED_PATTERN" $CF6 > /etc/bird6.conf
EOF
echo "rsync --exclude=.git -a /mnt/nfs/bird-test-$REV/ /tmp/bird4" >> net/rc-at$T
echo "rsync --exclude=.git -a /mnt/nfs/bird-test-$REV/ /tmp/bird6" >> net/rc-at$T
cat <<'EOF' >> net/rc-at$T
cd /tmp/bird4
$AUTOCONF
./configure --with-suffix=4
#./configure --enable-debug
#sed -e 's/-g -O2/-g3 -O0/' -i obj/Rules
$MAKE
$MAKE install
PATH=$PATH:/usr/local/sbin
ulimit -c unlimited
bird4 -c /etc/bird4.conf
cd /tmp/bird6
$AUTOCONF
./configure --enable-ipv6 --with-suffix=6
#./configure --enable-debug
#sed -e 's/-g -O2/-g3 -O0/' -i obj/Rules
$MAKE
$MAKE install
PATH=$PATH:/usr/local/sbin
ulimit -c unlimited
bird6 -c /etc/bird6.conf
EOF
done
vctl restart -m $( for T in ${MACH[@]}; do echo at$T; done )
#!/bin/bash
set -e
usage() {
cat <<EOF
Usage (inside Bird's Git workdir): $0 commit script
EOF
exit 2
}
SUBDIRECTORY_OK=true
if [ -z "$1" ] || [ -z "$2" ] || [ ! -f "$2" ] || [ ! -z "$3" ]; then
usage
fi
COMMIT=$(git rev-parse $1)
echo COMMIT is $COMMIT
. "$(git --exec-path)/git-sh-setup"
cd_to_toplevel
DIR=$(pwd)
TMPDIR=$(mktemp -d)
cp $2 $TMPDIR/$COMMIT-run
chmod +x $TMPDIR/$COMMIT-run
pushd $TMPDIR
git init
git add $COMMIT-run
git commit -m "Config template"
git fetch -q $DIR
git merge -m "automerge" -q $COMMIT
git push -f root@10.0.0.11:/root/bird-auto-test HEAD:run
popd
rm -rf $TMPDIR
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment