Sha256: 1d691cf4cf15755de18f457d0c691d3c7281b1f5dde564a038360cf4a7a0ee22

Contents?: true

Size: 1.34 KB

Versions: 17

Compression:

Stored size: 1.34 KB

Contents

function Test-ReparsePoint([string]$path) {
  $file = Get-Item $path -Force -ea 0
  return [bool]($file.Attributes -band [IO.FileAttributes]::ReparsePoint)
}

$MountPoint = [System.IO.Path]::GetFullPath("<%= options[:mount_point] %>")
$ShareName = "<%= options[:share_name] %>"
$VmProviderUncPath = "<%= options[:vm_provider_unc_path] %>"

# https://github.com/BIAINC/vagrant-windows/issues/4
# Not sure why this works, but it does.

& net use $ShareName 2>&1 | Out-Null

Write-Debug "Attempting to mount $ShareName to $MountPoint"
if( (Test-Path "$MountPoint") -and (Test-ReparsePoint "$MountPoint") )
{
  Write-Debug "Junction already exists, so I will delete it"
  # Powershell refuses to delete junctions, oh well use cmd
  cmd /c rd "$MountPoint"

  if ( $LASTEXITCODE -ne 0 )
  {
    Write-Error "Failed to delete symbolic link at $MountPoint"
    exit 1
  }

}
elseif(Test-Path $MountPoint)
{
  Write-Debug "Mount point already exists and is not a symbolic link"
  exit 1
}

$BaseDirectory = [System.IO.Path]::GetDirectoryName($MountPoint)

if (-not (Test-Path $BaseDirectory))
{
  Write-Debug "Creating parent directory for mount point $BaseDirectory"
  New-Item $BaseDirectory -Type Directory -Force | Out-Null
}

cmd /c mklink /D "$MountPoint" "$VmProviderUncPath" | out-null

if ( $LASTEXITCODE -ne 0 )
{
  exit 1
}

Version data entries

17 entries across 14 versions & 4 rubygems

Version Path
vagrant-unbundled-1.9.1.1 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-1.8.5.2 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-1.8.5.1 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-1.8.4.2 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-1.8.4.1 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-1.8.1.2 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-1.8.1.1 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-cloudstack-1.2.0 vendor/bundle/bundler/gems/vagrant-c84e05fd063f/plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-272fb27e0536/plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-1cf2a8db4ccb/plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-b421af58e8b3/plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-309e896975d1/plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/bundler/gems/vagrant-1e28f1ac31e7/plugins/guests/windows/scripts/mount_volume.ps1.erb