Installer and Uninstaller

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@1107 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2004-01-31 18:06:14 +00:00
parent 517d4dbf46
commit b7d1de7a4e
3 changed files with 261 additions and 327 deletions

View File

@ -49,112 +49,92 @@ restore_file() # $1 = file to restore
fi
}
if [ ! -f /usr/share/shorewall/version-${VERSION}.bkout ]; then
if [ ! -f /usr/share/shorewall2/version-${VERSION}.bkout ]; then
echo "Shorewall Version $VERSION is not installed"
exit 1
fi
echo "Backing Out Installation of Shorewall $VERSION"
if [ -L /usr/share/shorewall/init ]; then
FIREWALL=`ls -l /usr/share/shorewall/firewall | sed 's/^.*> //'`
if [ -L /usr/share/shorewall2/init ]; then
FIREWALL=`ls -l /usr/share/shorewall2/firewall | sed 's/^.*> //'`
restore_file $FIREWALL
restore_file /usr/share/shorewall/firewall
elif [ -L /usr/lib/shorewall/firewall ]; then
FIREWALL=`ls -l /usr/lib/shorewall/firewall | sed 's/^.*> //'`
restore_file $FIREWALL
elif [ -L /var/lib/shorewall/firewall ]; then
FIREWALL=`ls -l /var/lib/shorewall/firewall | sed 's/^.*> //'`
restore_file $FIREWALL
elif [ -L /usr/lib/shorewall/init ]; then
FIREWALL=`ls -l /usr/lib/shorewall/init | sed 's/^.*> //'`
restore_file $FIREWALL
restore_file /usr/lib/shorewall/firewall
fi
restore_file /sbin/shorewall
[ -f /etc/shorewall.conf.$VERSION ] && rm -f /etc/shorewall.conf.$VERSION
restore_file /etc/shorewall/shorewall.conf
restore_file /etc/shorewall/functions
restore_file /usr/lib/shorewall/functions
restore_file /var/lib/shorewall/functions
restore_file /usr/lib/shorewall/firewall
restore_file /usr/lib/shorewall/help
restore_file /etc/shorewall/common.def
restore_file /etc/shorewall/icmp.def
restore_file /etc/shorewall/zones
restore_file /etc/shorewall/policy
restore_file /etc/shorewall/interfaces
restore_file /etc/shorewall/hosts
restore_file /etc/shorewall/rules
restore_file /etc/shorewall/nat
restore_file /etc/shorewall/params
restore_file /etc/shorewall/proxyarp
restore_file /etc/shorewall/routestopped
restore_file /etc/shorewall/maclist
restore_file /etc/shorewall/masq
restore_file /etc/shorewall/modules
restore_file /etc/shorewall/tcrules
restore_file /etc/shorewall/tos
restore_file /etc/shorewall/tunnels
restore_file /etc/shorewall/blacklist
restore_file /etc/shorewall/whitelist
restore_file /etc/shorewall/rfc1918
restore_file /etc/shorewall/init
restore_file /etc/shorewall/start
restore_file /etc/shorewall/stop
restore_file /etc/shorewall/stopped
restore_file /etc/shorewall/ecn
restore_file /etc/shorewall/accounting
restore_file /etc/shorewall/usersets
restore_file /etc/shorewall/users
restore_file /etc/shorewall/actions
restore_file /etc/shorewall/action.template
if [ -f /usr/lib/shorewall/version-${VERSION}.bkout ]; then
restore_file /usr/lib/shorewall/version
oldversion="`cat /usr/lib/shorewall/version`"
elif [ -f /var/lib/shorewall/version-${VERSION}.bkout ]; then
restore_file /var/lib/shorewall/version
oldversion="`cat /var/lib/shorewall/version`"
else
restore_file /etc/shorewall/version
oldversion="`cat /etc/shorewall/version`"
restore_file /etc/init.d/shorewall2
fi
echo "Shorewall Restored to Version $oldversion"
restore_file /usr/share/shorewall2/firewall
restore_file /sbin/shorewall2
restore_file /etc/shorewall2/shorewall.conf
restore_file /etc/shorewall2/functions
restore_file /usr/lib/shorewall2/functions
restore_file /var/lib/shorewall2/functions
restore_file /usr/lib/shorewall2/firewall
restore_file /usr/lib/shorewall2/help
restore_file /etc/shorewall2/common.def
restore_file /etc/shorewall2/icmp.def
restore_file /etc/shorewall2/zones
restore_file /etc/shorewall2/policy
restore_file /etc/shorewall2/interfaces
restore_file /etc/shorewall2/hosts
restore_file /etc/shorewall2/rules
restore_file /etc/shorewall2/nat
restore_file /etc/shorewall2/params
restore_file /etc/shorewall2/proxyarp
restore_file /etc/shorewall2/routestopped
restore_file /etc/shorewall2/maclist
restore_file /etc/shorewall2/masq
restore_file /etc/shorewall2/modules
restore_file /etc/shorewall2/tcrules
restore_file /etc/shorewall2/tos
restore_file /etc/shorewall2/tunnels
restore_file /etc/shorewall2/blacklist
restore_file /etc/shorewall2/whitelist
restore_file /etc/shorewall2/rfc1918
restore_file /etc/shorewall2/init
restore_file /etc/shorewall2/start
restore_file /etc/shorewall2/stop
restore_file /etc/shorewall2/stopped
restore_file /etc/shorewall2/ecn
restore_file /etc/shorewall2/accounting
restore_file /etc/shorewall2/actions
for f in /etc/shorewall2/action.*-${VERSION}.bkout; do
restore_file $(echo $f | sed "s/-${VERSION}.bkout//")
done
restore_file /usr/share/shorewall2/version
echo "Shorewall2 Restored to Version $oldversion"

