FLASH_MANAGER="/usr/bin/flash-manager"
MOUNT="/usr/bin/mount"
UMOUNT="/usr/bin/umount"
-IFCONFIG="/usr/sbin/ifconfig"
REBOOT="/usr/sbin/reboot"
+IP="/usr/sbin/ip"
+IFCONFIG="/usr/sbin/ifconfig"
+GREP="/usr/bin/grep"
+
+NETIF="eth0"
#------------------------------------------------
# clear_bootmode
}
#------------------------------------------------
-# setup_network
+# print_ip
#------------------------------------------------
-setup_network() {
- "$IFCONFIG" eth0 192.168.0.1 up
- echo "IP address is set to 192.168.0.1"
+print_ip() {
+ IPADDR=`"$IP" -4 addr show $NETIF | "$GREP" -oP '(?<=inet\s)\d+(\.\d+){3}'`
+ if [ "z$IPADDR" == "z" ]; then
+ echo "IP address is not set, using default (192.168.0.100)"
+ IPADDR="192.168.0.100"
+
+ "$IFCONFIG" $NETIF $IPADDR up
+ fi
+ echo "IP address is set to ${IPADDR}"
}
#------------------------------------------------
# Main Routine Start
#------------------------------------------------
clear_bootmode
-setup_network
+print_ip
do_flash