Quickly sync selected files from your project with a VM testing machine.
Testing your code can break things, or leave unwanted rubbish in places you don’t expect. That’s why using a Virtual Machine (VM) is so convenient:
- 1) run your code -> 2) screw up -> 3) rewind -> 4) improve -> back to 1)
For many scenarios a normal shared folder does the job - code on host, execute on guest. However, the shared folder has different file permissions as it is mounted akin to a network share (VirtualBox 6.1), and hence is owned by root and restricted to the group vboxsf.
Enabling an ssh server on the guest and using rsync to transfer the files while keeping all file permissions as on the host allows for a better 1:1 replication, and avoids execution errors due to permission mismatches.
- bash
- rsync
- VM running ssh server
- Clone the repo
git clone https://github.com/mtoboid/sandbox.git
- Use ‘install’ to install the script:
install sandbox.bash /usr/local/bin/sandbox
- To uninstall simply delete the script:
rm /usr/local/bin/sandbox
- Install Sandbox.
- Install VirtualBox
- Set up your favourite distro as testing machine (e.g. Netinstall from Debian)
- After the machine is installed enable a second Guest-Host network adapter
for the machine:
- Settings -> Network -> ‘Adapter 2’: ‘Host-only Adapter’; ‘vboxnet0’
- Start the Guest
- (On Host) check that ‘vboxnet0’ is detected
ip link show
- (On Host) and note the ip address range
ip addr show
here 192.168.56.1
- (On Guest) get the devicename for the network adapter
ip link show
here enp0s8
- (On Guest) place a config for the adapter in
/etc/network/interfaces.d/${devicename}.config
:# Replace the xxx with whatever static ip you want to assign to the guest. # We'll use 200 for this example auto ${devicename} iface ${devicename} inet static address 192.168.56.xxx/24 network 192.168.56.0 broadcast 192.168.56.255
- Reboot the Guest and ensure everything is working:
ip addr show
-> 192.168.56.200 (or whatever you chose)systemctl status ssh
-> active (running)
- (On Host)
ssh [email protected]
should now work
- For more information about available actions see
sandbox usage
. - Now go to your project and setup Sandbox
sandbox setup
!
(C) 2020-2021 Tobias Marczewski SPDX: GPL-3.0-or-later