-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathvbox-share
executable file
·66 lines (62 loc) · 1.38 KB
/
vbox-share
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
#
# VirtualBox share.
#
# Virtualbox shares a folder as root by default;
# this script gets the current user's uid and gid,
# then shares a given folder (default ~/vbox/share).
#
# Examples:
#
# vbox-share
# vbox-share foo /media/bar
#
# Setup ideas for a Debian host with a Windows guest:
#
# http://www.maketecheasier.com/share-files-in-virtualbox-between-vista-guest-ubuntu-host/
#
# Setup ideas for a Debian guest:
#
# 1. As root, install the virtualbox guest additons.
# 2. Reboot the guest system (in this case a lenny install)
# 3. Run: modprobe vboxvfs (reports nothing so all is well)
# 4. mount.vboxsf MyVirtualDrive /media/shared
#
# Setup guest additions on a Debian host:
#
# apt-get install \
# virtualbox-guest-dkms \
# virtualbox-guest-utils \
# virtualbox-guest-x11 \
# virtualbox-ose-guest-utils
#
# Version: 1.2.0
# Created: 2014-01-16
# Updated: 2015-01-25
# License: GPL
# Contact: Joel Parker Henderson ([email protected])
##
set -euf
# Get the current user
uid=`id -u`
gid=`id -g`
user=`id -un`
# The host directory to share must be
# a relative path in the user's directory.
#
# Right:
#
# foo/bar
#
# Wrong:
#
# /home/alice/foo/bar
# /foo/bar
# ~alice/foo/bar
# ~/foo/bar
#
src=${1:-"vbox/share"}
# The mount point
mnt=${2:-"/media/vbox-share"}
set -o xtrace
sudo mount -t vboxsf -o uid=$uid,gid=$gid $src $mnt