]>
git.ipfire.org Git - thirdparty/strongswan.git/blob - programs/_plutoload/_plutoload.in
2 # Pluto database-loading script
3 # Copyright (C) 1998, 1999, 2001 Henry Spencer.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # RCSID $Id: _plutoload.in,v 1.2 2004/03/31 16:15:10 as Exp $
17 # exit status is 13 for protocol violation, that of Pluto otherwise
19 me
='ipsec _plutoload' # for messages
24 --load) plutoload
="$2" ; shift ;;
25 --start) plutostart
="$2" ; shift ;;
26 --wait) plutowait
="$2" ; shift ;;
27 --post) postpluto
="$2" ; shift ;;
29 -*) echo "$me: unknown option \`$1'" >&2 ; exit 2 ;;
36 eval `ipsec _confread --varprefix PLUTO --type ca --search auto add start`
37 if test " $PLUTO_confreadstatus" != " "
39 echo "auto=add/start search: $PLUTO_confreadstatus"
40 echo "unable to determine what ca information to add -- adding none"
43 caload
="$PLUTO_confreadnames"
47 # the way the searches were done ensures plutoload >= plutoroute >= plutostart
49 # search for things to "ipsec auto --add": auto in "add" "route" "start"
50 eval `ipsec _confread --varprefix PLUTO --search auto add route start`
51 if test " $PLUTO_confreadstatus" != " "
53 echo "auto=add/route/start search: $PLUTO_confreadstatus"
54 echo "unable to determine what conns to add -- adding none"
57 plutoload
="$PLUTO_confreadnames"
60 # search for things to "ipsec auto --route": auto in "route" "start"
61 eval `ipsec _confread --varprefix PLUTO --search auto route start`
62 if test " $PLUTO_confreadstatus" != " "
64 echo "auto=route/start search: $PLUTO_confreadstatus"
65 echo "unable to determine what conns to route -- routing none"
68 plutoroute
="$PLUTO_confreadnames"
71 # search for things to "ipsec auto --up": auto in "start"
72 eval `ipsec _confread --varprefix PLUTO --search auto start`
73 if test " $PLUTO_confreadstatus" != " "
75 echo "auto=start search: $PLUTO_confreadstatus"
76 echo "unable to determine what conns to start -- starting none"
79 plutostart
="$PLUTO_confreadnames"
82 # await Pluto's readiness (not likely to be an issue, but...)
87 'Pluto initialized') eofed
= ; break ;; # NOTE BREAK OUT
88 *) echo "pluto unexpectedly said \`$saying'" ;;
93 echo "pluto died unexpectedly!?!"
100 ipsec auto
--type ca
--add $tu ||
101 echo "...could not add ca \"$tu\""
107 ipsec auto
--add $tu ||
108 echo "...could not add conn \"$tu\""
114 # execute any post-startup cleanup
115 if test " $postpluto" != " "
121 echo "...postpluto command exited with status $st"
125 # quickly establish routing
126 for tu
in $plutoroute
128 ipsec auto
--route $tu ||
129 echo "...could not route conn \"$tu\""
132 # tunnel initiation, which may take a while
134 if test " $plutowait" = " no"
136 async
="--asynchronous"
138 for tu
in $plutostart
140 ipsec auto
--up $async $tu ||
141 echo "...could not start conn \"$tu\""
144 # report any further utterances, and watch for exit status
149 exit) eofed
= ; break ;; # NOTE BREAK OUT
150 *) echo "pluto unexpectedly says \`$saying'" ;;
155 echo "pluto died without exit status!?!"
162 echo "pluto yielded no exit status!?!"