2007-03-24 23:26:32 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2007-03-28 18:19:35 +02:00
|
|
|
# Script to install Shorewall-perl.
|
2007-03-24 23:26:32 +01:00
|
|
|
#
|
2007-09-08 18:09:51 +02:00
|
|
|
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
2007-03-24 23:26:32 +01:00
|
|
|
#
|
2008-07-27 23:00:08 +02:00
|
|
|
# (c) 2007,2008 - Tom Eastep (teastep@shorewall.net)
|
2007-03-24 23:26:32 +01:00
|
|
|
#
|
|
|
|
# Shorewall documentation is available at http://shorewall.net
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of Version 2 of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2007-09-08 18:09:51 +02:00
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2007-03-24 23:26:32 +01:00
|
|
|
#
|
|
|
|
|
2008-10-03 17:20:51 +02:00
|
|
|
VERSION=4.2.0
|
2007-03-24 23:26:32 +01:00
|
|
|
|
|
|
|
usage() # $1 = exit status
|
|
|
|
{
|
|
|
|
ME=$(basename $0)
|
|
|
|
echo "usage: $ME"
|
|
|
|
echo " $ME -v"
|
|
|
|
echo " $ME -h"
|
|
|
|
echo " $ME -n"
|
|
|
|
exit $1
|
|
|
|
}
|
|
|
|
|
|
|
|
split() {
|
2008-03-14 03:07:28 +01:00
|
|
|
local ifs
|
|
|
|
ifs=$IFS
|
2007-03-24 23:26:32 +01:00
|
|
|
IFS=:
|
|
|
|
set -- $1
|
|
|
|
echo $*
|
|
|
|
IFS=$ifs
|
|
|
|
}
|
|
|
|
|
|
|
|
qt()
|
|
|
|
{
|
|
|
|
"$@" >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
mywhich() {
|
|
|
|
local dir
|
|
|
|
|
|
|
|
for dir in $(split $PATH); do
|
|
|
|
if [ -x $dir/$1 ]; then
|
|
|
|
echo $dir/$1
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
return 2
|
|
|
|
}
|
|
|
|
|
|
|
|
run_install()
|
|
|
|
{
|
|
|
|
if ! install $*; then
|
|
|
|
echo
|
|
|
|
echo "ERROR: Failed to install $*" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
delete_file() # $1 = file to delete
|
|
|
|
{
|
|
|
|
rm -f $1
|
|
|
|
}
|
|
|
|
|
|
|
|
install_file() # $1 = source $2 = target $3 = mode
|
|
|
|
{
|
|
|
|
run_install $OWNERSHIP -m $3 $1 ${2}
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Parse the run line
|
|
|
|
#
|
|
|
|
# DEST is the SysVInit script directory
|
|
|
|
# INIT is the name of the script in the $DEST directory
|
|
|
|
# RUNLEVELS is the chkconfig parmeters for firewall
|
|
|
|
# ARGS is "yes" if we've already parsed an argument
|
|
|
|
#
|
|
|
|
ARGS=""
|
|
|
|
|
|
|
|
if [ -z "$DEST" ] ; then
|
|
|
|
DEST="/etc/init.d"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$INIT" ] ; then
|
|
|
|
INIT="shorewall"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$RUNLEVELS" ] ; then
|
|
|
|
RUNLEVELS=""
|
|
|
|
fi
|
|
|
|
|
2008-04-30 17:11:26 +02:00
|
|
|
case $(uname) in
|
|
|
|
CYGWIN*)
|
|
|
|
DEST=
|
|
|
|
INIT=
|
|
|
|
OWNER=$(id -un)
|
|
|
|
GROUP=$(id -gn)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
[ -z "$OWNER" ] && OWNER=root
|
|
|
|
[ -z "$GROUP" ] && GROUP=root
|
|
|
|
;;
|
|
|
|
esac
|
2007-03-24 23:26:32 +01:00
|
|
|
|
|
|
|
NOBACKUP=
|
|
|
|
|
|
|
|
while [ $# -gt 0 ] ; do
|
|
|
|
case "$1" in
|
|
|
|
-h|help|?)
|
|
|
|
usage 0
|
|
|
|
;;
|
|
|
|
-v)
|
2007-03-28 18:19:35 +02:00
|
|
|
echo "Shorewall-perl Installer Version $VERSION"
|
2007-03-24 23:26:32 +01:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
-n)
|
|
|
|
NOBACKUP=Yes
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
ARGS="yes"
|
|
|
|
done
|
|
|
|
|
|
|
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
|
|
|
|
|
|
|
OWNERSHIP="-o $OWNER -g $GROUP"
|
|
|
|
|
|
|
|
if [ -n "$PREFIX" ]; then
|
|
|
|
if [ `id -u` != 0 ] ; then
|
|
|
|
echo "Not setting file owner/group permissions, not running as root."
|
|
|
|
OWNERSHIP=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
install -d $OWNERSHIP -m 755 ${PREFIX}/sbin
|
|
|
|
install -d $OWNERSHIP -m 755 ${PREFIX}${DEST}
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Change to the directory containing this script
|
|
|
|
#
|
|
|
|
cd "$(dirname $0)"
|
|
|
|
|
2007-03-28 18:19:35 +02:00
|
|
|
echo "Installing Shorewall-perl Version $VERSION"
|
2007-03-24 23:26:32 +01:00
|
|
|
|
|
|
|
#
|
2007-03-28 18:19:35 +02:00
|
|
|
# /usr/share/shorewall-perl if needed
|
2007-03-24 23:26:32 +01:00
|
|
|
#
|
2007-03-28 18:19:35 +02:00
|
|
|
mkdir -p ${PREFIX}/usr/share/shorewall-perl/Shorewall
|
2007-03-24 23:26:32 +01:00
|
|
|
|
2007-03-28 18:19:35 +02:00
|
|
|
chmod 755 ${PREFIX}/usr/share/shorewall-perl
|
|
|
|
chmod 755 ${PREFIX}/usr/share/shorewall-perl/Shorewall
|
2007-03-24 23:26:32 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install the Compiler
|
|
|
|
#
|
|
|
|
|
2007-07-02 16:50:57 +02:00
|
|
|
install_file compiler.pl ${PREFIX}/usr/share/shorewall-perl/compiler.pl 0755
|
2007-03-24 23:26:32 +01:00
|
|
|
|
|
|
|
echo
|
2007-03-28 18:19:35 +02:00
|
|
|
echo "Compiler installed in ${PREFIX}/usr/share/shorewall-perl/compiler.pl"
|
2007-03-24 23:26:32 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Install the libraries
|
|
|
|
#
|
|
|
|
for f in Shorewall/*.pm ; do
|
2007-03-28 18:19:35 +02:00
|
|
|
install_file $f ${PREFIX}/usr/share/shorewall-perl/$f 0644
|
2007-07-02 16:50:57 +02:00
|
|
|
echo "Module ${f%.*} installed as ${PREFIX}/usr/share/shorewall-perl/$f"
|
2007-03-24 23:26:32 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
#
|
|
|
|
# Install the program skeleton files
|
|
|
|
#
|
|
|
|
for f in prog.* ; do
|
2007-03-28 18:19:35 +02:00
|
|
|
install_file $f ${PREFIX}/usr/share/shorewall-perl/$f 0644
|
|
|
|
echo "Program skeleton file ${f#*.} installed as ${PREFIX}/usr/share/shorewall-perl/$f"
|
2007-03-24 23:26:32 +01:00
|
|
|
done
|
|
|
|
|
2007-05-18 00:24:01 +02:00
|
|
|
echo $VERSION > ${PREFIX}/usr/share/shorewall-perl/version
|
2007-03-24 23:26:32 +01:00
|
|
|
#
|
|
|
|
# Report Success
|
|
|
|
#
|
2007-03-28 18:19:35 +02:00
|
|
|
echo "Shorewall-perl Version $VERSION Installed"
|