#!/bin/sh # # $Id: install_shoregen,v 1.5 2004/04/22 11:12:51 paulgear Exp $ # # Wrapper script to install shoregen-generated shorewall configuration files. # # # (c) Copyright 2004 Paul D. Gear # # 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. # # 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 Foundation, Inc., # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to # on the World Wide Web. VERBOSE=0 RESTART=0 CHECK=1 TIME=1 usage() { echo "Usage: $0 [--verbose] [--restart] host ... Generates and installs shorewall configuration on the given hosts" >&2 exit 1 } error() { echo "$0: ERROR -" "$@" >&2 } while :; do case "$1" in -v|--verbose) VERBOSE=1 shift ;; -r|--restart) RESTART=1 shift ;; -c|--nocheck) CHECK=0 shift ;; -t|--notime) TIME=0 shift ;; --) shift break 2 ;; --*) error "Unrecognised option $1" usage ;; *) break 2 ;; esac done set -e set -u if [ "$#" -lt 1 ]; then usage fi USER=root RSYNC_ARGS="--recursive --backup --times --cvs-exclude --rsh=ssh" #--progress if [ "$VERBOSE" -gt 0 ]; then RSYNC_ARGS="$RSYNC_ARGS --verbose" fi DIR=/etc/shorewall SW_PATH=/sbin/shorewall PATH=$PATH: if [ "$TIME" -gt 0 ]; then TIME="time" else TIME="" fi for HOST; do shoregen $HOST rsync $RSYNC_ARGS SPOOL/$HOST/ $USER@$HOST:$DIR/ if [ "$CHECK" -gt 0 ]; then $TIME ssh -l $USER -t $HOST $SW_PATH check fi if [ "$RESTART" -gt 0 ]; then $TIME ssh -l $USER -t $HOST $SW_PATH restart fi done