mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-06-08 01:18:32 +08:00
Alternative sleep function
This commit is contained in:
parent
c9d544d0cd
commit
eb30a4d66f
@ -1,11 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -u
|
||||
|
||||
declare nmi
|
||||
# Functions
|
||||
|
||||
snore()
|
||||
{
|
||||
local IFS
|
||||
[[ -n "${_snore_fd:-}" ]] || exec {_snore_fd}<> <(:)
|
||||
read ${1:+-t "$1"} -u $_snore_fd || :
|
||||
}
|
||||
|
||||
function checkNMI {
|
||||
|
||||
nmi=$(awk '/NMI/ {for (i=2; i<=NF; i++) if ($i ~ /^[0-9]+$/) {sum+=$i}} END {print sum}' /proc/interrupts)
|
||||
local nmi=$(awk '/NMI/ {for (i=2; i<=NF; i++) if ($i ~ /^[0-9]+$/) {sum+=$i}} END {print sum}' /proc/interrupts)
|
||||
|
||||
if [ "$nmi" != "" ] && [ "$nmi" -ne "0" ]; then
|
||||
|
||||
@ -18,9 +25,13 @@ function checkNMI {
|
||||
|
||||
}
|
||||
|
||||
# Setup serialport
|
||||
|
||||
chmod 666 /dev/ttyS0
|
||||
checkNMI
|
||||
|
||||
# Install packages
|
||||
|
||||
first_run=false
|
||||
|
||||
for filename in /usr/local/packages/*.spk; do
|
||||
@ -50,14 +61,17 @@ else
|
||||
|
||||
fi
|
||||
|
||||
# Display message in docker log output
|
||||
|
||||
echo "-------------------------------------------" > /dev/ttyS0
|
||||
echo " You can now login to DSM at port 5000 " > /dev/ttyS0
|
||||
echo "-------------------------------------------" > /dev/ttyS0
|
||||
|
||||
# Wait for NMI interrupt as a shutdown signal
|
||||
|
||||
while true; do
|
||||
|
||||
checkNMI
|
||||
sleep 2
|
||||
snore 2
|
||||
|
||||
done
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user