mirror of
https://github.com/oSoWoSo/DistroHopper.git
synced 2024-08-14 22:46:53 +00:00
Add get_port() function
Find a free port from an available range.
This commit is contained in:
parent
4d7910b868
commit
292686c3ca
1 changed files with 13 additions and 0 deletions
13
quickemu.sh
13
quickemu.sh
|
@ -29,6 +29,19 @@ function vm_snapshot() {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_port() {
|
||||||
|
local PORT_START=22220
|
||||||
|
local PORT_RANGE=9
|
||||||
|
while true; do
|
||||||
|
local CANDIDATE=$[${PORT_START} + (${RANDOM} % ${PORT_RANGE})]
|
||||||
|
(echo "" >/dev/tcp/127.0.0.1/${CANDIDATE}) >/dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "${CANDIDATE}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
function vm_boot() {
|
function vm_boot() {
|
||||||
local VMNAME=$(basename ${VM} .conf)
|
local VMNAME=$(basename ${VM} .conf)
|
||||||
local BIOS=""
|
local BIOS=""
|
||||||
|
|
Loading…
Reference in a new issue