Sha256: ef131e5b5b8e9d9eb13f3547bab0e4bbfae6c6df95862f501d8abc2cff906fea

Contents?: true

Size: 1.35 KB

Versions: 22

Compression:

Stored size: 1.35 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.exe /c rd "$MountPoint"

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

}
elseif(Test-Path $MountPoint)
{
  Write-Error "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.exe /c mklink /D "$MountPoint" "$VmProviderUncPath" | out-null

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

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.3.3.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.3.2.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.19.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.18.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.16.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.14.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.10.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.9.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.8.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.7.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.6.2 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.6.1 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.6.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.5.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.4.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.3.0 plugins/guests/windows/scripts/mount_volume.ps1.erb
vagrant-unbundled-2.2.2.0 plugins/guests/windows/scripts/mount_volume.ps1.erb