View File

@ -77,7 +77,7 @@ run_install()
cant_autostart()
{
echo
echo "WARNING: Unable to configure Shorewall to start"
echo "WARNING: Unable to configure Shorewall2 to start"
echo " automatically at boot"
}
@ -105,20 +105,6 @@ delete_file() # $1 = file to delete
fi
}
modify_rclocal()
{
if [ -f /etc/rc.d/rc.local ]; then
if [ -z "`grep shorewall /etc/rc.d/rc.local`" ]; then
cp -f /etc/rc.d/rc.local /etc/rc.d/rc.local-shorewall.bkout
echo >> /etc/rc.d/rc.local
echo "/sbin/shorewall start" >> /etc/rc.d/rc.local
echo "/etc/rc.d/rc.local modified to start Shorewall"
fi
else
cant_autostart
fi
}
install_file_with_backup() # $1 = source $2 = target $3 = mode
{
backup_file $2
@ -195,7 +181,7 @@ if [ -n "$PREFIX" ]; then
install -d -o $OWNER -g $GROUP -m 755 ${PREFIX}${DEST}
fi
FIREWALL="shorewall"
FIREWALL="shorewall2"
#
# Change to the directory containing this script
@ -205,18 +191,18 @@ cd "`dirname $0`"
echo "Installing Shorewall Version $VERSION"
#
# Check for /etc/shorewall
# Check for /etc/shorewall2
#
if [ -d ${PREFIX}/etc/shorewall ]; then
if [ -d ${PREFIX}/etc/shorewall2 ]; then
first_install=""
else
first_install="Yes"
fi
install_file_with_backup shorewall ${PREFIX}/sbin/shorewall 0544
install_file_with_backup shorewall ${PREFIX}/sbin/shorewall2 0544
echo
echo "Shorewall control program installed in ${PREFIX}/sbin/shorewall"
echo "Shorewall2 control program installed in ${PREFIX}/sbin/shorewall2"
#
# Install the Firewall Script
@ -227,64 +213,59 @@ echo
echo "Shorewall script installed in ${PREFIX}${DEST}/$FIREWALL"
#
# Create /etc/shorewall, /usr/share/shorewall and /var/shorewall if needed
# Create /etc/shorewall2, /usr/share/shorewall2 and /var/shorewall if needed
#
mkdir -p ${PREFIX}/etc/shorewall
mkdir -p ${PREFIX}/usr/share/shorewall
mkdir -p ${PREFIX}/etc/shorewall2
mkdir -p ${PREFIX}/usr/share/shorewall2
mkdir -p ${PREFIX}/var/lib/shorewall
#
# Install the config file
#
if [ -f ${PREFIX}/etc/shorewall/shorewall.conf ]; then
backup_file /etc/shorewall/shorewall.conf
if [ -f ${PREFIX}/etc/shorewall2/shorewall.conf ]; then
backup_file /etc/shorewall2/shorewall.conf
else
run_install -o $OWNER -g $GROUP -m 0744 shorewall.conf ${PREFIX}/etc/shorewall/shorewall.conf
run_install -o $OWNER -g $GROUP -m 0744 shorewall.conf ${PREFIX}/etc/shorewall2/shorewall.conf
echo
echo "Config file installed as ${PREFIX}/etc/shorewall/shorewall.conf"
echo "Config file installed as ${PREFIX}/etc/shorewall2/shorewall.conf"
fi
#
# Install the zones file
#
if [ -f ${PREFIX}/etc/shorewall/zones ]; then
backup_file /etc/shorewall/zones
if [ -f ${PREFIX}/etc/shorewall2/zones ]; then
backup_file /etc/shorewall2/zones
else
run_install -o $OWNER -g $GROUP -m 0744 zones ${PREFIX}/etc/shorewall/zones
run_install -o $OWNER -g $GROUP -m 0744 zones ${PREFIX}/etc/shorewall2/zones
echo
echo "Zones file installed as ${PREFIX}/etc/shorewall/zones"
echo "Zones file installed as ${PREFIX}/etc/shorewall2/zones"
fi
#
# Install the functions file
#
if [ -f ${PREFIX}/etc/shorewall/functions ]; then
backup_file ${PREFIX}/etc/shorewall/functions
rm -f ${PREFIX}/etc/shorewall/functions
if [ -f ${PREFIX}/etc/shorewall2/functions ]; then
backup_file ${PREFIX}/etc/shorewall2/functions
rm -f ${PREFIX}/etc/shorewall2/functions
fi
if [ -f ${PREFIX}/var/lib/shorewall/functions ]; then
backup_file ${PREFIX}/var/lib/shorewall/functions
rm -f ${PREFIX}/var/lib/shorewall/functions
fi
install_file_with_backup functions ${PREFIX}/usr/share/shorewall/functions 0444
install_file_with_backup functions ${PREFIX}/usr/share/shorewall2/functions 0444
echo
echo "Common functions installed in ${PREFIX}/usr/share/shorewall/functions"
echo "Common functions installed in ${PREFIX}/usr/share/shorewall2/functions"
#
# Install the Help file
#
install_file_with_backup help ${PREFIX}/usr/share/shorewall/help 0544
install_file_with_backup help ${PREFIX}/usr/share/shorewall2/help 0544
echo
echo "Help command executor installed in ${PREFIX}/usr/share/shorewall/help"
echo "Help command executor installed in ${PREFIX}/usr/share/shorewall2/help"
#
# Install the common.def file
#
install_file_with_backup common.def ${PREFIX}/etc/shorewall/common.def 0444
install_file_with_backup common.def ${PREFIX}/etc/shorewall2/common.def 0444
echo
echo "Common rules installed in ${PREFIX}/etc/shorewall/common.def"
echo "Common rules installed in ${PREFIX}/etc/shorewall2/common.def"
#
# Delete the icmp.def file
@ -294,337 +275,317 @@ delete_file icmp.def
#
# Install the policy file
#
if [ -f ${PREFIX}/etc/shorewall/policy ]; then
backup_file /etc/shorewall/policy
if [ -f ${PREFIX}/etc/shorewall2/policy ]; then
backup_file /etc/shorewall2/policy
else
run_install -o $OWNER -g $GROUP -m 0600 policy ${PREFIX}/etc/shorewall/policy
run_install -o $OWNER -g $GROUP -m 0600 policy ${PREFIX}/etc/shorewall2/policy
echo
echo "Policy file installed as ${PREFIX}/etc/shorewall/policy"
echo "Policy file installed as ${PREFIX}/etc/shorewall2/policy"
fi
#
# Install the interfaces file
#
if [ -f ${PREFIX}/etc/shorewall/interfaces ]; then
backup_file /etc/shorewall/interfaces
if [ -f ${PREFIX}/etc/shorewall2/interfaces ]; then
backup_file /etc/shorewall2/interfaces
else
run_install -o $OWNER -g $GROUP -m 0600 interfaces ${PREFIX}/etc/shorewall/interfaces
run_install -o $OWNER -g $GROUP -m 0600 interfaces ${PREFIX}/etc/shorewall2/interfaces
echo
echo "Interfaces file installed as ${PREFIX}/etc/shorewall/interfaces"
echo "Interfaces file installed as ${PREFIX}/etc/shorewall2/interfaces"
fi
#
# Install the hosts file
#
if [ -f ${PREFIX}/etc/shorewall/hosts ]; then
backup_file /etc/shorewall/hosts
if [ -f ${PREFIX}/etc/shorewall2/hosts ]; then
backup_file /etc/shorewall2/hosts
else
run_install -o $OWNER -g $GROUP -m 0600 hosts ${PREFIX}/etc/shorewall/hosts
run_install -o $OWNER -g $GROUP -m 0600 hosts ${PREFIX}/etc/shorewall2/hosts
echo
echo "Hosts file installed as ${PREFIX}/etc/shorewall/hosts"
echo "Hosts file installed as ${PREFIX}/etc/shorewall2/hosts"
fi
#
# Install the rules file
#
if [ -f ${PREFIX}/etc/shorewall/rules ]; then
backup_file /etc/shorewall/rules
if [ -f ${PREFIX}/etc/shorewall2/rules ]; then
backup_file /etc/shorewall2/rules
else
run_install -o $OWNER -g $GROUP -m 0600 rules ${PREFIX}/etc/shorewall/rules
run_install -o $OWNER -g $GROUP -m 0600 rules ${PREFIX}/etc/shorewall2/rules
echo
echo "Rules file installed as ${PREFIX}/etc/shorewall/rules"
echo "Rules file installed as ${PREFIX}/etc/shorewall2/rules"
fi
#
# Install the NAT file
#
if [ -f ${PREFIX}/etc/shorewall/nat ]; then
backup_file /etc/shorewall/nat
if [ -f ${PREFIX}/etc/shorewall2/nat ]; then
backup_file /etc/shorewall2/nat
else
run_install -o $OWNER -g $GROUP -m 0600 nat ${PREFIX}/etc/shorewall/nat
run_install -o $OWNER -g $GROUP -m 0600 nat ${PREFIX}/etc/shorewall2/nat
echo
echo "NAT file installed as ${PREFIX}/etc/shorewall/nat"
echo "NAT file installed as ${PREFIX}/etc/shorewall2/nat"
fi
#
# Install the Parameters file
#
if [ -f ${PREFIX}/etc/shorewall/params ]; then
backup_file /etc/shorewall/params
if [ -f ${PREFIX}/etc/shorewall2/params ]; then
backup_file /etc/shorewall2/params
else
run_install -o $OWNER -g $GROUP -m 0600 params ${PREFIX}/etc/shorewall/params
run_install -o $OWNER -g $GROUP -m 0600 params ${PREFIX}/etc/shorewall2/params
echo
echo "Parameter file installed as ${PREFIX}/etc/shorewall/params"
echo "Parameter file installed as ${PREFIX}/etc/shorewall2/params"
fi
#
# Install the proxy ARP file
#
if [ -f ${PREFIX}/etc/shorewall/proxyarp ]; then
backup_file /etc/shorewall/proxyarp
if [ -f ${PREFIX}/etc/shorewall2/proxyarp ]; then
backup_file /etc/shorewall2/proxyarp
else
run_install -o $OWNER -g $GROUP -m 0600 proxyarp ${PREFIX}/etc/shorewall/proxyarp
run_install -o $OWNER -g $GROUP -m 0600 proxyarp ${PREFIX}/etc/shorewall2/proxyarp
echo
echo "Proxy ARP file installed as ${PREFIX}/etc/shorewall/proxyarp"
echo "Proxy ARP file installed as ${PREFIX}/etc/shorewall2/proxyarp"
fi
#
# Install the Stopped Routing file
#
if [ -f ${PREFIX}/etc/shorewall/routestopped ]; then
backup_file /etc/shorewall/routestopped
if [ -f ${PREFIX}/etc/shorewall2/routestopped ]; then
backup_file /etc/shorewall2/routestopped
else
run_install -o $OWNER -g $GROUP -m 0600 routestopped ${PREFIX}/etc/shorewall/routestopped
run_install -o $OWNER -g $GROUP -m 0600 routestopped ${PREFIX}/etc/shorewall2/routestopped
echo
echo "Stopped Routing file installed as ${PREFIX}/etc/shorewall/routestopped"
echo "Stopped Routing file installed as ${PREFIX}/etc/shorewall2/routestopped"
fi
#
# Install the Mac List file
#
if [ -f ${PREFIX}/etc/shorewall/maclist ]; then
backup_file /etc/shorewall/maclist
if [ -f ${PREFIX}/etc/shorewall2/maclist ]; then
backup_file /etc/shorewall2/maclist
else
run_install -o $OWNER -g $GROUP -m 0600 maclist ${PREFIX}/etc/shorewall/maclist
run_install -o $OWNER -g $GROUP -m 0600 maclist ${PREFIX}/etc/shorewall2/maclist
echo
echo "MAC list file installed as ${PREFIX}/etc/shorewall/maclist"
echo "MAC list file installed as ${PREFIX}/etc/shorewall2/maclist"
fi
#
# Install the Masq file
#
if [ -f ${PREFIX}/etc/shorewall/masq ]; then
backup_file /etc/shorewall/masq
if [ -f ${PREFIX}/etc/shorewall2/masq ]; then
backup_file /etc/shorewall2/masq
else
run_install -o $OWNER -g $GROUP -m 0600 masq ${PREFIX}/etc/shorewall/masq
run_install -o $OWNER -g $GROUP -m 0600 masq ${PREFIX}/etc/shorewall2/masq
echo
echo "Masquerade file installed as ${PREFIX}/etc/shorewall/masq"
echo "Masquerade file installed as ${PREFIX}/etc/shorewall2/masq"
fi
#
# Install the Modules file
#
if [ -f ${PREFIX}/etc/shorewall/modules ]; then
backup_file /etc/shorewall/modules
if [ -f ${PREFIX}/etc/shorewall2/modules ]; then
backup_file /etc/shorewall2/modules
else
run_install -o $OWNER -g $GROUP -m 0600 modules ${PREFIX}/etc/shorewall/modules
run_install -o $OWNER -g $GROUP -m 0600 modules ${PREFIX}/etc/shorewall2/modules
echo
echo "Modules file installed as ${PREFIX}/etc/shorewall/modules"
echo "Modules file installed as ${PREFIX}/etc/shorewall2/modules"
fi
#
# Install the TC Rules file
#
if [ -f ${PREFIX}/etc/shorewall/tcrules ]; then
backup_file /etc/shorewall/tcrules
if [ -f ${PREFIX}/etc/shorewall2/tcrules ]; then
backup_file /etc/shorewall2/tcrules
else
run_install -o $OWNER -g $GROUP -m 0600 tcrules ${PREFIX}/etc/shorewall/tcrules
run_install -o $OWNER -g $GROUP -m 0600 tcrules ${PREFIX}/etc/shorewall2/tcrules
echo
echo "TC Rules file installed as ${PREFIX}/etc/shorewall/tcrules"
echo "TC Rules file installed as ${PREFIX}/etc/shorewall2/tcrules"
fi
#
# Install the TOS file
#
if [ -f ${PREFIX}/etc/shorewall/tos ]; then
backup_file /etc/shorewall/tos
if [ -f ${PREFIX}/etc/shorewall2/tos ]; then
backup_file /etc/shorewall2/tos
else
run_install -o $OWNER -g $GROUP -m 0600 tos ${PREFIX}/etc/shorewall/tos
run_install -o $OWNER -g $GROUP -m 0600 tos ${PREFIX}/etc/shorewall2/tos
echo
echo "TOS file installed as ${PREFIX}/etc/shorewall/tos"
echo "TOS file installed as ${PREFIX}/etc/shorewall2/tos"
fi
#
# Install the Tunnels file
#
if [ -f ${PREFIX}/etc/shorewall/tunnels ]; then
backup_file /etc/shorewall/tunnels
if [ -f ${PREFIX}/etc/shorewall2/tunnels ]; then
backup_file /etc/shorewall2/tunnels
else
run_install -o $OWNER -g $GROUP -m 0600 tunnels ${PREFIX}/etc/shorewall/tunnels
run_install -o $OWNER -g $GROUP -m 0600 tunnels ${PREFIX}/etc/shorewall2/tunnels
echo
echo "Tunnels file installed as ${PREFIX}/etc/shorewall/tunnels"
echo "Tunnels file installed as ${PREFIX}/etc/shorewall2/tunnels"
fi
#
# Install the blacklist file
#
if [ -f ${PREFIX}/etc/shorewall/blacklist ]; then
backup_file /etc/shorewall/blacklist
if [ -f ${PREFIX}/etc/shorewall2/blacklist ]; then
backup_file /etc/shorewall2/blacklist
else
run_install -o $OWNER -g $GROUP -m 0600 blacklist ${PREFIX}/etc/shorewall/blacklist
run_install -o $OWNER -g $GROUP -m 0600 blacklist ${PREFIX}/etc/shorewall2/blacklist
echo
echo "Blacklist file installed as ${PREFIX}/etc/shorewall/blacklist"
echo "Blacklist file installed as ${PREFIX}/etc/shorewall2/blacklist"
fi
#
# Backup and remove the whitelist file
#
if [ -f ${PREFIX}/etc/shorewall/whitelist ]; then
backup_file /etc/shorewall/whitelist
rm -f ${PREFIX}/etc/shorewall/whitelist
if [ -f ${PREFIX}/etc/shorewall2/whitelist ]; then
backup_file /etc/shorewall2/whitelist
rm -f ${PREFIX}/etc/shorewall2/whitelist
fi
#
# Install the rfc1918 file
#
if [ -f ${PREFIX}/etc/shorewall/rfc1918 ]; then
backup_file /etc/shorewall/rfc1918
if [ -f ${PREFIX}/etc/shorewall2/rfc1918 ]; then
backup_file /etc/shorewall2/rfc1918
else
run_install -o $OWNER -g $GROUP -m 0600 rfc1918 ${PREFIX}/etc/shorewall/rfc1918
run_install -o $OWNER -g $GROUP -m 0600 rfc1918 ${PREFIX}/etc/shorewall2/rfc1918
echo
echo "RFC 1918 file installed as ${PREFIX}/etc/shorewall/rfc1918"
echo "RFC 1918 file installed as ${PREFIX}/etc/shorewall2/rfc1918"
fi
#
# Install the init file
#
if [ -f ${PREFIX}/etc/shorewall/init ]; then
backup_file /etc/shorewall/init
if [ -f ${PREFIX}/etc/shorewall2/init ]; then
backup_file /etc/shorewall2/init
else
run_install -o $OWNER -g $GROUP -m 0600 init ${PREFIX}/etc/shorewall/init
run_install -o $OWNER -g $GROUP -m 0600 init ${PREFIX}/etc/shorewall2/init
echo
echo "Init file installed as ${PREFIX}/etc/shorewall/init"
echo "Init file installed as ${PREFIX}/etc/shorewall2/init"
fi
#
# Install the start file
#
if [ -f ${PREFIX}/etc/shorewall/start ]; then
backup_file /etc/shorewall/start
if [ -f ${PREFIX}/etc/shorewall2/start ]; then
backup_file /etc/shorewall2/start
else
run_install -o $OWNER -g $GROUP -m 0600 start ${PREFIX}/etc/shorewall/start
run_install -o $OWNER -g $GROUP -m 0600 start ${PREFIX}/etc/shorewall2/start
echo
echo "Start file installed as ${PREFIX}/etc/shorewall/start"
echo "Start file installed as ${PREFIX}/etc/shorewall2/start"
fi
#
# Install the stop file
#
if [ -f ${PREFIX}/etc/shorewall/stop ]; then
backup_file /etc/shorewall/stop
if [ -f ${PREFIX}/etc/shorewall2/stop ]; then
backup_file /etc/shorewall2/stop
else
run_install -o $OWNER -g $GROUP -m 0600 stop ${PREFIX}/etc/shorewall/stop
run_install -o $OWNER -g $GROUP -m 0600 stop ${PREFIX}/etc/shorewall2/stop
echo
echo "Stop file installed as ${PREFIX}/etc/shorewall/stop"
echo "Stop file installed as ${PREFIX}/etc/shorewall2/stop"
fi
#
# Install the stopped file
#
if [ -f ${PREFIX}/etc/shorewall/stopped ]; then
backup_file /etc/shorewall/stopped
if [ -f ${PREFIX}/etc/shorewall2/stopped ]; then
backup_file /etc/shorewall2/stopped
else
run_install -o $OWNER -g $GROUP -m 0600 stopped ${PREFIX}/etc/shorewall/stopped
run_install -o $OWNER -g $GROUP -m 0600 stopped ${PREFIX}/etc/shorewall2/stopped
echo
echo "Stopped file installed as ${PREFIX}/etc/shorewall/stopped"
echo "Stopped file installed as ${PREFIX}/etc/shorewall2/stopped"
fi
#
# Install the ECN file
#
if [ -f ${PREFIX}/etc/shorewall/ecn ]; then
backup_file /etc/shorewall/ecn
if [ -f ${PREFIX}/etc/shorewall2/ecn ]; then
backup_file /etc/shorewall2/ecn
else
run_install -o $OWNER -g $GROUP -m 0600 ecn ${PREFIX}/etc/shorewall/ecn
run_install -o $OWNER -g $GROUP -m 0600 ecn ${PREFIX}/etc/shorewall2/ecn
echo
echo "ECN file installed as ${PREFIX}/etc/shorewall/ecn"
echo "ECN file installed as ${PREFIX}/etc/shorewall2/ecn"
fi
#
# Install the Accounting file
#
if [ -f ${PREFIX}/etc/shorewall/accounting ]; then
backup_file /etc/shorewall/accounting
if [ -f ${PREFIX}/etc/shorewall2/accounting ]; then
backup_file /etc/shorewall2/accounting
else
run_install -o $OWNER -g $GROUP -m 0600 accounting ${PREFIX}/etc/shorewall/accounting
run_install -o $OWNER -g $GROUP -m 0600 accounting ${PREFIX}/etc/shorewall2/accounting
echo
echo "Accounting file installed as ${PREFIX}/etc/shorewall/accounting"
echo "Accounting file installed as ${PREFIX}/etc/shorewall2/accounting"
fi
#
# Install the User Sets file
#
if [ -f ${PREFIX}/etc/shorewall/usersets ]; then
backup_file /etc/shorewall/usersets
else
run_install -o $OWNER -g $GROUP -m 0600 usersets ${PREFIX}/etc/shorewall/usersets
echo
echo "User Sets file installed as ${PREFIX}/etc/shorewall/usersets"
fi
#
# Install the User file
#
if [ -f ${PREFIX}/etc/shorewall/users ]; then
backup_file /etc/shorewall/users
else
run_install -o $OWNER -g $GROUP -m 0600 users ${PREFIX}/etc/shorewall/users
echo
echo "Users file installed as ${PREFIX}/etc/shorewall/users"
fi
#
# Install the Actions file
#
if [ -f ${PREFIX}/etc/shorewall/actions ]; then
backup_file /etc/shorewall/actions
if [ -f ${PREFIX}/etc/shorewall2/actions ]; then
backup_file /etc/shorewall2/actions
else
run_install -o $OWNER -g $GROUP -m 0600 actions ${PREFIX}/etc/shorewall/actions
run_install -o $OWNER -g $GROUP -m 0600 actions ${PREFIX}/etc/shorewall2/actions
echo
echo "Actions file installed as ${PREFIX}/etc/shorewall/actions"
echo "Actions file installed as ${PREFIX}/etc/shorewall2/actions"
fi
#
# Install the Action Template file
# Install the Action files
#
if [ -f ${PREFIX}/etc/shorewall/action.template ]; then
backup_file /etc/shorewall/action.template
else
run_install -o $OWNER -g $GROUP -m 0600 action.template ${PREFIX}/etc/shorewall/action.template
echo
echo "Action Template file installed as ${PREFIX}/etc/shorewall/action.template"
fi
for f in action.* ; do
if [ -f ${PREFIX}/etc/shorewall2/$f ]; then
backup_file /etc/shorewall2/$f
else
run_install -o $OWNER -g $GROUP -m 0600 $f ${PREFIX}/etc/shorewall2/$f
echo
echo "Action ${f#*.} file installed as ${PREFIX}/etc/shorewall2/$f"
fi
done
#
# Backup the version file
#
if [ -z "$PREFIX" ]; then
if [ -f /usr/share/shorewall/version ]; then
backup_file /usr/share/shorewall/version
elif [ -f /usr/lib/shorewall/version ]; then
backup_file /usr/lib/shorewall/version
elif [ -n "$oldversion" ]; then
echo $oldversion > /usr/lib/shorewall/version-${VERSION}.bkout
else
echo "Unknown" > /usr/lib/shorewall/version-${VERSION}.bkout
if [ -f /usr/share/shorewall2/version ]; then
backup_file /usr/share/shorewall2/version
fi
fi
#
# Create the version file
#
echo "$VERSION" > ${PREFIX}/usr/share/shorewall/version
chmod 644 ${PREFIX}/usr/share/shorewall/version
echo "$VERSION" > ${PREFIX}/usr/share/shorewall2/version
chmod 644 ${PREFIX}/usr/share/shorewall2/version
#
# Remove and create the symbolic link to the init script
#
if [ -z "$PREFIX" ]; then
rm -f /usr/share/shorewall/init
ln -s ${DEST}/${FIREWALL} /usr/share/shorewall/init
rm -f /usr/share/shorewall2/init
ln -s ${DEST}/${FIREWALL} /usr/share/shorewall2/init
fi
#
# Install the firewall script
#
install_file_with_backup firewall ${PREFIX}/usr/share/shorewall/firewall 0544
install_file_with_backup firewall ${PREFIX}/usr/share/shorewall2/firewall 0544
if [ -z "$PREFIX" -a -n "$first_install" ]; then
if [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
if insserv /etc/init.d/shorewall ; then
echo
echo "Firewall will start automatically at boot"
else
cant_autostart
fi
elif [ -x /sbin/chkconfig -o -x /usr/sbin/chkconfig ]; then
if chkconfig --add $FIREWALL ; then
echo
echo "Firewall will start automatically in run levels as follows:"
chkconfig --list $FIREWALL
else
cant_autostart
fi
elif [ -x /sbin/rc-update ]; then
if rc-update add shorewall default; then
echo
echo "Firewall will start automatically at boot"
else
cant_autostart
fi
else
cant_autostart
fi
if [ -n "$DEBIAN" ]; then
run_install -o $OWNER -g $GROUP -m 0644 default.debian /etc/default/shorewall
run_install -o $OWNER -g $GROUP -m 0644 default.debian /etc/default/shorewall2
ln -s ../init.d/shorewall2 /etc/rcS.d/S40shorewall2
echo
echo "Shorewall2 will start automatically at boot"
else
if [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
if insserv /etc/init.d/shorewalls ; then
echo
echo "Shorewall2 will start automatically at boot"
else
cant_autostart
fi
elif [ -x /sbin/chkconfig -o -x /usr/sbin/chkconfig ]; then
if chkconfig --add shorewall2 ; then
echo
echo "Shorewall2 will start automatically in run levels as follows:"
chkconfig --list $FIREWALL
else
cant_autostart
fi
elif [ -x /sbin/rc-update ]; then
if rc-update add shorewall2 default; then
echo
echo "Shorewall2 will start automatically at boot"
else
cant_autostart
fi
else
cant_autostart
fi
echo \
"########################################################################
# REMOVE THIS FILE AFTER YOU HAVE CONFIGURED SHOREWALL #
########################################################################" > /etc/shorewall/startup_disabled
########################################################################" > /etc/shorewall2/startup_disabled
fi
fi
@ -632,4 +593,4 @@ fi
# Report Success
#
echo
echo "Shorewall Version $VERSION Installed"
echo "Shorewall2 Version $VERSION Installed"

View File

@ -60,8 +60,8 @@ remove_file() # $1 = file to restore
fi
}
if [ -f /usr/share/shorewall/version ]; then
INSTALLED_VERSION="`cat /usr/lib/shorewall/version`"
if [ -f /usr/share/shorewall2/version ]; then
INSTALLED_VERSION="`cat /usr/share/shorewall2/version`"
if [ "$INSTALLED_VERSION" != "$VERSION" ]; then
echo "WARNING: Shorewall Version $INSTALLED_VERSION is installed"
echo " and this is the $VERSION uninstaller."
@ -75,17 +75,13 @@ fi
echo "Uninstalling Shorewall2 $VERSION"
if qt iptables -L shorewall -n; then
/sbin/shorewall clear
/sbin/shorewall2 clear
fi
if [ -L /usr/lib/shorewall/firewall ]; then
FIREWALL=`ls -l /usr/lib/shorewall/firewall | sed 's/^.*> //'`
elif [ -L /var/lib/shorewall/firewall ]; then
FIREWALL=`ls -l /var/lib/shorewall/firewall | sed 's/^.*> //'`
elif [ -L /usr/lib/shorewall/init ]; then
FIREWALL=`ls -l /usr/lib/shorewall/init | sed 's/^.*> //'`
if [ -L /usr/share/shorewall2/init ]; then
FIREWALL=`ls -l /usr/share/shorewall2/init | sed 's/^.*> //'`
else
FIREWALL=
FIREWALL=/etc/init.d/shorewall2
fi
if [ -n "$FIREWALL" ]; then
@ -93,24 +89,21 @@ if [ -n "$FIREWALL" ]; then
insserv -r $FIREWALL
elif [ -x /sbin/chkconfig -o -x /usr/sbin/chkconfig ]; then
chkconfig --del `basename $FIREWALL`
else
rm -f /etc/rc*.d/*`basename $FIREWALL`
fi
remove_file $FIREWALL
rm -f ${FIREWALL}-*.bkout
fi
rm -f /sbin/shorewall
rm -f /sbin/shorewall-*.bkout
rm -f /sbin/shorewall2
rm -f /sbin/shorewall2-*.bkout
if [ -n "$VERSION" ]; then
restore_file /etc/rc.d/rc.local
fi
rm -rf /etc/shorewall2
rm -rf /var/lib/shorewall2
rm -rf /usr/share/shorewall2
rm -rf /etc/shorewall
rm -rf /usr/lib/shorewall
rm -rf /var/lib/shorewall
rm -rf /usr/share/shorewall
echo "Shorewall Uninstalled"
echo "Shorewall2 Uninstalled"