Skip to content

Commit

Permalink
create install script example
Browse files Browse the repository at this point in the history
  • Loading branch information
jgstew committed Jul 7, 2024
1 parent 240b8b0 commit c1d5e5d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Mozilla/Firefox-Win.ChocolateyPackager.recipe.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# https://download.mozilla.org/?product=firefox-latest-ssl&os=osx&lang=en-US
---
Description: Creates an choco package for the latest version of Firefox
Description: Creates an choco package for the latest version of Firefox - Only runs on Windows
Identifier: com.github.jgstew.ChocolateyPackager.Firefox-Win64
Input:
NAME: "Firefox"
Expand All @@ -12,6 +11,7 @@ Input:
MinimumVersion: "2.3"
ParentRecipe: com.github.jgstew.download.Firefox-Win64
Process:
# The following processor is windows only:
- Processor: ChocolateyPackager
Arguments:
id: "%NAME%"
Expand Down
26 changes: 26 additions & 0 deletions Mozilla/Firefox-Win.installscript.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# URL of the file to download
$url = "{{download_url}}"

# Expected SHA256 hash of the file (replace with your actual hash)
$expectedHash = "{{file_sha256}}"

# Path where the downloaded file will be saved
$outputFile = "C:\Windows\Temp\{{file_name}}"

# Download the file
Invoke-WebRequest -Uri $url -OutFile $outputFile

# Calculate the actual SHA256 hash of the downloaded file
$actualHash = Get-FileHash -Path $outputFile -Algorithm SHA256 | Select-Object -ExpandProperty Hash

# Compare the actual and expected hashes
if ($actualHash -eq $expectedHash) {
Write-Output "Hashes match. Proceeding to execute the file."

# Execute the downloaded file
Start-Process -FilePath $outputFile -ArgumentList "/S"
} else {
Write-Output "Hashes do not match. The downloaded file may be corrupted or tampered with."
# You can choose to delete the downloaded file in case of hash mismatch
# Remove-Item -Path $outputFile
}
25 changes: 25 additions & 0 deletions Mozilla/Firefox-Win.installscript.recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# https://download.mozilla.org/?product=firefox-latest-ssl&os=osx&lang=en-US
---
Description: Creates an installscript for the latest version of Firefox
Identifier: com.github.jgstew.installscript.Firefox-Win64
Input:
NAME: "Firefox"
product: firefox-latest-ssl
OS: win64
filename: FirefoxSetup.exe
# https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=en-US
# https://download.mozilla.org/?product=firefox-msi-latest-ssl&os=win64&lang=en-US
MinimumVersion: "2.3"
ParentRecipe: com.github.jgstew.download.Firefox-Win64
Process:
- Processor: com.github.jgstew.SharedProcessors/TemplateDictionaryAppend
Arguments:
dictionary_name: template_dictionary
append_key: download_url
append_value: "%download_url%"

# create InstallFirefox.ps1 from template
- Processor: com.github.jgstew.SharedProcessors/ContentFromTemplate
Arguments:
template_file_path: "./Mozilla/Firefox-Win.installscript.ps1"
content_file_pathname: "%RECIPE_CACHE_DIR%/InstallFirefox.ps1"

0 comments on commit c1d5e5d

Please sign in to comment.