diff --git a/setup-concentrator.sh b/setup-concentrator.sh index 3484e372..78a0e741 100755 --- a/setup-concentrator.sh +++ b/setup-concentrator.sh @@ -116,13 +116,56 @@ function activate_peer() { fi } -function create_station_peer() { +function create_concentrator_peer() { if [ -f "$SWANC/peers-available/${1}.conf" ]; then echo "Peer $1 config already exists." return; fi cat > "$SWANC/peers-available/${1}.conf" < "$SWANC/peers-available/${1}.conf-remote" <> "$SWANC/secrets.conf" <> "$SWANC/secrets.conf" < $SWANC/remote-${1}-secrets.conf + echo "created $SWANC/remote-${1}-secrets.conf" } function get_vrf_for_if() { - echo "1"; + local ifmaster=`ip -o li show $1 | egrep -o '(master \S+)'` + [[ x$ifmaster = x ]] && echo "No master found for $1" + echo ${ifmaster#master } } function enable_ipsec_if() { @@ -219,35 +289,57 @@ function activate_all() { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -while getopts "ibec:a:d:" arg; do +while getopts "a:c:d:p:v:behi" arg; do case $arg in - i) - initialize - echo "Initialized." - exit 0; - ;; - c) - check_arg $OPTARG - echo "Creating $OPTARG" - create_station_peer $OPTARG - create_station_key $OPTARG - ;; a) check_arg $OPTARG echo "Activating $OPTARG" activate_peer $OPTARG ;; + b) + enable_ipsec_if $WLAN_IF + ;; + c) + check_arg $OPTARG + echo "Creating $OPTARG" + create_concentrator_peer $OPTARG + create_station_peer $OPTARG + create_concentrator_key $OPTARG + create_station_key $OPTARG + ;; d) check_arg $OPTARG echo "Deactivating $OPTARG" deactivate_peer $OPTARG ;; - b) - enable_ipsec_if $WLAN_IF - ;; e) activate_all ;; + + h) + cat <