From 9784e024e7619991713c63383b68692330cf298b Mon Sep 17 00:00:00 2001 From: bbruns Date: Thu, 18 Nov 2010 19:23:49 +0000 Subject: [PATCH] Begin work on config tool --- tools/configure-firewall | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/tools/configure-firewall b/tools/configure-firewall index e23e86c..8530119 100755 --- a/tools/configure-firewall +++ b/tools/configure-firewall @@ -22,21 +22,47 @@ CONFIGTOOL_VER="0.1" WHIPTAIL="/usr/bin/whiptail" TMPCONFIG=`mktemp` +WHICH="/usr/bin/which" +AUTOCONFIG_BIN="iptables:IPTABLES ip6tables:IP6TABLES modprobe:MODPROBE" # These are string variables WELCOME_HEAD="Welcome to the Firewall/SOSDG Config Tool v${CONFIGTOOL_VER}" -WELCOME_BODY="This tool is a quick way to do a basic setup of the firewall script. - The results of this tool will be output to a file of your choosing at - the end of configuration.\nContinue?" +WELCOME_BODY="This tool is a quick way to do a basic setup of the firewall script.\nThe results of this tool will be output to a file of your choosing at the end of configuration.\nContinue?" +AUTOCONFIG_PATHS="Would you like to try to configure paths of important programs automatically?" + if [ ! -x $WHIPTAIL ]; then echo "Error: please make sure you have whiptail installed, and the WHIPTAIL variable is set correctly in the tool." + rm -f "$TMPCONFIG" exit 1 fi -if ! ( $WHIPTAIL --yesno "${WELCOME_MSG}\n${WELCOME_BODY}" 12 60 --no-button "Quit" ); then +if ! ( $WHIPTAIL --yesno "${WELCOME_HEAD}\n${WELCOME_BODY}" 12 70 --no-button "Quit" ); then echo "Quitting config tool." + rm -f "$TMPCONFIG" exit 1 -fi \ No newline at end of file +fi + +if [ -w $TMPCONFIG ]; then + echo "# Automatically generated config file, please check before actually using." >"${TMPCONFIG}" +else + echo "Error: could not write tmp file for config generation!" + exit 1 +fi + +if ( $WHIPTAIL --yesno "${AUTOCONFIG_PATHS}" 5 40 ); then + for i in $AUTOCONFIG_BIN; do + IFS_OLD=${IFS};IFS=: + BIN_PATH=($i) + IFS=${IFS_OLD} + if ( $WHICH $BIN_PATH[0] ); then + BIN_FULL="`${WHICH} ${BIN_PATH[0]}`" + echo "${BIN_PATH[1]}="${BIN_PATH[0]}" >>${TMPCONFIG} + fi + done +# +#else +fi +