From 00cd79935ca5420daa37cadccba878cd7efd75b5 Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 20 Jan 2013 13:03:43 +0100 Subject: add a script to try to connect to all not yet connected hosts --- manifests/base.pp | 4 ++++ templates/scripts/start_unconnected.sh.erb | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 templates/scripts/start_unconnected.sh.erb diff --git a/manifests/base.pp b/manifests/base.pp index 2787fee..7755bd6 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -39,6 +39,10 @@ class strongswan::base { content => "#!/bin/bash\n${strongswan::binary} status | grep ESTABLISHED | awk -F\\[ '{ print \$1 }'\n", notify => undef, mode => '0500'; + "/usr/local/sbin/${binary_name}_start_unconnected": + content => template('strongswan/scripts/start_unconnected.sh.erb'), + notify => undef, + mode => '0500'; } service{'ipsec': diff --git a/templates/scripts/start_unconnected.sh.erb b/templates/scripts/start_unconnected.sh.erb new file mode 100644 index 0000000..0dbaffe --- /dev/null +++ b/templates/scripts/start_unconnected.sh.erb @@ -0,0 +1,8 @@ +#!/bin/bash +connected=`<%= scope.lookupvar('strongswan::base::binary_name') %>_connected_hosts` +grep -El '^conn' /etc/ipsec.d/hosts/* | while read line; do + host=`basename $line '.conf'` + echo $connected | grep -q $host + [ $? -gt 0 ] && <%= scope.lookupvar('strongswan::base::binary_name') %> up $host +done + -- cgit v1.2.3