Rename rip_docker to install/vm-builder, and start making a build script that uses it

This commit is contained in:
Micah Lee 2021-06-29 17:01:47 -07:00
parent 57f9c6bf2c
commit 7b2211fc1f
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
16 changed files with 39 additions and 57 deletions

4
.gitignore vendored
View file

@ -134,4 +134,6 @@ deb_dist
.DS_Store .DS_Store
install/windows/Dangerzone.wxs install/windows/Dangerzone.wxs
test_docs/sample-safe.pdf test_docs/sample-safe.pdf
share/bin share/bin
install/vm-builder/vm
install/vm-builder/.vagrant

View file

@ -56,10 +56,10 @@ If you don't have it already, install poetry (`pip3 install --user poetry`). The
poetry install poetry install
``` ```
Make sure Docker Desktop is installed (Dangerzone copies hyperkit and vpnkit binaries from it) and run this to collect the binaries: Make sure [Docker Desktop](https://www.docker.com/products/docker-desktop) and vagrant (`brew install vagrant`) are installed and run this to collect the binaries:
``` ```
./install/macos/collect-bins.sh ./install/macos/get-vm.sh
``` ```
Run from source tree: Run from source tree:

View file

@ -11,7 +11,7 @@ class SysTray(QtWidgets.QSystemTrayIcon):
self.setIcon(self.gui_common.get_window_icon()) self.setIcon(self.gui_common.get_window_icon())
menu = QtWidgets.QMenu() menu = QtWidgets.QMenu()
self.status_action = menu.addAction("Dangerzone is starting ...") self.status_action = menu.addAction("...")
self.status_action.setEnabled(False) self.status_action.setEnabled(False)
menu.addSeparator() menu.addSeparator()
self.restart_action = menu.addAction("Restart") self.restart_action = menu.addAction("Restart")
@ -22,6 +22,22 @@ class SysTray(QtWidgets.QSystemTrayIcon):
self.setContextMenu(menu) self.setContextMenu(menu)
self.show() self.show()
# Processes for the Dangerzone VM
self.vpnkit_p = None
self.hyperkit_p = None
# Start the VM
self.vm_start()
def vm_start(self):
self.status_action.setText("Starting Dangerzone ...")
# Kill existing processes
if self.vpnkit_p is not None:
self.vpnkit_p.terminate()
if self.hyperkit_p is not None:
self.hyperkit_p.terminate()
def restart_clicked(self): def restart_clicked(self):
self.status_action.setText("Restarting Dangerzone ...") self.status_action.setText("Restarting Dangerzone ...")

View file

@ -1,4 +0,0 @@
#!/bin/sh
mkdir -p share/bin
cp /Applications/Docker.app/Contents/Resources/bin/com.docker.hyperkit share/bin/hyperkit
cp /Applications/Docker.app/Contents/Resources/bin/com.docker.vpnkit share/bin/vpnkit

17
install/macos/get-vm.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
# Extract hyperkit and vpnkit from Docker Desktop
mkdir -p share/bin
cp /Applications/Docker.app/Contents/Resources/bin/com.docker.hyperkit share/bin/hyperkit
cp /Applications/Docker.app/Contents/Resources/bin/com.docker.vpnkit share/bin/vpnkit
# Build ISO
cd install/vm-builder
vagrant up
vagrant ssh -- /vagrant/build-iso.sh
vagrant down
cd ../..
# Copy the ISO to resources
mkdir -p share/vm
cp install/vm-builder/vm/* share/vm

View file

@ -1,2 +0,0 @@
vm
.vagrant

View file

@ -1,47 +0,0 @@
#!/usr/bin/env python3
import subprocess
import uuid
import os
def main():
base_dir = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "vm"
)
vm_uuid = uuid.uuid4()
cmd = [
"hyperkit",
"-m",
"4G",
"-c",
"2",
"-s",
"0:0,hostbridge",
"-s",
"31,lpc",
"-s",
"2:0,virtio-net",
"-l",
"com1,stdio",
# "-F",
# os.path.join(base_dir, "hyperkit.pid"),
"-U",
str(vm_uuid),
"-s",
"3:0,ahci-cd," + os.path.join(base_dir, "alpine-dangerzone-v3.14-x86_64.iso"),
"-f",
"kexec,"
+ os.path.join(base_dir, "vmlinuz-virt")
+ ","
+ os.path.join(base_dir, "initramfs-virt")
+ ',"modules=virtio_net console=ttyS0"',
]
print(" ".join(cmd))
subprocess.run(cmd)
if __name__ == "__main__":
main()