home *** CD-ROM | disk | FTP | other *** search
/ chilidog.highland.cc.ks.us / chilidog.highland.cc.ks.us.zip / chilidog.highland.cc.ks.us / backup / bradford.20110725.etc.tar.gz / bradford.20110725.etc.tar / etc / sysconfig / scripts / SuSEfirewall2-batch < prev    next >
Text File  |  2006-04-22  |  3KB  |  86 lines

  1. #!/bin/bash
  2. # SuSEfirewall2-batch - batchmode support functions
  3. # Copyright (C) 2004 SUSE LINUX Products GmbH
  4. #
  5. # Author:     Ludwig Nussel
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License
  8. # version 2 as published by the Free Software Foundation.
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. # GNU General Public License for more details.
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software
  15. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  16.  
  17. check_iptables_batch()
  18. {
  19.     if [ -n "$USE_IPTABLES_BATCH" ]; then
  20.         IPTABLES_BATCH=/usr/sbin/iptables-batch
  21.         IP6TABLES_BATCH=/usr/sbin/ip6tables-batch
  22.         if [ ! -x "$IPTABLES_BATCH" ]; then
  23.             [ "$USE_IPTABLES_BATCH" != 'auto' ] && echo "iptables-batch missing, batch support disabled."
  24.             USE_IPTABLES_BATCH=""
  25.         elif [ ! -x "$IP6TABLES_BATCH" ]; then
  26.             [ "$USE_IPTABLES_BATCH" != 'auto' ] && echo "ip6tables-batch missing, batch support disabled."
  27.             USE_IPTABLES_BATCH=""
  28.         fi
  29.     fi
  30.  
  31.     # override iptables calls with shell function if in batch mode
  32.     if [ -n "$USE_IPTABLES_BATCH" ]; then
  33.         iptables_batchfile=`mktemp -t SuSEfirewall2_iptables.XXXXXXXX` || exit 1
  34.         removeonexit "$iptables_batchfile"
  35.         exec 4> "$iptables_batchfile"
  36.         echo "#!$IPTABLES_BATCH" >&4
  37.         iptables()
  38.         {
  39.             local i
  40.             echo -n "iptables" >&4
  41.             for i in "$@"; do echo -n " \"$i\""; done >&4
  42.             echo >&4
  43.         }
  44.         ip6tables_batchfile=`mktemp -t SuSEfirewall2_ip6tables.XXXXXXXX` || exit 1
  45.         removeonexit "$ip6tables_batchfile"
  46.         exec 6> "$ip6tables_batchfile"
  47.         echo "#!$IP6TABLES_BATCH" >&6
  48.         ip6tables()
  49.         {
  50.             local i
  51.             echo -n "ip6tables" >&6
  52.             for i in "$@"; do echo -n " \"$i\""; done >&6
  53.             echo >&6
  54.         }
  55.     fi
  56. }
  57.  
  58. iptables_batch_commitpoint()
  59. {
  60.     echo commit >&6
  61. }
  62.  
  63. commit_iptables_batch()
  64. {
  65.     if [ -n "$USE_IPTABLES_BATCH" ]; then
  66.     message "batch committing..."
  67.     if ! $IPTABLES_BATCH "$iptables_batchfile"; then
  68.         error "iptables-batch failed, re-running using iptables"
  69.         iptables() { $IPTABLES_BIN "$@"; }
  70.         commit() { :; }
  71.         . $iptables_batchfile
  72.     fi
  73.     if ! $IP6TABLES_BATCH "$ip6tables_batchfile"; then
  74.         error "ip6tables-batch failed, re-running using ip6tables"
  75.         ip6tables() { $IP6TABLES_BIN "$@"; }
  76.         commit() { :; }
  77.         . $ip6tables_batchfile
  78.     fi
  79.     fi
  80. }
  81.  
  82. # vim: sw=4
  83.