0% found this document useful (0 votes)
25 views

How To Setup Chocolatey Package Locally and Download It On The Client's Machine

Uploaded by

sharmaguyz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

How To Setup Chocolatey Package Locally and Download It On The Client's Machine

Uploaded by

sharmaguyz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

How to setup Chocolatey Package

8/25/2024
Locally and download it on the
client's machine
Table of Contents
Prerequisites....................................................................................................................................... 1
Install and Configure Nexus Repository Manager on Ubuntu .......................................................... 1
How to configure the nexus package repository for the Chocolatey server on Linux ..................... 4
Installation of Choco command line utility ..................................................................................... 11
Download and Save Packages (Skype and WinRAR) locally ........................................................... 11
Create Skype Choco Package manually ........................................................................................... 11
Create WinRAR Choco Package manually ....................................................................................... 12
Install package on client’s machine ................................................................................................. 13

Prerequisites

 A server running Ubuntu 20.04.


 A root password configured for the server.

Install and Configure Nexus Repository Manager on Ubuntu

1. Update your system packages to the latest version:

apt-get update -y

2. Nexus requires Java. Install Java 17:

apt-get install openjdk-17-jdk -y

Verify the Java installation:

java -version

3. Install Nexus
o Create a separate user to run Nexus:

useradd -M -d /opt/nexus -s /bin/bash -r nexus

o Edit the sudoers file to allow the nexus user to execute commands without a
password:

echo "nexus ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nexus

o Create Nexus Directory and Download Nexus

mkdir /opt/nexus

1
Download the latest version of Nexus. (Replace the URL with the latest
version if necessary):

wget https://sonatype-
download.global.ssl.fastly.net/repository/downloads-prod-
group/3/nexus-3.29.2-02-unix.tar.gz

Extract the downloaded file to /opt/nexus:

tar xzf nexus-3.29.2-02-unix.tar.gz -C /opt/nexus --strip-


components=1

o Set the proper ownership for the Nexus directory:

chown -R nexus:nexus /opt/nexus

o Configure Nexus

Edit the nexus.vmoptions file to define the maximum memory size:

nano /opt/nexus/bin/nexus.vmoptions

Add or update the following settings:

-Xms1024m
-Xmx1024m
-XX:MaxDirectMemorySize=1024m
-XX:LogFile=./sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-
Djava.util.logging.config.file=/etc/karaf/java.util.logging.pro
perties
-Dkaraf.data=./sonatype-work/nexus3
-Dkaraf.log=./sonatype-work/nexus3/log
-Djava.io.tmpdir=./sonatype-work/nexus3/tmp

Save and close the file.

Edit the nexus.rc file to set the user to run Nexus:

nano /opt/nexus/bin/nexus.rc

Uncomment and change the following line:

run_as_user="nexus"

Save and close the file.

o Start the Nexus service:

2
sudo -u nexus /opt/nexus/bin/nexus start

Verify Nexus is running:

tail -f /opt/nexus/sonatype-work/nexus3/log/nexus.log

Check if Nexus is listening on port 8081:

ss -altnp | grep 8081

4. Access Nexus Web Interface

Print the Nexus admin password:

cat /opt/nexus/sonatype-work/nexus3/admin.password

Access the Nexus web UI at http://<your-server-ip>:8081 using the admin


password.

5. Run Nexus as a Systemd Service


o Create a Systemd Service File

Create a new service file for Nexus:

sudo nano /etc/systemd/system/nexus.service

Add the following content:

[Unit]
Description=Nexus Repository Manager
Documentation=http://help.sonatype.com/
After=network.target

[Service]
Type=forking
User=nexus
Group=nexus
ExecStart=/usr/bin/sudo -u nexus /opt/nexus/bin/nexus start
ExecStop=/usr/bin/sudo -u nexus /opt/nexus/bin/nexus stop
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Save and close the file.

o Reload Systemd and Start Nexus

Reload the systemd manager:

sudo systemctl daemon-reload

Start and enable the Nexus service:

3
sudo systemctl start nexus.service
sudo systemctl enable nexus.service

Check the status of the Nexus service:

sudo systemctl status nexus.service

How to configure the nexus package repository for the Chocolatey server on Linux

Open the web url on browser and login with credential


http://45.149.204.152:8081/#browse/welcome

Click on the setting option and go to repository.

4
Click on the Create Repository.

5
We will work on the below 3 Nuget repositories for the chocolatey server

First, we will create nugget(proxy)click on this.

Filled the highlighted fields and remain other fields default after that click on the create
repository.

