Skip to content

Quickly sync selected files from your project with a VM testing machine.

License

Notifications You must be signed in to change notification settings

mtoboid/sandbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sandbox

Quickly sync selected files from your project with a VM testing machine.

Rationale

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.

Dependencies

  • bash
  • rsync
  • VM running ssh server

Install

  1. Clone the repo git clone https://github.com/mtoboid/sandbox.git
  2. Use ‘install’ to install the script:
    install sandbox.bash /usr/local/bin/sandbox
        
  3. To uninstall simply delete the script:
    rm /usr/local/bin/sandbox
        

Example setup with a VM (VirtualBox)

  1. Install Sandbox.
  2. Install VirtualBox
  3. Set up your favourite distro as testing machine (e.g. Netinstall from Debian)
  4. 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
  5. For more information about available actions see sandbox usage.
  6. Now go to your project and setup Sandbox sandbox setup!

License

(C) 2020-2021 Tobias Marczewski SPDX: GPL-3.0-or-later

About

Quickly sync selected files from your project with a VM testing machine.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages