2023-02-08 21:01:48 +00:00
|
|
|
#!/bin/bash
|
2018-03-10 23:40:07 +00:00
|
|
|
|
2022-04-29 14:26:02 +00:00
|
|
|
. /etc/functions
|
|
|
|
|
2024-02-01 19:30:31 +00:00
|
|
|
TRACE_FUNC
|
2023-02-18 17:58:43 +00:00
|
|
|
|
2018-03-10 23:40:07 +00:00
|
|
|
# bring up the ethernet; maybe should do DHCP?
|
|
|
|
ifconfig lo 127.0.0.1
|
|
|
|
|
2018-03-14 00:55:34 +00:00
|
|
|
network_modules="e1000 e1000e igb sfc mdio mlx4_core mlx4_en"
|
|
|
|
for module in `echo $network_modules`; do
|
|
|
|
if [ -f /lib/modules/$module.ko ]; then
|
|
|
|
insmod /lib/modules/$module.ko
|
|
|
|
fi
|
|
|
|
done
|
2018-03-10 23:40:07 +00:00
|
|
|
|
|
|
|
if [ -e /sys/class/net/eth0 ]; then
|
2022-04-29 14:26:02 +00:00
|
|
|
#Randomize eth0 MAC address of maximized boards
|
|
|
|
if echo "$CONFIG_BOARD" | grep -q maximized; then
|
|
|
|
ifconfig eth0 down
|
|
|
|
echo "Generating random MAC address (might take a while)..."
|
|
|
|
mac=$(generate_random_mac_address)
|
|
|
|
echo "Assigning randomly generated MAC: $mac to eth0..."
|
|
|
|
ifconfig eth0 hw ether $mac
|
|
|
|
ifconfig eth0 up
|
|
|
|
fi
|
|
|
|
|
2018-03-14 00:55:34 +00:00
|
|
|
# Set up static IP
|
2018-03-10 23:40:07 +00:00
|
|
|
if [ ! -z "$CONFIG_BOOT_STATIC_IP" ]; then
|
|
|
|
ifconfig eth0 $CONFIG_BOOT_STATIC_IP
|
2020-04-22 19:00:48 +00:00
|
|
|
#Get ip from DHCP
|
|
|
|
elif [ -e /sbin/udhcpc ];then
|
|
|
|
if udhcpc -T 1 -q; then
|
|
|
|
if [ -e /sbin/ntpd ]; then
|
|
|
|
DNS_SERVER=$(grep nameserver /etc/resolv.conf|awk -F " " {'print $2'})
|
|
|
|
killall ntpd 2&>1 > /dev/null
|
|
|
|
if ! ntpd -d -N -n -q -p $DNS_SERVER > /dev/ttyprintk; then
|
|
|
|
if ! ntpd -d -d -N -n -q -p ntp.pool.org> /dev/ttyprintk; then
|
|
|
|
echo "NTP sync unsuccessful." > /dev/tty0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
hwclock -w
|
|
|
|
echo "" > /dev/tty0
|
2022-03-23 20:02:59 +00:00
|
|
|
date=`date "+%Y-%m-%d %H:%M:%S %Z"`
|
|
|
|
echo "Time: $date" > /dev/tty0
|
2020-04-22 19:00:48 +00:00
|
|
|
fi
|
|
|
|
fi
|
2018-03-10 23:40:07 +00:00
|
|
|
fi
|
2020-04-22 19:00:48 +00:00
|
|
|
|
2018-03-10 23:40:07 +00:00
|
|
|
ifconfig eth0 > /dev/ttyprintk
|
2020-04-22 19:00:48 +00:00
|
|
|
|
|
|
|
if [ -e /bin/dropbear ]; then
|
|
|
|
# Set up the ssh server, allow root logins and log to stderr
|
|
|
|
if [ ! -d /etc/dropbear ]; then
|
|
|
|
mkdir /etc/dropbear
|
|
|
|
fi
|
|
|
|
dropbear -B -R 2>/dev/ttyprintk
|
2018-03-10 23:40:07 +00:00
|
|
|
fi
|
2020-04-22 19:00:48 +00:00
|
|
|
echo "" > /dev/tty0
|
|
|
|
ifconfig eth0 | head -2 > /dev/tty0
|
2018-03-10 23:40:07 +00:00
|
|
|
fi
|