mosers
/
eaas-vde-proxy
Archiviert
1
0
Fork 0

Start script rewritten, proxy changes macs (not fully functional) [#7]

main
Simon Moser vor 3 Jahren
Ursprung b27179fbc7
Commit 040814e0c3
Signiert von: mosers
GPG-Schlüssel-ID: 96B3365A234B500C

1
.gitignore vendored

@ -18,3 +18,4 @@
# Images
*.iso
*.qcow2
test-env/images

Binäre Datei nicht angezeigt.

@ -0,0 +1,75 @@
#!/bin/bash
# QEMU/VDE network environment preparation script
RUN='/run/vde'
qemu=/opt/qemu/build/qemu-system-x86_64
# PID identifiers
all="$RUN/*.pid"
network="$RUN/net_*.pid"
vms="$RUN/vm_*.pid"
alpine="$RUN/vm_alpine_*.pid"
alpine1="$RUN/vm_alpine_1.pid"
alpine2="$RUN/vm_alpine_2.pid"
kali="$RUN/vm_kali.pid"
case "$1" in
start)
sudo mkdir -p $RUN && sudo chown "$(id -un)":"$(id -gn)" $RUN
case "$2" in
network | all)
echo "Starting VDE network for QEMU: "
vde_switch -daemon -s $RUN/sw_main.sock -p $RUN/net_sw_main.pid
vde_switch -daemon -s $RUN/sw_proxy1.sock -p $RUN/net_sw_proxy1.pid
vde_switch -daemon -s $RUN/sw_proxy2.sock -p $RUN/net_sw_proxy2.pid
vde_switch -daemon -s $RUN/sw_proxy3.sock -p $RUN/net_sw_proxy3.pid
slirpvde -D -H 10.0.0.2 --daemon -s $RUN/sw_main.sock -p $RUN/net_slirp.pid
;;&
alpine1 | alpine | vms | all)
$qemu -m 512 -nic vde,mac='52:54:00:12:34:56',sock=$RUN/sw_proxy1.sock -hda alpine1.qcow2 -daemonize -vnc :1 -pidfile $RUN/vm_alpine_1.pid
;;&
alpine2 | alpine | vms | all)
$qemu -m 512 -nic vde,mac='52:54:00:12:34:66',sock=$RUN/sw_proxy2.sock -hda alpine2.qcow2 -daemonize -vnc :2 -pidfile $RUN/vm_alpine_2.pid
;;&
kali | vms | all)
$qemu -m 1024 -nic user -nic vde,mac='52:54:00:12:34:76',sock=$RUN/sw_proxy3.sock -hda kali.qcow2 -daemonize -vnc :3 -pidfile $RUN/vm_kali.pid
;;
*)
echo "Usage: envctl start {all|network|vms|alpine|alpine1|alpine2|kali}"
esac
#echo "Run:\nqemu -m 512 -nic vde,mac='52:54:00:12:34:56',sock=$RUN/sw_proxy.sock -hda alpine1.qcow2 -nographic"
;;
stop)
if [ -n "${!2}" ]; then
if ls ${!2} 2> /dev/null; then
cat ${!2} | xargs kill
rm -f ${!2}
else
echo "$2 is not running"
fi
else
echo "Usage: envctl stop {all|network|vms|alpine|alpine1|alpine2|kali}"
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
if [ -n "${!2}" ]; then
if ls ${!2} 2> /dev/null; then
ps -fq "$(cat ${!2} | xargs | sed 's/ /,/g')"
else
echo "$2 is not running"
fi
else
echo "Usage: envctl status {all|network|vms|alpine|alpine1|alpine2|kali}"
fi
;;
*)
echo "Usage: envctl {start|stop|restart} {all|network|vms|alpine|alpine1|alpine2|kali}"
exit 1
;;
esac
exit 0