mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 05:06:43 +00:00
Merge pull request #3153 from andreasmn/wakeonlan
init: optimized wake-on-lan script
This commit is contained in:
commit
5214346595
@ -80,6 +80,7 @@
|
|||||||
case $boot in
|
case $boot in
|
||||||
CIFS=*|SMB=*|ISCSI=*|NBD=*|NFS=*)
|
CIFS=*|SMB=*|ISCSI=*|NBD=*|NFS=*)
|
||||||
UPDATE_DISABLED=yes
|
UPDATE_DISABLED=yes
|
||||||
|
FLASH_NETBOOT=yes
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
@ -94,9 +95,6 @@
|
|||||||
wol_mac=*)
|
wol_mac=*)
|
||||||
wol_mac="${arg#*=}"
|
wol_mac="${arg#*=}"
|
||||||
;;
|
;;
|
||||||
wol_ip=*)
|
|
||||||
wol_ip="${arg#*=}"
|
|
||||||
;;
|
|
||||||
wol_wait=*)
|
wol_wait=*)
|
||||||
wol_wait="${arg#*=}"
|
wol_wait="${arg#*=}"
|
||||||
;;
|
;;
|
||||||
@ -415,22 +413,40 @@
|
|||||||
fi
|
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() {
|
mount_flash() {
|
||||||
progress "Mounting flash"
|
progress "Mounting flash"
|
||||||
|
|
||||||
|
wakeonlan
|
||||||
|
|
||||||
mount_part "$boot" "/flash" "ro,noatime"
|
mount_part "$boot" "/flash" "ro,noatime"
|
||||||
}
|
}
|
||||||
|
|
||||||
mount_storage() {
|
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
|
|
||||||
|
|
||||||
progress "Mounting storage"
|
progress "Mounting storage"
|
||||||
|
|
||||||
|
wakeonlan
|
||||||
|
|
||||||
if [ -n "$disk" ]; then
|
if [ -n "$disk" ]; then
|
||||||
if [ -n "$OVERLAY" ]; then
|
if [ -n "$OVERLAY" ]; then
|
||||||
OVERLAY_DIR=`cat /sys/class/net/eth0/address | tr -d :`
|
OVERLAY_DIR=`cat /sys/class/net/eth0/address | tr -d :`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user