File: ipsec-add.sh

package info (click to toggle)
libreswan 5.2-2.4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 81,656 kB
  • sloc: ansic: 129,988; sh: 32,018; xml: 20,646; python: 10,303; makefile: 3,022; javascript: 1,506; sed: 574; yacc: 511; perl: 264; awk: 52
file content (39 lines) | stat: -rwxr-xr-x 782 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

set -eu

if test $# -eq 0 ; then
    cat <<EOF 1>&2
Usage:
  $0 <conn> ...

Hack to get around libreswan not defining host-pair search order
during IKE_SA_INIT.  The connections are added such that when multiple
connections match they will be tested per their appearance on the
command line.
EOF
    exit 1
fi

# In 5.0 connections are searched new-to-old.  Hence, need to be added
# in reverse order!

# In 5.1 connections are searched old-to-new.  Hence, can be added in
# order.

connection=( "$@" )
declare -a output
declare -a status

for (( i=1 ; i<=$#; i++)) ; do
    c=${!i}
    output[$i]=$(ipsec add ${c} 2>&1)
    status[$i]=$?
done

for (( i=1 ; i<=$#; i++)) ; do
    echo "${output[$i]}"
    test "${status[$i]}" -eq 0 || exit "${status[$i]}"
done

exit 0