#!/bin/vbash if [ "$(id -g -n)" != 'vyattacfg' ] ; then exec sg vyattacfg -c "/bin/vbash $(readlink -f $0) $@" fi read -p "How many lines do you want to add to the config? \nEnter a number between 10 and 20000: " input_number if [[ "$input_number" -ge 10 && "$input_number" -le 20000 ]]; then echo "Valid input: $input_number" else echo "Invalid input. Please enter a number between 10 and 20000." exit 1 fi input_number=$(( (input_number + 2) / 3 )) echo "Adding firewall rules from: 2 to $input_number" source /opt/vyatta/etc/functions/script-template configure echo " Starting with set commands at " date for ((i=2; i<=input_number; i++)); do set firewall ipv4 name client_to_dmz rule $i action accept set firewall ipv4 name client_to_dmz rule $i protocol tcp set firewall ipv4 name client_to_dmz rule $i destination port $((i + 80)) done while true; do read -p "Do you want to commit the changes? (yes/no): " commit_choice if [[ "$commit_choice" == "yes" || "$commit_choice" == "no" ]]; then break else echo "Invalid input. Please enter 'yes' or 'no'." fi done if [[ "$commit_choice" == "yes" ]]; then echo "Starting commit at" date commit echo "Commit completed at" date save else echo "Changes not committed." fi exit