Skip to content
This repository was archived by the owner on Jan 28, 2023. It is now read-only.

Commit a0b270b

Browse files
committed
Fixed race condition in install script
Signed-off-by: Alexandro Sanchez Bach <[email protected]>
1 parent 12e4821 commit a0b270b

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

platforms/linux/haxm-install.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ groupadd -f $GRPNAME
1919
echo "KERNEL==\"${DEVNAME}\", GROUP=\"${GRPNAME}\", MODE=\"0660\"" \
2020
> /lib/udev/rules.d/99-haxm.rules
2121

22+
# Wait for device
23+
limit=3
24+
attempts=0
25+
while [ ! -c /dev/$DEVNAME ]; do
26+
if [ $attempts -ge $limit ]; then
27+
echo 'HAXM installation error: No device detected!'
28+
exit 1
29+
fi
30+
let attempts++
31+
echo "Waiting for device... (attempt $attempts of $limit)"
32+
sleep 1
33+
done
34+
2235
# Adjust device permissions
2336
chown root:$GRPNAME /dev/$DEVNAME
2437
chmod 660 /dev/$DEVNAME
38+
39+
echo 'HAXM successfully installed'

platforms/linux/haxm-uninstall.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ sed -i "/^${MODNAME}$/d" /etc/modules
1717

1818
# Unload kernel module
1919
modprobe -r $MODNAME
20+
21+
echo 'HAXM successfully uninstalled'

0 commit comments

Comments
 (0)