#!/usr/bin/env bash set -eu DESC="Conguration IPv6 de base du réseau" SYSTEMS="bigboss lambda nomade societe tiny web" setIpv6() { echo "$@" host=$1 eth=$2 addr=$(vdn-ssh root@$host "ifconfig $eth" | grep 'inet6:.*fe80:' | head -n 1 | tr -s ' ' | cut -d ' ' -f 4) [ -z "$addr" ] && return || : case "$3" in site) new=$(echo "$addr" | sed -re 's/^fe80:/fec0:/');; global) new=$(echo "$addr" | sed -re 's/^fe80:/2002:/');; esac exist=false if vdn-ssh root@$host "ifconfig $eth" | grep -q "inet6:.*$new"; then exist=true fi if [ $exist = false ]; then echo "$host : ifconfig $eth inet6 add $new" vdn-ssh root@$host " ifconfig $eth inet6 add $new/64 " fi } run() { setErrorHandler echoStart requireSshGuests $SYSTEMS waitSsh $SYSTEMS for i in $SYSTEMS; do setIpv6WorkAround $i done setIpv6 tiny eth1 site setIpv6 bigboss eth0 site setIpv6 web eth0 site setIpv6 societe eth1 site setIpv6 societe eth2 site setIpv6 societe eth0 global setIpv6 nomade eth0 global setIpv6 lambda eth0 global unsetErrorHandler echoDone }