#! /bin/sh
basename=$(basename "$0")

# STYLES GO HERE
reset=""
bold=""
blink=""
bel=""
underline=""

# FUNCTION FOR SIMPLICITY
newcmd()
{
       echo Please use "$bold""$*""$reset" instead.
       env "$@"
#       exit
}

if [ "$basename" = "net-tools-deprecated" ]; then
 echo net-tools-deprecated: Script to annoy people using deprecated networking commands on OpenSuSE
 echo arp, ifconfig, iptunnel, netstat, and route are the main offenders...
 echo this script will execute the modern commands if they are simple enough
 echo bonus: OpenSUSE 15 does not have whois, so this script also does that "(via netcat)."
 echo installs in /usr/local/bin in a fashion similar to busybox
 echo simply symlink any old commands towards this script
 echo e.g.: "$bold"ln -s /usr/local/bin/net-tools-deprecated /usr/local/bin/arp"$reset"
 exit
fi

echo "$bel$reset$blink"net-tools-deprecated: You have used a deprecated command: "$basename $*""$reset".

case "$basename $*" in
       "arp "|"arp -a"|"arp --all"|"arp -n"|"arp --numeric")
       newcmd ip n
       ;;

       "arp -d "*|"arp --delete "*)
       echo New command syntax:
       echo "$bold"ip n del «ip_addr» "$reset"to invalidate
       echo "$bold"ip n f «ip_address» "$reset"to flush
       ;;

       "arp -i "*|"arp --device "*)
       echo New command syntax: "$bold"ip n show dev «int»"$reset"
       ip n show dev "$2"
       ;;

       "arp -s "*|"arp --set "*)
       echo New command syntax:
       echo "$bold"ip n add «ip_addr» lladdr «mac_address» dev «device» nud «nud_state»"$reset"
       ;;

       "arp -v")
       newcmd ip -s n
       ;;

       arp*)
       echo Most arp commands have been replaced by "$bold"ip"$reset" commands
       echo Please see: "$underline"http://bit.ly/2hjQRoE"$reset"
       exit
       ;;

       "ifconfig ")
       newcmd ip a
       ;;

       ifconfig*)
       echo Most ifconfig commands have been replaced by "$bold"ip"$reset" commands.
       echo Please see: "$underline"http://bit.ly/2iE6m7K"$reset"
       ;;

       iptunnel*)
       echo Please use "$bold"ip tunnel"$reset" instead.
       echo The syntax is very similar, examples are at: "$underline"http://bit.ly/2hPY2Cc"$reset"
       ;;

       "netstat "|"netstat -N"|"netstat --symbolic")
       newcmd ss -r
       ;;

       "netstat -a"|"netstat --all")
       nwcmd ss -a
       ;;

       "netstat -C")
       newcmd ip route list cache
       ;;

       "netstat -e"|"netstat --extend")
       newcmd ss -e
       ;;

       "netstat -r")
       necmd ip route
       ;;

       "netstat -i")
       newcmd ip -s link
       ;;

       "netstat -g")
       newcmd ip maddr
       ;;

       "netstat -n"|"netstat --numeric")
       newcmd ss -n
       ;;

       "netstat -s"|"netstat --statistics")
       newcmd ss -s
       ;;

       "netstat -t"|"netstat --tcp")
       newcmd ss -t
       ;;

       "netstat -u"|"netstat --udp")
       newcmd ss -u
       ;;

       "netstat -w"|"netstat --raw")
       newcmd ss -w
       ;;

       netstat*)
       echo Most netstat commands have been replaced by "$bold"ss"$reset" commands
       echo Please see: "$underline"http://bit.ly/2hRUAa0"$reset"
       ;;

       "route ")
       newcmd ip r
       ;;

       "route -e"|"route -ee")
       newcmd ip r show
       ;;

       "route -h"|"route --help")
       newcmd ip route help
       ;;

       "route -v"|"route --verbose")
       newcmd ip -s route
       ;;

       "route -V"|"route --version")
       newcmd ip -V
       ;;

       route*)
       echo Most route commands have been replaced by "$bold"ip"$reset" commands.
       echo Please see: "$underline"http://bit.ly/2AmdM6F"$reset"
       ;;

       "whois "|"whois -h"*)
       echo OpenSUSE 15 does not including a whois client...
       echo Try something like "$bold"echo «query» "|" nc -v «whois_server» 43"$reset"
       ;;

       whois*)
       echo OpenSUSE 15 does not including a whois client...
       echo Try something like "$bold"echo «query» "|" nc -v «whois_server» 43"$reset"
       echo "$1" | nc -v whois.geektools.com 43 | less
       ;;


       *)
       echo EXCEPTION: UNKNOWN COMMAND
       ;;

esac