Accomodate bash clones like dash and ash -- install script

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@326 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2002-11-10 23:25:19 +00:00
parent b8f806e625
commit 530b4ba457

View File

@ -68,14 +68,16 @@ usage() # $1 = exit status
run_install() run_install()
{ {
if ! install $*; then if ! install $*; then
echo -e "\nERROR: Failed to install $*" echo
echo "ERROR: Failed to install $*"
exit 1 exit 1
fi fi
} }
cant_autostart() cant_autostart()
{ {
echo -e "\nWARNING: Unable to configure Shorewall to start" echo
echo "WARNING: Unable to configure Shorewall to start"
echo " automatically at boot" echo " automatically at boot"
} }
@ -224,7 +226,8 @@ fi
install_file_with_backup shorewall ${PREFIX}/sbin/shorewall 0544 install_file_with_backup shorewall ${PREFIX}/sbin/shorewall 0544
echo -e "\nShorewall control program installed in ${PREFIX}/sbin/shorewall" echo
echo "Shorewall control program installed in ${PREFIX}/sbin/shorewall"
# #
# Install the Firewall Script # Install the Firewall Script
@ -240,7 +243,8 @@ if [ -n "$RUNLEVELS" ]; then
awk -f awk.temp init.sh > init.temp awk -f awk.temp init.sh > init.temp
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo -e "\nERROR: Error running awk." echo
echo "ERROR: Error running awk."
echo " You must run `basename $0` without the "-r" option then edit" echo " You must run `basename $0` without the "-r" option then edit"
echo " $DEST/$FIREWALL manually (line beginning '# chkconfig:')" echo " $DEST/$FIREWALL manually (line beginning '# chkconfig:')"
exit 1 exit 1
@ -253,7 +257,8 @@ else
install_file_with_backup init.sh ${PREFIX}${DEST}/$FIREWALL 0544 install_file_with_backup init.sh ${PREFIX}${DEST}/$FIREWALL 0544
fi fi
echo -e "\nShorewall script installed in ${PREFIX}${DEST}/$FIREWALL" echo
echo "Shorewall script installed in ${PREFIX}${DEST}/$FIREWALL"
# #
# Create /etc/shorewall, /usr/lib/shorewall and /var/shorewall if needed # Create /etc/shorewall, /usr/lib/shorewall and /var/shorewall if needed
@ -268,7 +273,8 @@ if [ -f ${PREFIX}/etc/shorewall/shorewall.conf ]; then
backup_file /etc/shorewall/shorewall.conf backup_file /etc/shorewall/shorewall.conf
else 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/shorewall/shorewall.conf
echo -e "\nConfig file installed as ${PREFIX}/etc/shorewall/shorewall.conf" echo
echo "Config file installed as ${PREFIX}/etc/shorewall/shorewall.conf"
fi fi
# #
# Install the zones file # Install the zones file
@ -277,7 +283,8 @@ if [ -f ${PREFIX}/etc/shorewall/zones ]; then
backup_file /etc/shorewall/zones backup_file /etc/shorewall/zones
else 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/shorewall/zones
echo -e "\nZones file installed as ${PREFIX}/etc/shorewall/zones" echo
echo "Zones file installed as ${PREFIX}/etc/shorewall/zones"
fi fi
# #
@ -295,19 +302,22 @@ fi
install_file_with_backup functions ${PREFIX}/usr/lib/shorewall/functions 0444 install_file_with_backup functions ${PREFIX}/usr/lib/shorewall/functions 0444
echo -e "\nCommon functions installed in ${PREFIX}/usr/lib/shorewall/functions" echo
echo "Common functions installed in ${PREFIX}/usr/lib/shorewall/functions"
# #
# Install the common.def file # 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/shorewall/common.def 0444
echo -e "\nCommon rules installed in ${PREFIX}/etc/shorewall/common.def" echo
echo "Common rules installed in ${PREFIX}/etc/shorewall/common.def"
# #
# Install the icmp.def file # Install the icmp.def file
# #
install_file_with_backup icmp.def ${PREFIX}/etc/shorewall/icmp.def 0444 install_file_with_backup icmp.def ${PREFIX}/etc/shorewall/icmp.def 0444
echo -e "\nCommon ICMP rules installed in ${PREFIX}/etc/shorewall/icmp.def" echo
echo "Common ICMP rules installed in ${PREFIX}/etc/shorewall/icmp.def"
# #
# Install the policy file # Install the policy file
@ -316,7 +326,8 @@ if [ -f ${PREFIX}/etc/shorewall/policy ]; then
backup_file /etc/shorewall/policy backup_file /etc/shorewall/policy
else 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/shorewall/policy
echo -e "\nPolicy file installed as ${PREFIX}/etc/shorewall/policy" echo
echo "Policy file installed as ${PREFIX}/etc/shorewall/policy"
fi fi
# #
# Install the interfaces file # Install the interfaces file
@ -325,7 +336,8 @@ if [ -f ${PREFIX}/etc/shorewall/interfaces ]; then
backup_file /etc/shorewall/interfaces backup_file /etc/shorewall/interfaces
else 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/shorewall/interfaces
echo -e "\nInterfaces file installed as ${PREFIX}/etc/shorewall/interfaces" echo
echo "Interfaces file installed as ${PREFIX}/etc/shorewall/interfaces"
fi fi
# #
# Install the hosts file # Install the hosts file
@ -334,7 +346,8 @@ if [ -f ${PREFIX}/etc/shorewall/hosts ]; then
backup_file /etc/shorewall/hosts backup_file /etc/shorewall/hosts
else 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/shorewall/hosts
echo -e "\nHosts file installed as ${PREFIX}/etc/shorewall/hosts" echo
echo "Hosts file installed as ${PREFIX}/etc/shorewall/hosts"
fi fi
# #
# Install the rules file # Install the rules file
@ -343,7 +356,8 @@ if [ -f ${PREFIX}/etc/shorewall/rules ]; then
backup_file /etc/shorewall/rules backup_file /etc/shorewall/rules
else 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/shorewall/rules
echo -e "\nRules file installed as ${PREFIX}/etc/shorewall/rules" echo
echo "Rules file installed as ${PREFIX}/etc/shorewall/rules"
fi fi
# #
# Install the NAT file # Install the NAT file
@ -352,7 +366,8 @@ if [ -f ${PREFIX}/etc/shorewall/nat ]; then
backup_file /etc/shorewall/nat backup_file /etc/shorewall/nat
else 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/shorewall/nat
echo -e "\nNAT file installed as ${PREFIX}/etc/shorewall/nat" echo
echo "NAT file installed as ${PREFIX}/etc/shorewall/nat"
fi fi
# #
# Install the Parameters file # Install the Parameters file
@ -361,7 +376,8 @@ if [ -f ${PREFIX}/etc/shorewall/params ]; then
backup_file /etc/shorewall/params backup_file /etc/shorewall/params
else 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/shorewall/params
echo -e "\nParameter file installed as ${PREFIX}/etc/shorewall/params" echo
echo "Parameter file installed as ${PREFIX}/etc/shorewall/params"
fi fi
# #
# Install the proxy ARP file # Install the proxy ARP file
@ -370,7 +386,8 @@ if [ -f ${PREFIX}/etc/shorewall/proxyarp ]; then
backup_file /etc/shorewall/proxyarp backup_file /etc/shorewall/proxyarp
else 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/shorewall/proxyarp
echo -e "\nProxy ARP file installed as ${PREFIX}/etc/shorewall/proxyarp" echo
echo "Proxy ARP file installed as ${PREFIX}/etc/shorewall/proxyarp"
fi fi
# #
# Install the Stopped Routing file # Install the Stopped Routing file
@ -379,7 +396,8 @@ if [ -f ${PREFIX}/etc/shorewall/routestopped ]; then
backup_file /etc/shorewall/routestopped backup_file /etc/shorewall/routestopped
else 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/shorewall/routestopped
echo -e "\nStopped Routing file installed as ${PREFIX}/etc/shorewall/routestopped" echo
echo "Stopped Routing file installed as ${PREFIX}/etc/shorewall/routestopped"
fi fi
# #
# Install the Mac List file # Install the Mac List file
@ -388,7 +406,8 @@ if [ -f ${PREFIX}/etc/shorewall/maclist ]; then
backup_file /etc/shorewall/maclist backup_file /etc/shorewall/maclist
else 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/shorewall/maclist
echo -e "\nMAC list file installed as ${PREFIX}/etc/shorewall/maclist" echo
echo "MAC list file installed as ${PREFIX}/etc/shorewall/maclist"
fi fi
# #
# Install the Masq file # Install the Masq file
@ -397,7 +416,8 @@ if [ -f ${PREFIX}/etc/shorewall/masq ]; then
backup_file /etc/shorewall/masq backup_file /etc/shorewall/masq
else 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/shorewall/masq
echo -e "\nMasquerade file installed as ${PREFIX}/etc/shorewall/masq" echo
echo "Masquerade file installed as ${PREFIX}/etc/shorewall/masq"
fi fi
# #
# Install the Modules file # Install the Modules file
@ -406,7 +426,8 @@ if [ -f ${PREFIX}/etc/shorewall/modules ]; then
backup_file /etc/shorewall/modules backup_file /etc/shorewall/modules
else 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/shorewall/modules
echo -e "\nModules file installed as ${PREFIX}/etc/shorewall/modules" echo
echo "Modules file installed as ${PREFIX}/etc/shorewall/modules"
fi fi
# #
# Install the TC Rules file # Install the TC Rules file
@ -415,7 +436,8 @@ if [ -f ${PREFIX}/etc/shorewall/tcrules ]; then
backup_file /etc/shorewall/tcrules backup_file /etc/shorewall/tcrules
else 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/shorewall/tcrules
echo -e "\nTC Rules file installed as ${PREFIX}/etc/shorewall/tcrules" echo
echo "TC Rules file installed as ${PREFIX}/etc/shorewall/tcrules"
fi fi
# #
@ -425,7 +447,8 @@ if [ -f ${PREFIX}/etc/shorewall/tos ]; then
backup_file /etc/shorewall/tos backup_file /etc/shorewall/tos
else 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/shorewall/tos
echo -e "\nTOS file installed as ${PREFIX}/etc/shorewall/tos" echo
echo "TOS file installed as ${PREFIX}/etc/shorewall/tos"
fi fi
# #
# Install the Tunnels file # Install the Tunnels file
@ -434,7 +457,8 @@ if [ -f ${PREFIX}/etc/shorewall/tunnels ]; then
backup_file /etc/shorewall/tunnels backup_file /etc/shorewall/tunnels
else 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/shorewall/tunnels
echo -e "\nTunnels file installed as ${PREFIX}/etc/shorewall/tunnels" echo
echo "Tunnels file installed as ${PREFIX}/etc/shorewall/tunnels"
fi fi
# #
# Install the blacklist file # Install the blacklist file
@ -443,7 +467,8 @@ if [ -f ${PREFIX}/etc/shorewall/blacklist ]; then
backup_file /etc/shorewall/blacklist backup_file /etc/shorewall/blacklist
else 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/shorewall/blacklist
echo -e "\nBlacklist file installed as ${PREFIX}/etc/shorewall/blacklist" echo
echo "Blacklist file installed as ${PREFIX}/etc/shorewall/blacklist"
fi fi
# #
# Backup and remove the whitelist file # Backup and remove the whitelist file
@ -459,7 +484,8 @@ if [ -f ${PREFIX}/etc/shorewall/rfc1918 ]; then
backup_file /etc/shorewall/rfc1918 backup_file /etc/shorewall/rfc1918
else 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/shorewall/rfc1918
echo -e "\nRFC 1918 file installed as ${PREFIX}/etc/shorewall/rfc1918" echo
echo "RFC 1918 file installed as ${PREFIX}/etc/shorewall/rfc1918"
fi fi
# #
# Backup the version file # Backup the version file
@ -498,20 +524,23 @@ install_file_with_backup firewall ${PREFIX}/usr/lib/shorewall/firewall 0544
if [ -z "$PREFIX" -a -n "$first_install" ]; then if [ -z "$PREFIX" -a -n "$first_install" ]; then
if [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then if [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
if insserv /etc/init.d/shorewall ; then if insserv /etc/init.d/shorewall ; then
echo -e "\nFirewall will start automatically at boot" echo
echo "Firewall will start automatically at boot"
else else
cant_autostart cant_autostart
fi fi
elif [ -x /sbin/chkconfig -o -x /usr/sbin/chkconfig ]; then elif [ -x /sbin/chkconfig -o -x /usr/sbin/chkconfig ]; then
if chkconfig --add $FIREWALL ; then if chkconfig --add $FIREWALL ; then
echo -e "\nFirewall will start automatically in run levels as follows:" echo
echo "Firewall will start automatically in run levels as follows:"
chkconfig --list $FIREWALL chkconfig --list $FIREWALL
else else
cant_autostart cant_autostart
fi fi
elif [ -x /sbin/rc-update ]; then elif [ -x /sbin/rc-update ]; then
if rc-update add shorewall default; then if rc-update add shorewall default; then
echo -e "\nFirewall will start automatically at boot" echo
echo "Firewall will start automatically at boot"
else else
cant_autostart cant_autostart
fi fi
@ -528,4 +557,5 @@ fi
# #
# Report Success # Report Success
# #
echo -e "\nShorewall Version $VERSION Installed" echo
echo "Shorewall Version $VERSION Installed"