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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
#! /bin/sh
# prefix command to run stuff from our programs directory
# Copyright (C) 1998-2002 Henry Spencer.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# RCSID $Id: ipsec.in,v 1.33 2003/04/23 14:56:23 dhr Exp $
# where the private directory and the config files are
IPSEC_EXECDIR="${IPSEC_EXECDIR-@IPSEC_EXECDIR@}"
IPSEC_LIBDIR="${IPSEC_LIBDIR-@IPSEC_LIBDIR@}"
IPSEC_SBINDIR="${IPSEC_SBINDIR-@IPSEC_SBINDIR@}"
IPSEC_CONFS="${IPSEC_CONFS-@IPSEC_CONFS@}"
IPSEC_DIR="$IPSEC_LIBDIR"
export IPSEC_DIR IPSEC_CONFS IPSEC_LIBDIR IPSEC_EXECDIR
# standardize PATH, and export it for everything else's benefit
PATH="${IPSEC_SBINDIR}":/sbin:/usr/sbin:/usr/local/bin:/bin:/usr/bin
export PATH
# things not to be listed in --help command list
DONTMENTION='^(ipsec|_.*|.*\.old|.*~)$'
# version numbering (details filled in by build)
# Possibly should call a C program to invoke the version_code() function
# instead, but for performance's sake, we inline it here (and only here).
version="xxx"
# export the version information
IPSEC_VERSION="$version"
export IPSEC_VERSION
# function for the funky user/kernel version stuff
fixversion() {
if test -f /proc/net/ipsec_version
then
kv="`awk '{print $NF}' /proc/net/ipsec_version`"
else
kv="(no kernel code presently loaded)"
fi
if test " $kv" != " $version"
then
version="U$version/K$kv"
fi
}
case "$1" in
'')
echo "Usage: ipsec command argument ..."
echo "Use --help for list of commands, or see ipsec(8) manual page"
echo "or the FreeS/WAN documentation for names of the common ones."
echo "Most have their own manual pages, e.g. ipsec_auto(8)."
echo "See <http://www.freeswan.org> for more general info."
exit 0
;;
--help)
echo "Usage: ipsec command argument ..."
echo "where command is one of:"
for f in `ls $IPSEC_LIBDIR $IPSEC_EXECDIR | egrep -v -i "$DONTMENTION"`
do
if test -x $IPSEC_LIBDIR/$f || test -x $IPSEC_EXECDIR/$f
then
echo " $f"
fi
done
echo
echo "Most of these have their own manual pages, e.g. ipsec_auto(8)."
echo "See also <http://www.freeswan.org> or the ipsec(8) manual page."
exit 0
;;
version|--version)
fixversion
echo "Linux FreeS/WAN $version"
echo "See \`ipsec --copyright' for copyright information."
if [ -f $IPSEC_LIBDIR/distro.txt ]
then
cat $IPSEC_LIBDIR/distro.txt
fi
exit 0
;;
--versioncode)
fixversion
echo "$version"
exit 0
;;
--copyright)
set _copyright
# and fall through, invoking "ipsec _copyright"
;;
--directory)
echo "$IPSEC_DIR"
exit 0
;;
--confdir)
echo "$IPSEC_CONFS"
exit 0
;;
--*)
echo "$0: unknown option \`$1' (perhaps command name was omitted?)" >&2
exit 1
;;
esac
cmd="$1"
shift
path="$IPSEC_EXECDIR/$cmd"
if test ! -x "$path"
then
path="$IPSEC_LIBDIR/$cmd"
if test ! -x "$path"
then
echo "$0: unknown IPsec command \`$cmd' (\`ipsec --help' for list)" >&2
exit 1
fi
fi
exec $path "$@"
|