Merge "Add dhcp support for ramdisk element."
This commit is contained in:
commit
fc5e791a6b
1
elements/ramdisk/binary-deps.d/ramdisk
Normal file
1
elements/ramdisk/binary-deps.d/ramdisk
Normal file
@ -0,0 +1 @@
|
||||
dhclient
|
1
elements/ramdisk/element-deps
Normal file
1
elements/ramdisk/element-deps
Normal file
@ -0,0 +1 @@
|
||||
pkg-map
|
@ -34,10 +34,12 @@ mount -t proc proc /proc
|
||||
readonly _BOOTIF_=$(get_kernel_parameter BOOTIF)
|
||||
readonly _IP_=$(get_kernel_parameter ip)
|
||||
readonly BOOT_MAC_ADDRESS=$(echo "$_BOOTIF_" | sed -e "s/-/:/g" | sed -e "s/^01://g" | tr 'a-f' 'A-F')
|
||||
readonly BOOT_IP_ADDRESS=$(echo "$_IP_" | cut -d':' -f1)
|
||||
readonly BOOT_SERVER=$(echo "$_IP_" | cut -d':' -f2)
|
||||
readonly BOOT_NETMASK=$(echo "$_IP_" | cut -d':' -f4)
|
||||
readonly BOOT_GATEWAY=$(echo "$_IP_" | cut -d':' -f3)
|
||||
|
||||
# IP address and other parameters may be set later in the init script
|
||||
BOOT_IP_ADDRESS=$(echo "$_IP_" | cut -d':' -f1)
|
||||
BOOT_NETMASK=$(echo "$_IP_" | cut -d':' -f4)
|
||||
BOOT_GATEWAY=$(echo "$_IP_" | cut -d':' -f3)
|
||||
|
||||
readonly DISK=$(get_kernel_parameter disk)
|
||||
|
||||
|
@ -26,20 +26,35 @@ if [ $rv -ne 0 ]; then
|
||||
troubleshoot
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if boot IP address was specific or retrieve from DHCP
|
||||
if [ -n "$BOOT_IP_ADDRESS" ]; then
|
||||
ifconfig "$BOOT_INTERFACE" "$BOOT_IP_ADDRESS" netmask "$BOOT_NETMASK"
|
||||
route del default || true
|
||||
route add default gw $BOOT_GATEWAY
|
||||
|
||||
echo "pinging to boot server $BOOT_SERVER"
|
||||
w=30
|
||||
while [ $w -gt 0 ]; do
|
||||
ping -c 5 -q "$BOOT_SERVER" > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
break
|
||||
else
|
||||
dhclient -1 "$BOOT_INTERFACE"
|
||||
if [[ $? == 2 ]]; then
|
||||
echo "Error getting IP address for $BOOT_INTERFACE with MAC \
|
||||
$BOOT_MAC_ADDRESS"
|
||||
troubleshoot
|
||||
fi
|
||||
|
||||
BOOT_IP_ADDRESS=$(ifconfig "$BOOT_INTERFACE" | grep 'inet addr:' | \
|
||||
cut -d: -f2 | awk '{ print $1}')
|
||||
BOOT_NETMASK=$(ifconfig "$BOOT_INTERFACE" | grep 'Mask:' | cut -d':' -f4)
|
||||
BOOT_GATEWAY=$(route -n | grep "$BOOT_INTERFACE" | grep '^0.0.0.0' | \
|
||||
awk '{print $2}')
|
||||
echo "obtained the following from dhcp: "
|
||||
echo " ip address = $BOOT_IP_ADDRESS"
|
||||
echo " netmask = $BOOT_NETMASK"
|
||||
echo " gateway = $BOOT_GATEWAY"
|
||||
fi
|
||||
|
||||
if [ -n "$BOOT_SERVER" ]; then
|
||||
echo "pinging to boot server $BOOT_SERVER"
|
||||
wait_for 6 1 ping -c 5 -q "$BOOT_SERVER" > /dev/null
|
||||
fi
|
||||
sleep 1
|
||||
w=`expr $w - 5`
|
||||
done
|
||||
|
||||
echo "network ready"
|
||||
|
||||
|
@ -2,6 +2,5 @@
|
||||
set -eux
|
||||
set -o pipefail
|
||||
|
||||
if [ "opensuse" = "$DISTRO_NAME" ]; then
|
||||
install-packages dhcp-client
|
||||
fi
|
||||
DHCP_CLIENT=$(pkg-map --element ramdisk dhcp_client)
|
||||
install-packages $DHCP_CLIENT
|
||||
|
10
elements/ramdisk/pkg-map
Normal file
10
elements/ramdisk/pkg-map
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"family":{
|
||||
"debian":{
|
||||
"dhcp_client":"isc-dhcp-client"
|
||||
}
|
||||
},
|
||||
"default":{
|
||||
"dhcp_client":"dhclient"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user