init: optimized wake-on-lan script

This commit is contained in:
andreasmn 2014-04-30 09:16:56 +02:00 committed by Stephan Raue
parent a2b61f7c1c
commit 89ee8cc204

View File

@ -80,6 +80,7 @@
case $boot in
CIFS=*|SMB=*|ISCSI=*|NBD=*|NFS=*)
UPDATE_DISABLED=yes
FLASH_NETBOOT=yes
;;
esac
;;
@ -94,9 +95,6 @@
wol_mac=*)
wol_mac="${arg#*=}"
;;
wol_ip=*)
wol_ip="${arg#*=}"
;;
wol_wait=*)
wol_wait="${arg#*=}"
;;
@ -415,22 +413,40 @@
fi
}
wakeonlan() {
if [ "$STORAGE_NETBOOT" = "yes" ]; then
wol_ip=${disk%:*}
wol_ip=${wol_ip#*=}
elif [ "$FLASH_NETBOOT" = "yes" ]; then
wol_ip=${boot%:*}
wol_ip=${wol_ip#*=}
else
return 0
fi
if [ -n "$wol_ip" -a -n "$wol_mac" -a -n "$wol_wait" ]; then
progress "Sending Magic Packet (WOL) if needed"
if ! ping -q -c 2 "$wol_ip" &>/dev/null; then
ether-wake "$wol_mac"
sleep "$wol_wait"
fi
fi
}
mount_flash() {
progress "Mounting flash"
wakeonlan
mount_part "$boot" "/flash" "ro,noatime"
}
mount_storage() {
if [ -n "$wol_ip" ] && [ -n "$wol_mac" ] && [ -n "$wol_wait" ]; then
if ! (/bin/busybox ping -q -c 2 "$wol_ip" > /dev/null 2>&1); then
/bin/busybox ether-wake "$wol_mac"
/bin/busybox sleep "$wol_wait"
fi
fi
mount_storage() {
progress "Mounting storage"
wakeonlan
if [ -n "$disk" ]; then
if [ -n "$OVERLAY" ]; then
OVERLAY_DIR=`cat /sys/class/net/eth0/address | tr -d :`