Extended MOTD with GUI
[tomato.git] / release / src / router / others / mymotd
blob023d2901df5c9c238e9eba536429ef461455fab6
1 #!/bin/sh
3 MOTD_ON=`nvram get sshd_motd`
5 #only if enable
6 if [ "$MOTD_ON" == "1" ]; then
9 # Function calculates number of bit in a netmask
11 mask2cidr() {
12 nbits=0
13 IFS=.
14 for dec in $1 ; do
15 case $dec in
16 255) let nbits+=8;;
17 254) let nbits+=7;;
18 252) let nbits+=6;;
19 248) let nbits+=5;;
20 240) let nbits+=4;;
21 224) let nbits+=3;;
22 192) let nbits+=2;;
23 128) let nbits+=1;;
24 0);;
25 *) echo "Error: $dec is not recognised"; exit 1
26 esac
27 done
28 echo "$nbits"
31 LAN1=`nvram get lan1_ipaddr | wc -w`
32 LAN2=`nvram get lan2_ipaddr | wc -w`
33 LAN3=`nvram get lan3_ipaddr | wc -w`
34 DUAL=`nvram get landevs | grep wl1 | wc -l`
36 WAN_MASK=`nvram get wan_netmask`
37 WAN_NUMBITS=$(mask2cidr $WAN_MASK)
39 LAN_MASK=`nvram get lan_netmask`
40 LAN_NUMBITS=$(mask2cidr $LAN_MASK)
42 echo -e "\033[1;34m ======================================================== \033[0m"
43 echo -e "\033[1;32m Welcome to the `nvram get t_model_name` [`nvram get router_name`]\033[0m"
44 echo -e "\033[1;31m Uptime: `uptime | sed -e 's/, load/\n Load/'`\033[0m"
45 echo " WAN : `nvram get wan_ipaddr`/$WAN_NUMBITS @ `nvram get wan_hwaddr`"
46 echo " LAN : `nvram get lan_ipaddr`/$LAN_NUMBITS @ DHCP: `nvram get dhcpd_startip` - `nvram get dhcpd_endip`"
47 if [ "$LAN1" == "1" ]; then
48 LAN1_MASK=`nvram get lan1_netmask`
49 LAN1_NUMBITS=$(mask2cidr $LAN1_MASK)
50 echo " LAN1: `nvram get lan1_ipaddr`/$LAN1_NUMBITS @ DHCP: `nvram get dhcpd1_startip` - `nvram get dhcpd1_endip`";
52 if [ "$LAN2" == "1" ]; then
53 LAN2_MASK=`nvram get lan2_netmask`
54 LAN2_NUMBITS=$(mask2cidr $LAN2_MASK)
55 echo " LAN2: `nvram get lan2_ipaddr`/$LAN2_NUMBITS @ DHCP: `nvram get dhcpd2_startip` - `nvram get dhcpd2_endip`";
57 if [ "$LAN3" == "1" ]; then
58 LAN3_MASK=`nvram get lan3_netmask`
59 LAN3_NUMBITS=$(mask2cidr $LAN3_MASK)
60 echo " LAN3: `nvram get lan3_ipaddr`/$LAN3_NUMBITS @ DHCP: `nvram get dhcpd3_startip` - `nvram get dhcpd3_endip`";
62 echo " WL0 : `nvram get wl0_ssid` @ ch: `nvram get wl0_channel` @ `nvram get wl0_hwaddr`"
63 if [ "$DUAL" == "1" ]; then echo " WL1 : `nvram get wl1_ssid` @ ch: `nvram get wl1_channel` @ `nvram get wl1_hwaddr`"; fi
64 echo -e "\033[1;34m ======================================================== \033[0m"
66 echo ""