Implement BOOTDELAY option to wait for boot process to complete. Fix devd(8) config (thanks to LARKIND) to match all needed devices and their partitions.

This commit is contained in:
Slawomir Wojciech Wojtczak (vermaden) 2013-04-03 08:09:20 +02:00
parent 83e22eb923
commit 4506edf751
3 changed files with 33 additions and 7 deletions

View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Copyright (c) 2012 Slawomir Wojciech Wojtczak (vermaden) # Copyright (c) 2012-2013 Slawomir Wojciech Wojtczak (vermaden)
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -107,10 +107,16 @@ TIMEOUT (set to 8 by default)
example: TIMEOUT="8" example: TIMEOUT="8"
DELAY (set to 0.3 seconds by default) DELAY (set to 1 second by default)
How often to check for device availability. How often to check for device availability.
example: DELAY="2.5" example: DELAY="2.5"
BOOTDELAY (set to 45 seconds by default)
How long to wait for boot process to complete.
example: BOOTDELAY="30"
EOF EOF
exit 0 exit 0
} }
@ -143,7 +149,8 @@ fi
: ${USER="0"} # which user to use for popup : ${USER="0"} # which user to use for popup
: ${FM="0"} # which file manager to use : ${FM="0"} # which file manager to use
: ${TIMEOUT="8"} # stop waiting for device after that time : ${TIMEOUT="8"} # stop waiting for device after that time
: ${DELAY="0.3"} # check for the device node that often : ${DELAY="1"} # check for the device node that often
: ${BOOTDELAY="45"} # wait for boot process to complete
if [ "${USERUMOUNT}" = YES ] if [ "${USERUMOUNT}" = YES ]
then then
@ -232,6 +239,25 @@ __wait_for_device() { # 1=DEV
done done
} }
__wait_for_boot() {
local BOOTTIME=$( sysctl -n kern.boottime | awk -F',' '{print $1}' | awk '{print $NF }' )
local CURRTIME=$( date +%s )
local UPTIME=$(( ${CURRTIME} - ${BOOTTIME} ))
while [ ${UPTIME} -lt ${BOOTDELAY} ]
do
sleep 1
local WAIT=1
local CURRTIME=$( date +%s )
local UPTIME=$(( ${CURRTIME} - ${BOOTTIME} ))
done
if [ ${WAIT} -eq 1 ]
then
__log "${DEV}: wait for boot process completed after '${BOOTDELAY}' seconds"
fi
}
__wait_for_boot
DEV=/dev/${1} DEV=/dev/${1}
case ${2} in case ${2} in

View File

@ -1,14 +1,14 @@
notify 100 { notify 100 {
match "system" "DEVFS"; match "system" "DEVFS";
match "type" "CREATE"; match "type" "CREATE";
match "cdev" "(da|mmcsd)[0-9]+"; match "cdev" "(da|mmcsd)[0-9]+.*";
action "/usr/local/sbin/automount $cdev attach"; action "/usr/local/sbin/automount $cdev attach";
}; };
notify 100 { notify 100 {
match "system" "DEVFS"; match "system" "DEVFS";
match "type" "DESTROY"; match "type" "DESTROY";
match "cdev" "(da|mmcsd)[0-9]+"; match "cdev" "(da|mmcsd)[0-9]+.*";
action "/usr/local/sbin/automount $cdev detach"; action "/usr/local/sbin/automount $cdev detach";
}; };

View File

@ -1,14 +1,14 @@
notify 200 { notify 200 {
match "system" "DEVFS"; match "system" "DEVFS";
match "type" "CREATE"; match "type" "CREATE";
match "cdev" "(da|mmcsd)[0-9]+"; match "cdev" "(da|mmcsd)[0-9]+.*";
action "/bin/sh -xe /usr/local/sbin/automount $cdev attach >> /root/DEBUG.$cdev.attach 2>&1"; action "/bin/sh -xe /usr/local/sbin/automount $cdev attach >> /root/DEBUG.$cdev.attach 2>&1";
}; };
notify 200 { notify 200 {
match "system" "DEVFS"; match "system" "DEVFS";
match "type" "DESTROY"; match "type" "DESTROY";
match "cdev" "(da|mmcsd)[0-9]+"; match "cdev" "(da|mmcsd)[0-9]+.*";
action "/bin/sh -xe /usr/local/sbin/automount $cdev detach >> /root/DEBUG.$cdev.detach 2>&1"; action "/bin/sh -xe /usr/local/sbin/automount $cdev detach >> /root/DEBUG.$cdev.detach 2>&1";
}; };