fixing parallel invocations of start.sh
This commit is contained in:
parent
2868d59e9e
commit
956073c4ef
3
.gitignore
vendored
3
.gitignore
vendored
@ -10,8 +10,5 @@
|
|||||||
# build dirs
|
# build dirs
|
||||||
build/
|
build/
|
||||||
|
|
||||||
# fragments of running VM
|
|
||||||
.boot/
|
|
||||||
|
|
||||||
# generated ssh keys
|
# generated ssh keys
|
||||||
keys/*
|
keys/*
|
||||||
|
15
start.sh
15
start.sh
@ -24,10 +24,13 @@ _builddir=build
|
|||||||
mkdir -p $_builddir
|
mkdir -p $_builddir
|
||||||
|
|
||||||
_imagefile=$1
|
_imagefile=$1
|
||||||
_pidfile=$_builddir/qemu.pid
|
_pidfile=$_builddir/qemu-$$.pid
|
||||||
|
_bootdir=$_builddir/boot-$$
|
||||||
|
|
||||||
_loopdev=$(sudo losetup -f --show $_imagefile)
|
_loopdev=$(sudo losetup -f --show $_imagefile)
|
||||||
_bootdir=.boot
|
sudo partprobe $_loopdev
|
||||||
|
_localport=$((2022 + $(find $_builddir -iname 'qemu-*.pid' | wc -l)))
|
||||||
|
touch $_pidfile
|
||||||
|
|
||||||
# register a cleanup error handler
|
# register a cleanup error handler
|
||||||
function cleanup {
|
function cleanup {
|
||||||
@ -50,7 +53,7 @@ QEMU_AUDIO_DRV=none qemu-system-arm \
|
|||||||
--append "root=/dev/mmcblk0p2 rw roottype=ext4 console=ttyAMA0" \
|
--append "root=/dev/mmcblk0p2 rw roottype=ext4 console=ttyAMA0" \
|
||||||
-drive if=sd,driver=raw,cache=writeback,file=$_imagefile \
|
-drive if=sd,driver=raw,cache=writeback,file=$_imagefile \
|
||||||
-display none \
|
-display none \
|
||||||
-net user,hostfwd=tcp::2022-:22 \
|
-net user,hostfwd=tcp::$_localport-:22 \
|
||||||
-net nic \
|
-net nic \
|
||||||
-daemonize \
|
-daemonize \
|
||||||
-snapshot \
|
-snapshot \
|
||||||
@ -58,15 +61,15 @@ QEMU_AUDIO_DRV=none qemu-system-arm \
|
|||||||
|
|
||||||
# wait for ssh to be up
|
# wait for ssh to be up
|
||||||
_sshopts="-o StrictHostKeyChecking=no -o ConnectTimeout=5"
|
_sshopts="-o StrictHostKeyChecking=no -o ConnectTimeout=5"
|
||||||
while ! ssh -p 2022 -i keys/id_rsa root@localhost $_sshopts true 2>/dev/null; do
|
while ! ssh -p $_localport -i keys/id_rsa root@localhost $_sshopts true 2>/dev/null; do
|
||||||
echo -n . && sleep 5
|
echo -n . && sleep 5
|
||||||
done && echo
|
done && echo
|
||||||
|
|
||||||
# open a session
|
# open a session
|
||||||
ssh -p 2022 -i keys/id_rsa parabola@localhost
|
ssh -p $_localport -i keys/id_rsa parabola@localhost
|
||||||
|
|
||||||
# shutdown the VM
|
# shutdown the VM
|
||||||
ssh -p 2022 -i keys/id_rsa root@localhost "nohup shutdown -h now &>/dev/null & exit"
|
ssh -p $_localport -i keys/id_rsa root@localhost "nohup shutdown -h now &>/dev/null & exit"
|
||||||
while sudo kill -0 $(cat $_pidfile) 2> /dev/null; do echo -n . && sleep 5; done && echo
|
while sudo kill -0 $(cat $_pidfile) 2> /dev/null; do echo -n . && sleep 5; done && echo
|
||||||
rm -f $_pidfile
|
rm -f $_pidfile
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user