diff --git a/Downloader.ps1 b/Downloader.ps1 index f0b8fb4..01dc920 100644 --- a/Downloader.ps1 +++ b/Downloader.ps1 @@ -1,7 +1,47 @@ -# Read configuration from JSON file +# Writes out OlaYZen's Name + +write-host "|============================================|" +write-host "|=------------------------------------------=|" +write-host "|============================================|" +write-host "| |" +write-host "| |" +write-host "| YYYY YYYYZZZZZZZZZZZZZZZZZZZZZ |" +write-host "| Y::Y Y::::::::::::::::::::::::Z |" +write-host "| Y::Y Y::YZZZZZZZZZZZZZZZZZZZ:::Z |" +write-host "| Y::Y Y::Y Z:::Z |" +write-host "| Y:::Y Y:::Y Z:::Z |" +write-host "| Y:::Y Y:::Y Z:::Z |" +write-host "| Y:::Y:::Y Z:::Z |" +write-host "| Y:::::Y Z:::Z |" +write-host "| Y:::Y Z:::Z |" +write-host "| Y:::Y Z:::Z |" +write-host "| Y:::Y Z:::Z |" +write-host "| Y:::Y Z:::Z |" +write-host "| Y:::Y Z:::Z |" +write-host "| Y:::Y Z:::ZZZZZZZZZZZZZZZZ |" +write-host "| Y:::Y Z:::::::::::::::::::Z |" +write-host "| YYYYY ZZZZZZZZZZZZZZZZZZZZZ |" +write-host "| |" +write-host "| |" +write-host "|============================================|" +write-host "|=------------------------------------------=|" +write-host "|= made by OlaYZen =|" +write-host "|=------------------------------------------=|" +write-host "|============================================|" +write-host " " + +# Read configuration from JSON file $configPath = "$PSScriptRoot\config.json" $config = Get-Content -Path $configPath | ConvertFrom-Json +if($config.license){ + # Writes out the license to the end user + $copyrightUrl = "https://forgejo.olayzen.com/OlaYZen/MSI-Downloader/raw/branch/main/LICENSE" + $copyrightResponse = Invoke-WebRequest -Uri $copyrightUrl + $copyrightContent = $copyrightResponse.Content + Write-Host $copyrightContent +} + $chromeNaming = $config.chrome.options.folderName $workspacesNaming = $config.amazonWorkspace.options.folderName @@ -41,6 +81,11 @@ if (-not $amazonworkspacelogFileFormat) { $amazonworkspacelogFileNameFormat = $amazonworkspacelogFileName+"."+$amazonworkspacelogFileFormat +# Define template name +$ctRegular = $config.chrome.template.templateFolderNameRegular +$ctForced = $config.chrome.template.templateFolderNameForced +$wt = $config.amazonWorkspace.template.templateFolderName + if ($config.chrome.logging.clearLogs) { # Construct the full path to the log file $logFilePathchrome = Join-Path -Path $PSScriptRoot -ChildPath $chromelogFileNameFormat @@ -75,6 +120,122 @@ function amazonworkspace-Log-Message { } } +if (-not $ctRegular) { + $ctRegular = "Chrome-Template" +} + +if (-not $ctForced) { + $ctForced = "Chrome-Template-Forced" +} + +if (-not $wt) { + $wt = "Amazon-Workspace-Template" +} + +if ($config.debug){ + if($config.chrome.logging.logName -eq $config.amazonWorkspace.logging.logName){ + if($config.chrome.logging.logFormat -eq $config.amazonWorkspace.logging.logFormat){ + chrome-Log-Message "Debug: |============================================|" + chrome-Log-Message "Debug: |=------------------------------------------=|" + chrome-Log-Message "Debug: |============================================|" + chrome-Log-Message "Debug: | |" + chrome-Log-Message "Debug: | |" + chrome-Log-Message "Debug: | YYYY YYYYZZZZZZZZZZZZZZZZZZZZZ |" + chrome-Log-Message "Debug: | Y::Y Y::::::::::::::::::::::::Z |" + chrome-Log-Message "Debug: | Y::Y Y::YZZZZZZZZZZZZZZZZZZZ:::Z |" + chrome-Log-Message "Debug: | Y::Y Y::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Z:::ZZZZZZZZZZZZZZZZ |" + chrome-Log-Message "Debug: | Y:::Y Z:::::::::::::::::::Z |" + chrome-Log-Message "Debug: | YYYYY ZZZZZZZZZZZZZZZZZZZZZ |" + chrome-Log-Message "Debug: | |" + chrome-Log-Message "Debug: | |" + chrome-Log-Message "Debug: |============================================|" + chrome-Log-Message "Debug: |=------------------------------------------=|" + chrome-Log-Message "Debug: |= made by OlaYZen =|" + chrome-Log-Message "Debug: |=------------------------------------------=|" + chrome-Log-Message "Debug: |============================================|" + + chrome-Log-Message "Debug: Log files share the same name '$chromelogFileNameFormat'" + } + } else { + chrome-Log-Message "Debug: |============================================|" + chrome-Log-Message "Debug: |=------------------------------------------=|" + chrome-Log-Message "Debug: |============================================|" + chrome-Log-Message "Debug: | |" + chrome-Log-Message "Debug: | |" + chrome-Log-Message "Debug: | YYYY YYYYZZZZZZZZZZZZZZZZZZZZZ |" + chrome-Log-Message "Debug: | Y::Y Y::::::::::::::::::::::::Z |" + chrome-Log-Message "Debug: | Y::Y Y::YZZZZZZZZZZZZZZZZZZZ:::Z |" + chrome-Log-Message "Debug: | Y::Y Y::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Z:::Z |" + chrome-Log-Message "Debug: | Y:::Y Z:::ZZZZZZZZZZZZZZZZ |" + chrome-Log-Message "Debug: | Y:::Y Z:::::::::::::::::::Z |" + chrome-Log-Message "Debug: | YYYYY ZZZZZZZZZZZZZZZZZZZZZ |" + chrome-Log-Message "Debug: | |" + chrome-Log-Message "Debug: | |" + chrome-Log-Message "Debug: |============================================|" + chrome-Log-Message "Debug: |=------------------------------------------=|" + chrome-Log-Message "Debug: |= made by OlaYZen =|" + chrome-Log-Message "Debug: |=------------------------------------------=|" + chrome-Log-Message "Debug: |============================================|" + amazonworkspace-Log-Message "Debug: |============================================|" + amazonworkspace-Log-Message "Debug: |=------------------------------------------=|" + amazonworkspace-Log-Message "Debug: |============================================|" + amazonworkspace-Log-Message "Debug: | |" + amazonworkspace-Log-Message "Debug: | |" + amazonworkspace-Log-Message "Debug: | YYYY YYYYZZZZZZZZZZZZZZZZZZZZZ |" + amazonworkspace-Log-Message "Debug: | Y::Y Y::::::::::::::::::::::::Z |" + amazonworkspace-Log-Message "Debug: | Y::Y Y::YZZZZZZZZZZZZZZZZZZZ:::Z |" + amazonworkspace-Log-Message "Debug: | Y::Y Y::Y Z:::Z |" + amazonworkspace-Log-Message "Debug: | Y:::Y Y:::Y Z:::Z |" + amazonworkspace-Log-Message "Debug: | Y:::Y Y:::Y Z:::Z |" + amazonworkspace-Log-Message "Debug: | Y:::Y:::Y Z:::Z |" + amazonworkspace-Log-Message "Debug: | Y:::::Y Z:::Z |" + amazonworkspace-Log-Message "Debug: | Y:::Y Z:::Z |" + amazonworkspace-Log-Message "Debug: | Y:::Y Z:::Z |" + amazonworkspace-Log-Message "Debug: | Y:::Y Z:::Z |" + amazonworkspace-Log-Message "Debug: | Y:::Y Z:::Z |" + amazonworkspace-Log-Message "Debug: | Y:::Y Z:::Z |" + amazonworkspace-Log-Message "Debug: | Y:::Y Z:::ZZZZZZZZZZZZZZZZ |" + amazonworkspace-Log-Message "Debug: | Y:::Y Z:::::::::::::::::::Z |" + amazonworkspace-Log-Message "Debug: | YYYYY ZZZZZZZZZZZZZZZZZZZZZ |" + amazonworkspace-Log-Message "Debug: | |" + amazonworkspace-Log-Message "Debug: | |" + amazonworkspace-Log-Message "Debug: |============================================|" + amazonworkspace-Log-Message "Debug: |=------------------------------------------=|" + amazonworkspace-Log-Message "Debug: |= made by OlaYZen =|" + amazonworkspace-Log-Message "Debug: |=------------------------------------------=|" + amazonworkspace-Log-Message "Debug: |============================================|" + } + + +chrome-Log-Message "Debug: ctRegular set to '$ctRegular'" +chrome-Log-Message "Debug: ctForced set to '$ctForced'" +amazonworkspace-Log-Message "Debug: wt set to '$wt'" + +chrome-Log-Message "Debug: folderName set to '$chromeNaming'" +amazonworkspace-Log-Message "Debug: folderName set to '$workspacesNaming'" + + +} + # Check if both options are disabled and log a message if (-not $config.chrome.options.downloadRegular -and -not $config.chrome.options.downloadForced -and -not $config.amazonWorkspace.options.download) { chrome-Log-Message "Warn: Neither Chrome or Amazon Workspaces is selected. Please enable at least one option to proceed." @@ -83,17 +244,17 @@ if (-not $config.chrome.options.downloadRegular -and -not $config.chrome.options # Log the start of the script if ($config.amazonWorkspace.logging.logName -eq $config.chrome.logging.logName) { - chrome-Log-Message "Debug: Script started" + chrome-Log-Message "Info: Script started" } else { if ($config.chrome.options.downloadRegular) { - chrome-Log-Message "Debug: Script started" + chrome-Log-Message "Info: Script started" } elseif ($config.chrome.options.downloadForced) { - chrome-Log-Message "Debug: Script started" + chrome-Log-Message "Info: Script started" } if ($config.amazonWorkspace.options.download) { - amazonworkspace-Log-Message "Debug: Script started" + amazonworkspace-Log-Message "Info: Script started" } } @@ -144,9 +305,9 @@ $chrome32BitUrl = "https://dl.google.com/dl/chrome/install/googlechromestandalon $amazonworkspace64BitUrl = "https://d2td7dqidlhjx7.cloudfront.net/prod/global/windows/Amazon+WorkSpaces.msi" # Define source and destination folders -$sourceFolderRegular = "$PSScriptRoot\Template\Chrome-Template" -$sourceFolderForced = "$PSScriptRoot\Template\Chrome-Template-Forced" -$amazonworkspacesourceFolderRegular = "$PSScriptRoot\Template\Amazon-Workspace-Template" +$sourceFolderRegular = "$PSScriptRoot\Template\$ctRegular" +$sourceFolderForced = "$PSScriptRoot\Template\$ctForced" +$amazonworkspacesourceFolderRegular = "$PSScriptRoot\Template\$wt" $destinationFolder = Join-Path -Path $PSScriptRoot -ChildPath "$chromeNaming VERSION" $forceUpdateFolder = Join-Path -Path $PSScriptRoot -ChildPath "$chromeNaming VERSION_force_update" diff --git a/README.md b/README.md index 265bd27..782a61b 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,14 @@ The `config.json` file should be structured as follows: "folderName": "Chrome -" }, "logging": { - "fileName": "google_chrome", - "fileFormat": "log", + "logName": "google_chrome", + "logFormat": "log", "logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss", "clearLogs": false + }, + "template": { + "templateFolderNameRegular": "Chrome-Template", + "templateFolderNameForced": "Chrome-Template-Forced" } }, "amazonWorkspace":{ @@ -39,8 +43,13 @@ The `config.json` file should be structured as follows: "logFormat": "log", "logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss", "clearLogs": false + }, + "template": { + "templateFolderName": "Amazon-Workspace-Template" } - } + }, + "license": true, + "debug": false } ``` #### Options: @@ -59,6 +68,8 @@ The `config.json` file should be structured as follows: - `folderNumber`: A boolean flag to enable the automatic renaming of the folder to the newest version of Chrome. ⚠️ **This option requires administrative privileges when executing the script!** ⚠️ - `checkExist`: A boolean flag to delete old Chrome folders when the script is executed. ⚠️ **This action will delete your Chrome folders, so ensure you have backups if you wish to retain them.** ⚠️ - `folderName`: A string defining the name of the folders. The default name is `Chrome -` and `WorkSpaces -`. +- `license`: A boolean flag to enable/disable the MIT license showing on script start. +- `debug`: A boolean flag to enable/disable debugging in the logs. #### Logging options: --- @@ -67,6 +78,12 @@ The `config.json` file should be structured as follows: - `logDateFormat`: A string defining the format of timestamps in logs. The default format is `dd/MM/yyyy HH:mm:ss`. - `clearLogs`: A boolean flag to enable clearing of the log(s) file(s). This will clear the content inside of the log file(s). +#### Template options: +--- +- `templateFolderNameRegular`: A string defining the name of the regular GoogleChrome template folder name. +- `templateFolderNameForced`: A string defining the name of the forced Google Chrome template folder name. +- `templateFolderName`: A string defining the name of Amazon WorkSpaces template folder name. + ### Date Configuration --- @@ -92,6 +109,8 @@ The `config.json` file should be structured as follows: ##### `ss`: This specifier represents the second portion of the time. It uses two digits to represent the seconds, with leading zeros if necessary. For example, 45. +##### `fff`: This specifier represents the millisecond portion of the time. It uses three digits to represent the milliseconds, with leading zeros if necessary. For example, 123. + ##### `tt`: This specifier represents the AM/PM designator in a 12-hour time format. It is typically used alongside the hh specifier to indicate whether the time is in the AM or PM. For example, AM or PM. ### Examples diff --git a/config.json b/config.json index de3f925..0278c04 100644 --- a/config.json +++ b/config.json @@ -12,6 +12,10 @@ "logFormat": "log", "logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss", "clearLogs": false + }, + "template": { + "templateFolderNameRegular": "Chrome-Template", + "templateFolderNameForced": "Chrome-Template-Forced" } }, "amazonWorkspace":{ @@ -26,6 +30,11 @@ "logFormat": "log", "logDateFormat": "dd'/'MM'/'yyyy HH:mm:ss", "clearLogs": false + }, + "template": { + "templateFolderName": "Amazon-Workspace-Template" } - } + }, + "license": true, + "debug": false } \ No newline at end of file