简体   繁体   English

如何在Chocolatey软件包安装脚本中指定端口?

[英]How do I specify a port in a Chocolatey package install script?

I created a PowerShell script which asks the user whether they want to install Chocolatey and then installs a bunch of applications and moves some files. 我创建了一个PowerShell脚本,该脚本询问用户是否要安装Chocolatey,然后安装一堆应用程序并移动一些文件。

I'm using this on the corporate network and sadly, the proxy settings that we use are posing a problem. 我在公司网络上使用了它,可惜的是,我们使用的代理设置带来了问题。 When I execute the Chocolatey script, it says there's an error and it can't download the package. 当我执行Chocolatey脚本时,它说有一个错误,无法下载该软件包。 The most annoying thing is the error description is "No more data available". 最令人讨厌的是错误描述为“没有更多可用数据”。 So whilst trying to run the script, I ran Wireshark in the background and was told that the script is trying to connect directly to a box, where it shouldn't be and that's why it's being rejected. 因此,在尝试运行脚本时,我在后台运行了Wireshark,并被告知脚本正在尝试直接连接到不应该位于其中的盒子,这就是为什么它被拒绝的原因。

I was told to fix this, I need to force the script to go out of port 80. Which I'm not aware of how to do, so was looking for some advice on how to achieve this. 有人告诉我要解决此问题,我需要强制脚本退出端口80。我不知道该怎么做,因此一直在寻找有关实现此问题的建议。

I would like to think it was just as simple as adding :80 somewhere but, i've tried that and no luck. 我想这就像在某处添加:80一样简单,但是,我已经尝试过了,没有运气。

#-Setting HTTP/S Proxy's-#

write-host "Configuring local proxy settings"
cscript configs\SetProxy_underscore.vbs

function Install-NeededFor {
param(
   [string] $packageName = ''
  ,[bool] $defaultAnswer = $true
)

  if ($packageName -eq '') { return $false }

  $yes = '6'
  $no = '7'
  $msgBoxTimeout='-1'
  $defaultAnswerDisplay = 'Yes'
  $buttonType = 0x4;
  if (!$defaultAnswer) { $defaultAnswerDisplay = 'No'; $buttonType= 0x104; }

  $answer = $msgBoxTimeout
  try {
    $timeout = 10
    $question = "Do you need to install $($packageName)? Defaults to `'$defaultAnswerDisplay`' after $timeout seconds"
    $msgBox = New-Object -ComObject WScript.Shell
    $answer = $msgBox.Popup($question, $timeout, "Install $packageName", $buttonType)
  } catch {
  }

  if ($answer -eq $yes -or ($answer -eq $msgBoxTimeout -and $defaultAnswer -eq $true)) {
    write-host "Installing $packageName"
    return $true
  }

  write-host "Not installing $packageName"
  return $false
}

#-install chocolatey-#

if (Install-NeededFor 'chocolatey') {
  iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1'))
}

choco install dotnet4.5 -y
cinst nuget.commandline -y
cinst chefdk -y
cinst notepadplusplus -y
cinst vagrant -y
cinst vagrant-winrm-config -y
cinst virtualbox -version 4.3.12 -y
choco install virtualbox -version 4.3.12 -y
cinst atom -y
cinst putty -y
cinst winscp -y
cinst conemu -y
cinst launchy -y
cinst everything -y
choco install git.install -y -params '"/GitAndUnixToolsOnPath"'
choco install git-credential-winstore -y

vagrant plugin install vagrant-berkshelf
vagrant plugin install vagrant-proxyconf
vagrant plugin install vagrant-omnibus

Right now the 0.9.9 series doesn't seem to play well with proxies - follow https://github.com/chocolatey/choco/issues/243 to learn about when and what version it is fixed in. Thanks! 目前,0.9.9系列似乎不适用于代理-请关注https://github.com/chocolatey/choco/issues/243,以了解何时以及何时修复该版本。谢谢!

You can also stick with 0.9.8.33 until the fixes are in - we even have a way for you to install the older client - https://github.com/chocolatey/chocolatey.org/issues/162 您也可以坚持使用0.9.8.33,直到修复程序发布为止-我们甚至可以为您提供安装旧客户端的方法-https: //github.com/chocolatey/chocolatey.org/issues/162

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM