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="Distributed by the Institute of Internet Technologies and Applications
40 University of Applied Sciences Rapperswil, Switzerland (ITA-HSR)"
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"
99 if test -e $IPSEC_PLUTO_PID
101 $IPSEC_WHACK --name "$1" --terminate
103 if test -e $IPSEC_CHARON_PID
105 $IPSEC_STROKE down "$1"
109 listalgs|listpubkeys|listcacerts|listaacerts|\
110 listocspcerts|listacerts|listgroups|\
111 listcainfos|listcrls|listocsp|listcards|\
112 purgeocsp|rereadsecrets|rereadgroups|\
113 rereadcacerts|rereadaacerts|rereadocspcerts|\
114 rereadacerts|rereadcrls|rereadall)
117 if test -e $IPSEC_PLUTO_PID
119 $IPSEC_WHACK "$@" "--$op"
125 if test -e $IPSEC_PLUTO_PID
127 $IPSEC_WHACK "$@" "--$op"
129 if test -e $IPSEC_CHARON_PID
137 if test -e $IPSEC_PLUTO_PID
139 $IPSEC_WHACK --listen
144 if test -e $IPSEC_STARTER_PID
146 echo "Reloading strongSwan IPsec configuration..." >&2
147 kill -s USR1 `cat $IPSEC_STARTER_PID`
149 echo "ipsec starter is not running" >&2
154 $IPSEC_SBINDIR/ipsec stop
157 $IPSEC_SBINDIR/ipsec start "$@"
163 if test -e $IPSEC_PLUTO_PID
165 $IPSEC_WHACK --name "$1" "--$op"
172 if test -e $IPSEC_PLUTO_PID
174 $IPSEC_WHACK "--$op" "$@"
179 if test -e $IPSEC_PLUTO_PID
181 $IPSEC_WHACK --rereadsecrets
187 exec $IPSEC_STARTER "$@"
194 if test -e $IPSEC_PLUTO_PID
198 if test -e $IPSEC_CHARON_PID
203 if test -e $IPSEC_PLUTO_PID
205 $IPSEC_WHACK --name "$1" "--$op"
207 if test -e $IPSEC_CHARON_PID
209 $IPSEC_STROKE "$op" "$1"
215 if test -e $IPSEC_STARTER_PID
217 echo "Stopping strongSwan IPsec..." >&2
218 kill `cat $IPSEC_STARTER_PID`
220 echo "ipsec starter is not running" >&2
226 if test -e $IPSEC_PLUTO_PID
228 $IPSEC_WHACK --name "$1" --initiate
230 if test -e $IPSEC_CHARON_PID
232 $IPSEC_STROKE up "$1"
237 if test -e $IPSEC_STARTER_PID
239 echo "Updating strongSwan IPsec configuration..." >&2
240 kill -s HUP `cat $IPSEC_STARTER_PID`
242 echo "ipsec starter is not running" >&2
247 echo "Linux $IPSEC_NAME $IPSEC_VERSION"
248 echo "See \`ipsec --copyright' for copyright information."
253 echo "$0: unknown option \`$1' (perhaps command name was omitted?)" >&2
261 path="$IPSEC_DIR/$cmd"
265 path="$IPSEC_DIR/$cmd"
268 echo "$0: unknown IPsec command \`$cmd' (\`ipsec --help' for list)" >&2