Commit 7ce47e33 authored by Volker Hilsheimer's avatar Volker Hilsheimer

Change the default host home mount location on VM

Instead of generic /home/host, map the host user's home directory to the
equivalent location on the guest.

If that does not exist, keep using /home/host for compatibility reasons.
parent 866a895e
......@@ -231,15 +231,19 @@ Default rules are defined in the `settings` section of the `minicoin.yml` files.
Unless folder-sharing is disabled, the minicoin directory with the Vagrantfile
will be shared with the guest as a folder `/minicoin`; the home directory of
the current user (or whatever the `home_share` attribute specifies) will be shared
with the guest as a folder `host` (`/home/host` on Linux, `C:\Users\host` on
Windows, `/Users/host` on Mac guests).
with the guest as a home-folder in the respective home directory, ie (`/home/$USER`
on Linux, `C:\Users\$USER` on Windows, `/Users/$USER` on Mac guests, with `$USER`
being the user name on the host system).
Folder sharing can be disabled for each box by setting the `shared_folders`
attribute to `disabled`; the global `home_share` setting can be set to something
else than `~`, or to `disabled` to only share the minicoin folder.
else than `$HOME`, or to `disabled` to only share the minicoin folder.
On cloud-hosted VMs, folder-sharing should be disabled. Use the `mutagen` role
instead.
On cloud-hosted VMs, folder-sharing should be disabled. Use the file syncing
technologies, for instance `mutagen` through the available role, instead. When
doing so, the location of the files on the guest MUST be in the same relative
location to the `vagrant` user's home as it is on the host machine to the user's
home.
# Roles
......
......@@ -9,14 +9,17 @@ on the host
`minicoin` was run
* the `minicoin/util` directory is available in `/minicoin/util` (or
`C:\minicoin\util`), so utility scripts can be found there
* the user's home directory (if not disabled) is available in a "host"
subdirectory the platform's location for user directories (ie
`/home/host` for linux, `/Users/host` for macOS, `C:\Users\host` on Windows)
Job scripts should combine the first and second arguments passed in to map
directories on the host machine to directories on the box. The `parse-opts`
scripts in minicoin/util do this automatically, setting a `JOBDIR` variable
accordingly.
directories on the host machine to directories on the VM. Note that users or
minicoin may disable sharing of the home directory, and use other techniques
to make files from the host available to the guest. In those cases, the files
MUST be in an equivalent location of the `vagrant` home directory. Jobs should
not assume that the users' home directory is mounted, but prioritise an
equivalent location in the `vagrant` home.
The `parse-opts` scripts in minicoin/util do this automatically, setting a
`JOBDIR` variable accordingly.
This means that running minicoin in your home directory will automatically
set the `JOBDIR` variable to host's home directory mapped to the guest file
......@@ -27,9 +30,9 @@ $ cd ~/qt
$ minicoin run ubuntu1804 windows10 macos1013 test
```
will make the test script print "Job works on '/home/host/qt'" on the
Linux box, "Job works on 'C:\Users\host\qt'" on the Windows box, and
"Job works on '/Users/host/qt'" on the macOS box. See the code in the
will make the test script print "Job works on '/home/user/qt'" on the
Linux box, "Job works on 'C:\Users\user\qt'" on the Windows box, and
"Job works on '/Users/user/qt'" on the macOS box. See the code in the
`parse-opts` scripts in `minicoin/util` for how to convert the arguments
manually in your own scripts, if you don't want to use `parse-opts`.
......
......@@ -5,7 +5,7 @@ settings:
defaults:
shared_folders:
- $PWD: /minicoin # required by provisioning scripts
- $HOME_SHARE: $GUEST_HOMES/host
- $HOME_SHARE: $GUEST_HOMES/$USER
## locations from which we can download tqtc boxes and disk archives
......
......@@ -120,12 +120,21 @@ set short=
REM Interpret P0 and P1, set JOBDIR
set "_JOBDIR=!POSITIONAL[1]!"
set "HOST_HOME=!POSITIONAL[0]!"
set "MOUNTED_HOME=C:\Users\host"
call :get_username %HOST_HOME%
set "MOUNTED_HOME=C:\Users\%HOST_USER%"
if not exist %MOUNTED_HOME% SET "MOUNTED_HOME=C:\Users\host"
set JOBDIR=!_JOBDIR:%HOST_HOME%=%USERPROFILE%!
if not exist %JOBDIR% (
set JOBDIR=!_JOBDIR:%HOST_HOME%=%MOUNTED_HOME%!
)
set _JOBDIR=
set MOUNTED_HOME=
set HOST_HOME=
set JOBDIR=!JOBDIR:/=\!
exit /b
:get_username
SET "HOST_USER=%~nx1"
exit /b
......@@ -60,13 +60,16 @@ unset count
_JOBDIR="${POSITIONAL[1]}"
HOST_HOME="${POSITIONAL[0]}"
MOUNTED_HOME="/home/host"
HOST_USER=$(basename $HOST_HOME)
[ -d /Users ] && MOUNTED_HOME="/Users" || MOUNTED_HOME="/home"
[ -d "$MOUNTED_HOME/$HOST_USER" ] && MOUNTED_HOME="$MOUNTED_HOME/$HOST_USER" || MOUNTED_HOME="$MOUNTED_HOME/host"
JOBDIR="${_JOBDIR/$HOST_HOME/$HOME}"
if [ ! -d "$JOBDIR" ]
then
JOBDIR="${_JOBDIR/$HOST_HOME/$MOUNTED_HOME}"
fi
unset _JOBDIR
unset _HOST_HOME
unset HOST_HOME
unset MOUNTED_HOME
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment