-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updating install.bat to allow installation from local path on windows #111
base: master
Are you sure you want to change the base?
Conversation
@@ -214,7 +214,7 @@ def fetch_or_create_install_script(env) | |||
set version=%1 | |||
set dest=%~dp0chef-client-%version%-1.windows.msi | |||
echo Downloading Chef %version% for Windows... | |||
powershell -command "(New-Object System.Net.WebClient).DownloadFile('#{url}?v=%version%', '%dest%')" | |||
powershell -command "if(test-path '#{url}/chef-client*%version%*.msi'){[array]$tempstore = dir #{url} | ?{$_.name -like 'chef-client*%version%*.msi'};copy $tempstore[0].fullname %dest%}else{(New-Object System.Net.WebClient).DownloadFile('#{url}?v=%version%', '%dest%')}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would do something like
[uri]$uri='#{url}';switch -regex ($uri.scheme){('http(s*)'{$source='#{url}v=%version%'}'default{[$source=(resolve-path (join-path '#{url}' 'chef-client*%version%*.msi')).path)} };(new-object Net.Webclient).DownloadFile(([uri]$source).absoluteuri, '%dest%')}
for the PowerShell command. Casting it to a URI allows you to determine if it is http(s) or a file path (or no scheme if it is a partial path), then you can determine how to append the version details. Using join-path and resolve-path can assemble the file or unc path appropriately and the casting the result of that to a uri allows either the http or file scheme to be used with webclient (no need to switch back and forth between copy or webclient download.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URI exactly what I was looking for. I figured there is a single construct that allows for both. Big thanks, I'll play with it and amend the pull request. Also, I didnt know web-client can download local files via URI :) live and learn.
Gents, let me know when you have something to test. I'm trying to have this setup work in kitchen to avoid downloading the msi from the internet.
|
Vagrant is not showing this 'vagrant-omnibus' plugin for me. Is it shipped with kitchen?
|
@alexpop I dont think vagrant-omnibus is shipps with chefdk or kitchen. I just add it via The code in my original pull request works - though it's intended for windows only. It's actually what I'm using at the moment to get my 2k8 vagrant instances updated. config.vm.synced_folder '~/Documents/ISO_BOX_etc/binaries', "c:/parent_binaries"
config.omnibus.install_url = 'c:\\parent_binaries\\chef_client' I suspect for Linux instances below will work w/o any changes (it's what's in the read me right now) config.omnibus.install_url = '/some/local/path' |
No, vagrant-omnibus is not shipped nor used by Test Kitchen, see my comment here for more details. |
please take a look @smurawski
note: i couldn't make the powershell block pretty, seems as if tac (`) doesn't work as a carriage return escape with -command or perhaps ruby is eating.. dunno