#!/bin/ash # Check if an argument is passed if [ "$#" -ne 1 ]; then echo "Usage: $0 ip" exit 1 fi ip=$1 # Check if IP is in the range [1..254] and not 2, 99, 88, 98 if ! echo $ip | grep -qE '^(25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$' || [ "$ip" = "2" ] || [ "$ip" = "99" ] || [ "$ip" = "88" ] || [ "$ip" = "98" ]; then echo "Invalid IP: $ip. IP should be in the range [1..254] and not 2, 99, 88, 98." exit 1 fi cat << EOF > /etc/network/interfaces iface lo inet loopback auto eth0 iface eth0 inet static address 158.132.58.$ip/24 gateway 158.132.58.2 EOF rc-service networking restart sleep 3 rc-service sockd restart curl -o /dev/null -s -w "%{http_code}\n" google.com