Using Chocolatey (a package manager)


  • Senior Developer

    This guide will help you implement chocolatey into FOG (partially).

    [B]What is it?[/B]
    Chocolatey is a package manager for windows ([url]http://chocolatey.org/[/url]). It allows you to run commands like [I]cinst vlc blender[/I] and those programs will be installed silently.

    [B]Why use it?[/B]
    Think of chocolatey as a way to outsource your snapins. Let other people manage and update them. Giving you more time to focus on other parts of your network and ensuring computers get the latest version of a software.
    Not only will it install the latest version of software but it will allow you to update the software on a computer remotely from FOG. You can browser what software chocolatey offers at [url]http://chocolatey.org/packages[/url] (there are 1986 different packages available)

    [B]Limitations[/B]
    Chocolatey downloads and runs installers from the AppData folder of the current user. When using the FOG service, the current user is the System Account. This causes issues with installers that extract files (e.g. vlc or avast). My solution is to download and run the installer from c:\tmp
    Some packages will need to be made specifically for FOG and managed by you, though the majority will not.

    [B]Making a Samba share (only needed if you plan on making custom packages)[/B]
    You will need a samba share to host your custom packages. You may be wondering why just use the apache server to host the packages on the website. The reason is that when using websites to host packages chocolatey requires a nuget server to be running. But when using a folder, or samba share, no additional software or configuration is required.

    Run the following commands on your FOG server
    [code]sudo mkdir /var/www/fog/packages
    sudo mkdir /var/www/fog/packages/bin
    sudo chmod -R 775 /var/www/fog/packages

    sudo apt-get update
    sudo apt-get install samba [/code]

    Then open /etc/samba/smb.conf with your editor of choice (vi, nano, gedit …)

    Find the field 'security = ’ and make sure it is set to 'security = share’
    Find the field 'guest account = ’ and make sure it is set to ‘guest account = nobody’

    Add the following code to the end of the file
    [code]
    [packages]
    path = /var/www/packages
    guest ok = yes
    available = yes
    read only = yes
    browseable = yes
    public = yes
    writable = no[/code]

    /var/www/packages will be used to host your custom packages
    /var/www/bin will be used to host any installers or zips that your packages need

    [B]Making Custom Packages (optional)[/B]
    As mentioned before you will need to make a few packages yourself. I will provide 2 examples, VLC (an exe) and Office 2010 (a zip) and explain how to install an msi
    (Both examples can be downloaded from the attachments)

    [B]If your software does NOT need to be placed in c:\tmp then you can follow the guide here (it will be MUCH simpler)[/B]
    [url]https://github.com/chocolatey/chocolatey/wiki/CreatePackages[/url]

    Before beginning any of these examples you will need to install chocolatey on your machine and download/unzip the appropiate file from the attachments.

    Configuration files
    Each package requires a PACKAGE_NAME.nuspec file with the software’s information. The only fields that really matter are id (the package name used in the command line for cinst, so NO spaces ) and version (the software’s version), but I recommend you set title as well

    VLC (exe files)

    Open …/vlc-packages/tools/chocolateyInstall.ps1 this is the instructions on how to install VLC
    All you need to change for a different initialler are
    [LIST]
    []$packageName to your package name (this will be the thing you put in the id field for the config file)
    [
    ]$url and $url64 If there is no 64bit installer leave the variable as an empty string.
    []$silentArgs the silent switching
    [
    ]$installerFile change ‘vlc-installer.exe’ to be the installation file’s name (can really be anything because this is the location the downloaded file is saved to and ran from)
    [/LIST]
    Once finished, open a terminal as administrator and change your working directory to the PACKAGE_NAME-package and run 'cpack’
    Copy the generated file to /var/www/fog/packages with filezilla or your favorite ftp client

    Office 2010 (zip files)
    If you wish to use any zip files you will need to upload a copy of 7zip command line (7za.exe [url]http://sourceforge.net/projects/sevenzip/files/7-Zip/4.42/7za442.zip/download?use_mirror=superb-dca2&download=[/url]) to /var/www/packages/bin/7za.exe
    Open …/vlc-packages/tools/chocolateyInstall.ps1 this is the instructions on how to install Office 2010
    All you need to change for a different initialler are
    [LIST]
    []$packageName to your package name (this will be the thing you put in the id field for the config file)
    [
    ]$url and $url64 If there is no 64bit installer leave the variable as an empty string.
    []$silentArgs the silent switching
    [
    ]$installerFile32 and $installerFile64 These should be the installer locations. If there is no 64bit installer leave the variable as an empty string and change
    [/LIST]
    [code]
    if ([System.IO.Directory]::Exists(‘C:\Program Files (x86)’)) {
    Start-ChocolateyProcessAsAdmin $silentArgs $installerFile64
    } else {
    Start-ChocolateyProcessAsAdmin $silentArgs $installerFile32
    }
    [/code]
    to
    [code]
    Start-ChocolateyProcessAsAdmin $silentArgs $installerFile32
    [/code]

    Once finished, open a terminal as administrator and change your working directory to the PACKAGE_NAME-package and run 'cpack’
    Copy the generated file to /var/www/fog/packages with filezilla or your favorite ftp client

    MSI files (either zip or standalone file)

    Set $installerFile = 'msiexec.exe’
    Set $silentArgs = ‘/i’ + $tempDir + ‘INSTALLER_NAME.msi /quiet’

    [B]The Snapin Scripts[/B]
    The attached scripts end in .txt so they can be uploaded, remove it once downloaded

    See the attached file ‘BasePackage.cmd’ this is the snapin I deploy to every computer. Custom packages get [I]-source \FOG_IP_ADDRESS\packages[/I] added onto them.
    This script will install chocolatey if it doesn’t already exist and then install all of the software we use, outputing logs in c:\tmp for each software so I can see any errors
    [B]This script does NOT delete the c:\tmp folder once finished[/B]

    As for updating software on computers, see Update.cmd.

    If there are any mistakes/errors in the sample packages please let me know.

    [url="/_imported_xf_attachments/1/1165_office2010-package.zip?:"]office2010-package.zip[/url][url="/_imported_xf_attachments/1/1166_vlc-package.zip?:"]vlc-package.zip[/url][url="/_imported_xf_attachments/1/1168_Update.cmd.txt?:"]Update.cmd.txt[/url][url="/_imported_xf_attachments/1/1169_BasePackage.cmd.txt?:"]BasePackage.cmd.txt[/url]


Log in to reply
 

373
Online

38976
Users

10712
Topics

101675
Posts

Looks like your connection to FOG Project was lost, please wait while we try to reconnect.