6
7
Now we will create another repository that is nuget(hosted) go to create a repository and click
on it.

Click on the nuget(hosted)that is highlighted

8
Filed the nubet(hosted) repo name and remain other fields as defaults

Now go to Create Repositories page and click on it

Click on nugget(group)

9
Now add the name of the group e.g (chocolatey-group) and add the chocolatey-hosted and
chocolatey-group in the members list and create repository.

10
Now your Nexus Chocolatey server setup is completed

Installation of Choco command line utility

Go to your window client powershell and install choco command line utility with the
following command:
Set-ExecutionPolicy Bypass -Scope Process -Force;
[System.Net.ServicePointManager]::SecurityProtocol =
[System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-
Object
System.Net.WebClient).DownloadString('https://community.chocolatey.org/inst
all.ps1'))
Add Choco source in your window PowerShell using the below commands:-
Choco source

Remove the public repo of Chocolatey


choco source remove -n=chocolatey

Add the private source in the window client


choco source add -n=chocolatey-group -s
"'http://45.149.204.152:8081/repository/chocolatey-group/'" -u=admin -
p=<your-password> --priority=1

choco source list

Download and Save Packages (Skype and WinRAR) locally


Take the SSH of the server and run the below commands
Install the Webserver as NginX
apt-get update
apt-get install nginx –y
systemctl enable nginx

Save the Skype and WinRAR packages locally in the webserver


cd /var/www/html
wget https://www.win-rar.com/fileadmin/downloads/wrar_700_64bit.msi
mv wrar_700_64bit.msi winrar.msi

wget https://download.skype.com/s4l/download/win/Skype-8.126.0.208.msi
mv Skype-8.126.0.208.msi skype.msi

Create Skype Choco Package manually


Go to window PowerShell and run the below command
choco new skype
cd skype

11
edit the skype.nuspec file and update the version in line 29 as you want from
<version>__REPLACE__</version> to <version>8.126.0</version>
Now edit the file skype\tools\chocolateyinstall.ps1 and replace all the content with the
below one
$ErrorActionPreference = 'Stop'

$packageArgs = @{

packageName = $env:ChocolateyPackageName

softwareName = 'Skype*'

fileType = 'msi'

url = 'http://45.149.204.152/skype.msi'

checksum =
'e5c41e2fc70c03bfbee324272eaa1d702961a19111c303ab3e17d862a11e0f3c'

checksumType = 'sha256'

silentArgs = "/quiet /norestart /l*v


`"$($env:TEMP)\$($packageName).$($env:chocolateyPackageVersion).MsiInstall.
log`""

validExitCodes = @(0)

Install-ChocolateyPackage @packageArgs

Now pack the package with the command


choco pack skype.nuspec

It will create the new package in the skype directory with the name skype.8.126.0.nupkg
Now open the Nexus repository on the browser where you can upload packages on the left-
hand side. Upload the package skype.8.126.0.nupkg.
That uploaded package to the chocolatey-group repository

Create WinRAR Choco Package manually


Go to window PowerShell and run the below command
choco new winrar
cd winrar

edit the winrar.nuspec file and update the version in line 29 as you want from
<version>__REPLACE__</version> to <version>7.0.0</version>
Now edit the file winrar\tools\chocolateyinstall.ps1. Update the URL(line 18) and
filetype(line 24)
$url = 'http://45.149.204.152/winrar.msi' # download url, HTTPS
preferred

12
fileType = 'msi' #only one of these: exe, msi, msu

Now pack the package with the command


choco pack winrar.nuspec

It will create the new package in the winrar directory with the name winrar.7.0.0.nupkg
Now open the Nexus repository on the browser where you can upload packages on the left-
hand side. Upload the package winrar.7.0.0.nupkg.
That uploaded package to the chocolatey-group repository

Install package on client’s machine

Check the repository with the below command whether there is a public or private one
choco source

If there is a chocolatey repository, which you can see the name of at the start of the output,
then you can delete it with this command:
choco source remove -n=chocolatey

Add the nexus repository with the below command


choco source add -n=chocolatey-group -s
"'http://45.149.204.152:8081/repository/chocolatey-group/'" -u=admin -
p=<your-password> --priority=1

Verify the repository by running the below command


choco source

Install the Skype package with the below command


Syntax: choco install <package_name>

Enable-TlsCipherSuite -Name TLS_CHACHA20_POLY1305_SHA256


choco install skype -Version 8.126.0

Install the WinRAR package with the below command


Enable-TlsCipherSuite -Name TLS_CHACHA20_POLY1305_SHA256
choco install winrar -Version 7.0.0

13

You might also like