#!/bin/sh # # Module: vyatta-clear-conntrack # # **** License **** # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # 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. # # This code was originally developed by Vyatta, Inc. # Portions created by Vyatta are Copyright (C) 2006-2009 Vyatta, Inc. # All Rights Reserved. # # Author: Mohit Mehta # Date: February 2010 # Description: Script to flush all conntrack entries # # **** End License **** # # picked up from install-system script get_response () { ldefault=$(echo "$1" | tr [:upper:] [:lower:]) loptions=$(echo "$2" | tr [:upper:] [:lower:]) # get the response from the user read myresponse myresponse=$(echo "$myresponse" | tr [:upper:] [:lower:]) # Check to see if the user accepts the default if [ -z "$myresponse" ]; then echo -n $ldefault # if we are passing in options to check, make sure response is a valid option elif [ -n "$loptions" ]; then for token in $loptions do if [ "$token" == "$myresponse" ]; then echo -n "$myresponse" return 0 fi done return 1 else echo -n "$myresponse" fi return 0 } response='' while [ -z "$response" ] do if [ "$VYATTA_PROCESS_CLIENT" == "gui2_rest" ]; then response="y" else echo -ne "\nThis will clear all currently tracked and expected connections. Continue? (Y/N) [N]: " response=$(get_response "N" "Y N") fi if [ "$response" == "n" ]; then exit 1 else sudo /usr/sbin/conntrack -F >&/dev/null sudo /usr/sbin/conntrack -F expect >&/dev/null fi done