del version bash
parent
95a823446d
commit
462fac61d7
@ -1,69 +0,0 @@
|
||||
#!/bin/bash
|
||||
vmsDir="$HOME/vms"
|
||||
|
||||
function main(){
|
||||
downloadSysList
|
||||
filterList
|
||||
downloadSysIsos
|
||||
showVms
|
||||
}
|
||||
|
||||
function downloadSysList(){
|
||||
mkdir -p $vmsDir
|
||||
wget --no-check-certificate -q "http://fanta.56k.es/q/systems.lst" -O $vmsDir/.systems.lst
|
||||
}
|
||||
|
||||
function filterList(){
|
||||
nl=$(cat /home/fanta/vms/.systems.lst | wc -l)
|
||||
cat -n $vmsDir/.systems.lst | cut -d ";" -f 1,2 | tr ";" " "
|
||||
echo " "
|
||||
read -p "Number: " option
|
||||
if [[ $option == ?(-)+([0-9]) ]] ; then
|
||||
if [ "$option" -ge 1 ] && [ "$option" -le $nl ]; then
|
||||
cat $vmsDir/.systems.lst | head -$option | tail -1 > $vmsDir/.systems2.lst
|
||||
mv $vmsDir/.systems2.lst $vmsDir/.systems.lst
|
||||
else
|
||||
echo -e "\nError: Try again and enter a valid number my friend"
|
||||
exit
|
||||
fi
|
||||
|
||||
else
|
||||
echo -e "\nError: Try again and enter a integer number my friend"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
function downloadSysIsos(){
|
||||
while read system; do
|
||||
data=("$(echo "$system" | cut -d ";" -f 1)" "$(echo "$system" | cut -d ";" -f 2)" "$(echo "$system" | cut -d ";" -f 3)" "$(echo "$system" | cut -d ";" -f 4)" "$(echo "$system" | cut -d ";" -f 5)" "$(echo "$system" | cut -d ";" -f 6)" "$(echo "$system" | cut -d ";" -f 7)" "$(echo "$system" | cut -d ";" -f 8)")
|
||||
isoName="${data[0]}-${data[1]}-${data[2]}.iso"
|
||||
url="${data[3]}"
|
||||
sizeDisc="${data[4]}G"
|
||||
sizeRam="${data[5]}"
|
||||
extra="${data[6]}"
|
||||
echo "[+] Downloading $isoName"
|
||||
mkdir -p $vmsDir/${data[0]}-${data[1]}-${data[2]}
|
||||
if [ -f "$vmsDir/${data[0]}-${data[1]}-${data[2]}/$isoName" ]; then
|
||||
echo " $vmsDir/${data[0]}-${data[1]}-${data[2]}/$isoName exists"
|
||||
else
|
||||
wget --no-check-certificate -q $url -O $vmsDir/${data[0]}-${data[1]}-${data[2]}/$isoName
|
||||
echo " Create img [$sizeDisc] $vmsDir/${data[0]}-${data[1]}-${data[2]}/${data[0]}-${data[1]}-${data[2]}.qcow2"
|
||||
qemu-img create -q -f qcow2 "$vmsDir/${data[0]}-${data[1]}-${data[2]}/${data[0]}-${data[1]}-${data[2]}.qcow2" $sizeDisc
|
||||
echo " Create install script"
|
||||
echo "#!/bin/bash" > "$vmsDir/${data[0]}-${data[1]}-${data[2]}/install.sh"
|
||||
echo "qemu-system-${data[2]} $extra -m $sizeRam -cdrom $vmsDir/${data[0]}-${data[1]}-${data[2]}/$isoName -hda $vmsDir/${data[0]}-${data[1]}-${data[2]}/${data[0]}-${data[1]}-${data[2]}.qcow2" >> "$vmsDir/${data[0]}-${data[1]}-${data[2]}/install.sh"
|
||||
echo " Create start script"
|
||||
echo "#!/bin/bash" > "$vmsDir/${data[0]}-${data[1]}-${data[2]}/start.sh"
|
||||
echo "qemu-system-${data[2]} $extra -m $sizeRam -hda $vmsDir/${data[0]}-${data[1]}-${data[2]}/${data[0]}-${data[1]}-${data[2]}.qcow2" > "$vmsDir/${data[0]}-${data[1]}-${data[2]}/start.sh"
|
||||
fi
|
||||
done < $vmsDir/.systems.lst
|
||||
}
|
||||
|
||||
function showVms() {
|
||||
echo -en "\nVMs List:\n\n"
|
||||
cd $vmsDir
|
||||
ls -1
|
||||
echo -en "\nVirtual machines dir: $vmsDir\n\nChange to $vmsDir directory. Happy hacking !\n\n"
|
||||
}
|
||||
|
||||
main
|
Loading…
Reference in New Issue