![]() ![]() |
hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
#!/usr/bin/env shif ! [ -e settings ]; then OUTFILE="settings"; else OUTFILE="settings.new"; fi## configure path to "iptables"#COMMAND=`locate iptables|grep bin/iptables\$|head -n 1`if [ "$COMMAND" = "" ]; then COMMAND=`locate ipchains|grep bin/ipchains\$|head -n 1`; ficat > $OUTFILE <<EOF# path to iptables or ipchains command#EOFecho "IPTABLES=\"$COMMAND\"" >> $OUTFILEecho >> $OUTFILEcat >> $OUTFILE << EOF# Which kind of legend shall be used# set STYLE="bytes" to display all values in bytes/s# set STYLE="bits" to display all values in bits/s#EOFvar=`cat settings|grep "^STYLE="`if [ "$var" = "" ]; then var="STYLE=\"bytes\""; fiecho "$var" >> $OUTFILE## configure interfaces#INTERFACES=`netstat -i|grep [0-9] |awk '{print $1}'`if [ "$OUTFILE" = "settings.new" ]; thenINTIF=`cat settings | grep "^INTIF=" | sed -e "s/INTIF=//g ; s/\"//g"`EXTIF=`cat settings | grep "^EXTIF=" | sed -e "s/EXTIF=//g ; s/\"//g"`elseINTIF=""EXTIF=""fiif [ "$INTIF" = "" ] || [ "$EXTIF" = "" ]; thenechoecho "Configuring local interfaces.(i)nternal means an interface pointiong to your local machines (intranet)(e)xternal means an interface connecten with the internet(n)one means you don't want to account this interface.Please answer these:"for nn in $INTERFACES; dowhere="x"while [ "$where" != "i" ] && [ "$where" != "e" ] && [ "$where" != "n" ]; doecho -n "found: $nn - (i)nternal, (e)xternal or (n)one ? "read wherecase $where inn) ;;i) INTIF="$INTIF,$nn" ;;e) EXTIF="$EXTIF,$nn" ;;*) echo "please answer with \"i\" \"e\" or \"n\"" ;;esacechodonedoneficat >> $OUTFILE << EOF# list of interfaces for internal / external hosts# INTIF=<interfaces connected to your local network (intranet)># EXTIF=<interfaces connected to the internet>#EOFecho "INTIF=\"$INTIF\"" |sed -e "s/=\",/=\"/g" >> $OUTFILEecho "EXTIF=\"$EXTIF\"" |sed -e "s/=\",/=\"/g" >> $OUTFILEecho >> $OUTFILE## write template for the rest#echo "# list hosts on internal devices here, multiple lines of the form:" >> $OUTFILEecho "# DEVINT=\"<host>,<description>\"" >> $OUTFILEecho "# DEVINT=\"!<host>,<description>\"" >> $OUTFILEecho "#" >> $OUTFILEif [ "$OUTFILE" = "settings.new" ]; thencat settings|grep "^DEVINT=" >> $OUTFILEfiecho >> $OUTFILEecho "# list hosts on external devices here, multiple lines of the form:" >> $OUTFILEecho "# DEVEXT=\"<host>,<description>\"" >> $OUTFILEecho "# DEVEXT=\"!<host>,<description>\"" >> $OUTFILEecho "#" >> $OUTFILEif [ "$OUTFILE" = "settings.new" ]; thencat settings|grep "^DEVEXT=" >> $OUTFILEfiechoecho "Please check the settings file and adapt it to satisfy your needs."echo "maybe you have to configure some destination networks."if [ "$OUTFILE" = "settings.new" ]; thenmkdir -p backupNOW=`date +%Y%m%d-%H%M%S`mv -f settings backup/settings-$NOWmv -f settings.new settingsecho "a backup of the previous settings has been saved."fiecho