f5devcentral / f5-icontrol-powershell-snapin

PowerShell Snapin for F5's iControl SOAP Library
MIT License
8 stars 7 forks source link

Release Chocolatey package #7

Closed spuder closed 1 year ago

spuder commented 8 years ago

It would be great to have this powershell snapin available on the chocolatey market. Installing would be as simple as choco install icontrol.

I don't have distribution rights to publish a chocolatey package.

Here is a basic example (not complete) of what it would take to make a chocolatey package.

https://chocolatey.org/docs/create-packages

icontrol.nuspec

<?xml version="1.0"?>
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <metadata>
    <id>icontrol</id>
    <title>icontrol</title>
    <version>0.1.0.20120822</version>
    <authors>spuder</authors>
    <owners>spuder</owners>
    <summary>unoffical icontrol snapin and powershell commands</summary>
    <description>Unoffical icontrol snapin installer</description>
    <projectUrl>http://www.example.com</projectUrl>
    <tags>f5, icontrol</tags>
    <requireLicenseAcceptance>false</requireLicenseAcceptance> <!-- or true if you require the user to accept the License before installing -->
  </metadata>
</package>

tools/chocolateyInstall.ps1

Install-ChocolateyZipPackage -PackageName 'icontrol' `
 -Url 'https://devcentral.f5.com/d/microsoft-powershell-with-icontrol?download=true' `
 -UnzipLocation "c:\program files\f5 networks" `
 -ChecksumType 'sha256' `
 -Checksum 'C4842C03272EF9858757A050E1F482D401B672595CDBC9D41013E14523ADA89F'

Then run the following commands

cpack
choco install icontrol -fdv -s .
spuder commented 7 years ago

This is still very much needed.

Until an official chocolatey package is available, we've worked around with a chef cookbook.

default['f5-snapin']['source'] = 'https://artifact.repository.example.com/f5-icontrol-powershell-snapin-12_1_0.zip'
directory 'c:/program files/f5 networks' do
  action :create
end

windows_zipfile 'c:/program files/f5 networks' do
  source node['f5-snapin']['source']
  not_if { ::File.exist?('c:/program files/f5 networks/iControl.dll') }
end

template 'c:/program files/f5 networks/setupSnapIn.ps1' do
  source 'setupSnapin.ps1.erb'
  action :create
end

powershell_script 'register snapin' do
  cwd 'c:/program files/f5 networks'
  code <<-EOH
  ./setupSnapin.ps1
  EOH
  action :run
end
param([switch]$force)

function Is-SnapinRegistered()
{
  $registered = $false;
  if ( $null -ne (Get-PSSnapIn -Registered | where { $_.Name -eq "iControlSnapIn" } ) )
  {
    $registered = $true;
  }
  $registered;
}

function Install-Snapin()
{
  param(
    [string]$assembly = $null
  );

  foreach ($platform in ("", "64") )
  {
    Write-Host "Registering $assembly on platform '$platform'";
    if ( Test-Path "$env:windir\Microsoft.Net\Framework${platform}\v4.0.30319" )
    {
      Write-Host '.NET v4 present'
      $installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v4.0.30319\installUtil.exe";
    }
    ElseIf ( Test-Path "$env:windir\Microsoft.Net\Framework${platform}\v3.5" )
    {
      Write-Host '.NET v3.5 present'
      $installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v3.5\installUtil.exe";
    }
    ElseIf ( Test-Path "$env:windir\Microsoft.Net\Framework${platform}\v3.0" )
    {
      Write-Host '.NET v3.0 present'
      $installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v3.0\installUtil.exe";
    }
    ElseIf ( Test-Path "$env:windir\Microsoft.Net\Framework${platform}\v2.0.507272" )
    {
      Write-Host '.NET v2 present'
      $installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v2.0.50727\installUtil.exe";
    }
    Else
    {
      Write-Host 'Could not find any version of .NET >=2 and <=4'
      Exit 1
    }

    if ( [System.IO.File]::Exists($installUtil) )
    {
      Set-Alias installUtil $installUtil;
      installUtil $assembly /LogToConsole=false /LogFile=;
    }
  }
}

function Remove-Snapin()
{
  param(
    [string]$assembly = $null
  );

  foreach ($platform in ("", "64") )
  {
    Write-Host "Unregistering $assembly on platform '$platform'";
    $installUtil = "$env:windir\Microsoft.Net\Framework${platform}\v2.0.50727\installUtil.exe";
    if ( [System.IO.File]::Exists($installUtil) )
    {
      Set-Alias installUtil $installUtil;
      installUtil /u $assembly /LogToConsole=false /LogFile=;
    }
  }
}

if ( ($force) -or !(Is-SnapinRegistered) )
{
  Install-Snapin -assembly iControlSnapin.dll;
}
else
{
  Write-Host "iControlSnapIn already registered..."
}
adam-f5 commented 1 year ago

Repository Archived