2 # prefix command to run stuff from our programs directory
3 # Copyright (C) 1998-2002 Henry Spencer.
4 # Copyright (C) 2006 Andreas Steffen
5 # Copyright (C) 2006 Martin Willi
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 2 of the License, or (at your
10 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 # RCSID $Id: ipsec.in,v 1.13 2006/03/09 20:09:33 as Exp $
19 # name and version of the ipsec implementation
20 IPSEC_NAME="@IPSEC_NAME@"
21 IPSEC_VERSION="U@IPSEC_VERSION@/K`uname -r`"
23 # where the private directory and the config files are
24 IPSEC_DIR="@IPSEC_DIR@"
25 IPSEC_SBINDIR="@IPSEC_SBINDIR@"
26 IPSEC_CONFDIR="@IPSEC_CONFDIR@"
27 IPSEC_PIDDIR="@IPSEC_PIDDIR@"
29 IPSEC_STARTER_PID="${IPSEC_PIDDIR}/starter.pid"
30 IPSEC_PLUTO_PID="${IPSEC_PIDDIR}/pluto.pid"
31 IPSEC_CHARON_PID="${IPSEC_PIDDIR}/charon.pid"
33 IPSEC_WHACK="${IPSEC_DIR}/whack"
34 IPSEC_STROKE="${IPSEC_DIR}/stroke"
35 IPSEC_STARTER="${IPSEC_DIR}/starter"
37 export IPSEC_DIR IPSEC_SBINDIR IPSEC_CONFDIR IPSEC_PIDDIR IPSEC_VERSION IPSEC_NAME IPSEC_STARTER_PID IPSEC_PLUTO_PID IPSEC_CHARON_PID
39 IPSEC_DISTRO="Institute for Internet Technologies and Applications\n
40 University of Applied Sciences Rapperswil, Switzerland"
44 echo "Usage: ipsec command argument ..."
45 echo "Use --help for list of commands, or see ipsec(8) manual page"
46 echo "or the $IPSEC_NAME documentation for names of the common ones."
47 echo "Most have their own manual pages, e.g. ipsec_auto(8)."
48 echo "See <http://www.strongswan.org> for more general info."
52 echo "Usage: ipsec command argument ..."
53 echo "where command is one of:"
54 echo " start|restart arguments..."
55 echo " update|reload|stop"
56 echo " up|down|route|unroute <connectionname>"
57 echo " status|statusall [<connectionname>]"
59 echo " listalgs|listpubkeys|listcerts [--utc]"
60 echo " listcacerts|listaacerts|listocspcerts [--utc]"
61 echo " listacerts|listgroups|listcainfos [--utc]"
62 echo " listcrls|listocsp|listcards|listall [--utc]"
63 echo " rereadsecrets|rereadgroups"
64 echo " rereadcacerts|rereadaacerts|rereadocspcerts"
65 echo " rereadacerts|rereadcrls|rereadall"
67 echo " scencrypt|scdecrypt <value> [--inbase <base>] [--outbase <base>] [--keyid <id>]"
78 echo "Some of these functions have their own manual pages, e.g. ipsec_scepclient(8)."
87 # and fall through, invoking "ipsec _copyright"
101 echo "Usage: ipsec down <connection name>"
104 if test -e $IPSEC_PLUTO_PID
106 $IPSEC_WHACK --name "$1" --terminate
108 if test -e $IPSEC_CHARON_PID
110 $IPSEC_STROKE down "$1"
114 listalgs|listpubkeys|\listcards|\
115 rereadsecrets|rereadgroups)
118 if test -e $IPSEC_PLUTO_PID
120 $IPSEC_WHACK "$@" "--$op"
124 listcerts|listcacerts|listaacerts|\
125 listacerts\listgroups\listocspcerts|\
126 listcainfos|listcrls|listocsp|listall|\
127 rereadcacerts|rereadaacerts|rereadacerts|\
128 rereadocspcerts|rereadcrls|\
132 if test -e $IPSEC_PLUTO_PID
134 $IPSEC_WHACK "$@" "--$op"
136 if test -e $IPSEC_CHARON_PID
138 $IPSEC_STROKE "$op" "$@"
144 if test -e $IPSEC_PLUTO_PID
146 $IPSEC_WHACK --listen
151 if test -e $IPSEC_STARTER_PID
153 echo "Reloading strongSwan IPsec configuration..." >&2
154 kill -s USR1 `cat $IPSEC_STARTER_PID`
156 echo "ipsec starter is not running" >&2
161 $IPSEC_SBINDIR/ipsec stop
164 $IPSEC_SBINDIR/ipsec start "$@"
172 echo "Usage: ipsec $op <connection name>"
175 if test -e $IPSEC_PLUTO_PID
177 $IPSEC_WHACK --name "$1" "--$op"
179 if test -e $IPSEC_CHARON_PID
181 $IPSEC_STROKE "$op" "$1"
188 if test -e $IPSEC_PLUTO_PID
190 $IPSEC_WHACK "--$op" "$@"
195 if test -e $IPSEC_PLUTO_PID
197 $IPSEC_WHACK --rereadsecrets
203 exec $IPSEC_STARTER "$@"
210 if test -e $IPSEC_PLUTO_PID
214 if test -e $IPSEC_CHARON_PID
219 if test -e $IPSEC_PLUTO_PID
221 $IPSEC_WHACK --name "$1" "--$op"
223 if test -e $IPSEC_CHARON_PID
225 $IPSEC_STROKE "$op" "$1"
231 if test -e $IPSEC_STARTER_PID
233 echo "Stopping strongSwan IPsec..." >&2
234 kill `cat $IPSEC_STARTER_PID`
236 echo "ipsec starter is not running" >&2
244 echo "Usage: ipsec up <connection name>"
247 if test -e $IPSEC_PLUTO_PID
249 $IPSEC_WHACK --name "$1" --initiate
251 if test -e $IPSEC_CHARON_PID
253 $IPSEC_STROKE up "$1"
258 if test -e $IPSEC_STARTER_PID
260 echo "Updating strongSwan IPsec configuration..." >&2
261 kill -s HUP `cat $IPSEC_STARTER_PID`
263 echo "ipsec starter is not running" >&2
268 echo "Linux $IPSEC_NAME $IPSEC_VERSION"
269 echo "See \`ipsec --copyright' for copyright information."
274 echo "$0: unknown option \`$1' (perhaps command name was omitted?)" >&2
282 path="$IPSEC_DIR/$cmd"
286 path="$IPSEC_DIR/$cmd"
289 echo "$0: unknown IPsec command \`$cmd' (\`ipsec --help' for list)" >&2