Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdesk: Upgrade/Update hangs #58

Open
jkirk opened this issue Sep 9, 2024 · 18 comments
Open

rustdesk: Upgrade/Update hangs #58

jkirk opened this issue Sep 9, 2024 · 18 comments

Comments

@jkirk
Copy link
Contributor

jkirk commented Sep 9, 2024

When updating rustdesk (from 1.2.3 to 1.2.6) the installation hangs:

  PS C:\WINDOWS\system32> choco upgrade -y all
  Chocolatey v2.2.2
  Upgrading the following packages:
  all
  By upgrading, you accept licenses for the packages.

  You have 7zip.install v23.1.0 installed. Version 24.8.0 is available based on your source(s).
  [...]
  rustdesk.install v1.2.6 [Approved]
  rustdesk.install package files upgrade completed. Performing other installation steps.
  Downloading rustdesk.install
    from 'https://github.com/rustdesk/rustdesk/releases/download/1.2.6/rustdesk-1.2.6-x86_64.exe'
  Progress: 100% - Completed download of \\NAS\Software\chococache\rustdesk.install\1.2.6\rustdesk-1.2.6-x86_64.exe (20.45 MB).
  Download of rustdesk-1.2.6-x86_64.exe (20.45 MB) completed.
  Hashes match.
  Installing rustdesk.install...

After some time I pressed CTRL-C a few times, which aborted the whole chocolatey process and I restarted the upgrade (but rustdesk was at the latest version):

  PS C:\WINDOWS\system32> choco upgrade -y all
  Chocolatey v2.3.0
  Upgrading the following packages:
  all
  By upgrading, you accept licenses for the packages.
  [...]
  rustdesk.install v1.2.6 is the latest version available based on your source(s).

JFYI, I have a cacheLocation set on a NAS:

  PS C:\WINDOWS\system32> choco config get --name cacheLocation
  Chocolatey v1.3.1
  \\NAS\Software\chococache

I ran choco upgrade -y all on the system remotely (via Rustdesk).

I am currently not 100% sure, but when I call choco upgrade directly on the system I usually stop the rustdesk service to complete the update successfully. I couldn't do that this time, obviously.

So I think there is a problem when the service is running.

@bdukes
Copy link
Owner

bdukes commented Sep 9, 2024

Yes, I'd love to resolve the issue with the installer hanging. Stopping the service may help, though the install on a clean environment sometimes hangs as well (see the failed testing results for version 1.3.0). I don't have a lot of time to invest in tracking these issues down, but would definitely welcome any contribution to address the problem.

@jkirk
Copy link
Contributor Author

jkirk commented Sep 10, 2024

Just stumbled over this documentation: https://rustdesk.com/docs/en/client/windows/msi/

Quoting the examples:

Caution: For versions prior to 2024-08-05, there are issues with silent installation and silent repair. Please uninstall first, then install.

As far as I can see, this applies to versions prior 1.3.0 which means there are problems with the silent installation of 1.2.7 and below. I haven't checked and tested the new(?) installation parameters, but it might make sense to implement that in the chocolatey installer (including the uninstall + install process - if that is possible within a choco package).

@jkirk
Copy link
Contributor Author

jkirk commented Sep 22, 2024

Looking at #59, it might make sense to also switch to the MSI installation for rustdesk?

Anyway, I think I made some progress. I first installed rustdesk 1.2.3.2 (in a Windwos 10 VirtualBox VM) and installed/started the service:

PS C:\Windows\system32> choco install -y --version 1.2.3.2 rustdesk.install
Chocolatey v2.3.0
Installing the following packages:
rustdesk.install
By installing, you accept licenses for the packages.
Downloading package from source 'https://community.chocolatey.org/api/v2/'
Progress: Downloading rustdesk.install 1.2.3.2... 100%

rustdesk.install v1.2.3.2 [Approved]
rustdesk.install package files install completed. Performing other installation steps.
Downloading rustdesk.install
  from 'https://github.com/rustdesk/rustdesk/releases/download/1.2.3-2/rustdesk-1.2.3-2-x86_64.exe'
Progress: 100% - Completed download of C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.2.3.2\rustdesk-1.2.3-2-x86_64.exe (19.71 MB).
Download of rustdesk-1.2.3-2-x86_64.exe (19.71 MB) completed.
Hashes match.
Installing rustdesk.install...
rustdesk.install has been installed.
  rustdesk.install may be able to be automatically uninstalled.
 The install of rustdesk.install was successful.
  Deployed to 'C:\Program Files\RustDesk'

Chocolatey installed 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

PS C:\Windows\system32> & "C:\Program Files\RustDesk\RustDesk.exe" --install-service

I then updated rustdesk like so:

PS C:\Windows\system32> & "C:\Program Files\RustDesk\RustDesk.exe" --uninstall-service; choco install -y --version 1.3.1 rustdesk.install; & "C:\Program Files\RustDesk\RustDesk.exe" --install-service
Chocolatey v2.3.0
Installing the following packages:
rustdesk.install
By installing, you accept licenses for the packages.
Downloading package from source 'https://community.chocolatey.org/api/v2/'
Progress: Downloading rustdesk.install 1.3.1... 100%

rustdesk.install v1.3.1 - Possibly broken
rustdesk.install package files install completed. Performing other installation steps.
File appears to be downloaded already. Verifying with package checksum to determine if it needs to be redownloaded.
Hashes match.
Hashes match.
Installing rustdesk.install...
rustdesk.install has been installed.
  rustdesk.install may be able to be automatically uninstalled.
 The install of rustdesk.install was successful.
  Deployed to 'C:\Program Files\RustDesk'

Chocolatey installed 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

This time, the installation did not hang. It also worked remotely, although I lost the connection, but I was able to reconnect.

@bdukes Is it possible to run RustDesk.exe" --uninstall-service before an update (only) and RustDesk.exe" --install-service after an update or installation?

While at it, I also tried to uninstall rustdesk. This did not work as expected and had to do it this way:

PS C:\Windows\system32> & "C:\Program Files\RustDesk\RustDesk.exe" --uninstall-service; choco uninstall -y -skipautouninstall rustdesk.install
Chocolatey v2.3.0
Uninstalling the following packages:
rustdesk.install

rustdesk.install v1.3.1
 Running auto uninstaller...

  Did you know licensed versions of Chocolatey are 95% effective with
   Automatic Uninstaller due to licensed enhancements and Package
   Synchronizer?

For the question below, you have 30 seconds to make a selection.
Uninstall may not be silent (could not detect). Proceed?([Y]es/[[N]o]):

 Skipping auto uninstaller - Installer type was not detected and no silent uninstall key exists.
If the application was not removed with a chocolateyUninstall.ps1,
 please remove it from Programs and Features manually.
 rustdesk.install has been successfully uninstalled.

Chocolatey uninstalled 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

PS C:\Windows\system32> & "C:\Program Files\RustDesk\RustDesk.exe" --uninstall

Shall I create a separate issue?

@jkirk
Copy link
Contributor Author

jkirk commented Sep 22, 2024

And regarding the installer hanging in a clean environment: I think there is something special in the Vagrant/Virtualbox Chocolatey Testing Environment.

I hope I'll find some time to look into this too...

Anyway, thanks for maintaining the chocolatey package.

bdukes added a commit that referenced this issue Sep 23, 2024
And uninstall/reinstall during upgrade

For #58
@bdukes
Copy link
Owner

bdukes commented Sep 23, 2024

I've pushed a new version of the 1.3.1 package which uninstalls the service before upgrading, thanks for looking into it.

@jkirk
Copy link
Contributor Author

jkirk commented Sep 26, 2024

Thx! This is start, but updating RustDesk remotely will definitely kick the user out of the session, no?

What do you think about starting the service via RustDesk.exe --install-service after the installation; by default, but make it optional?

@bdukes
Copy link
Owner

bdukes commented Sep 26, 2024

It does run RustDesk.exe --install-service now, but we'd need to use package parameters to make it optional

@jkirk
Copy link
Contributor Author

jkirk commented Sep 27, 2024

Sorry, I missed the change in the chocolateyinstall.ps1. I'll test the change and let you know!

@jkirk
Copy link
Contributor Author

jkirk commented Oct 23, 2024

Short update:

The (fresh) installation of rustdesk v1.3.1 works without problems (aka does not get stuck).

I then uninstalled v1.3.1 (like in #58 (comment)) and installed v1.2.6. Again without problems.

From there I updated v1.2.6 to v1.3.1 also without problems.

I then uninstalled v1.3.1 and re-installed 1.2.6 again and noticed that the service was not started. Started the service (via the GUI) and tried to update to v1.3.1 again. This time the installer got stuck at "Installing rustdesk.install...".

This was done all locally. I think there still is an issue.

@jkirk
Copy link
Contributor Author

jkirk commented Oct 23, 2024

Ahh... Upgrading from v1.2.6 (with a running service installed) with & "C:\Program Files\RustDesk\RustDesk.exe" --uninstall-service; choco install -y --version 1.3.1 rustdesk.install; does work.

(At least & "C:\Program Files\RustDesk\RustDesk.exe" --install-service is not needed after the installation.)

I guess, we need to detect if the service is running / installed and stop it if yes before updating.

@bdukes
Copy link
Owner

bdukes commented Oct 23, 2024

I thought the chocolateyBeforeModify.ps1 should do that for us:

$installedPath = 'C:\Program Files\RustDesk\RustDesk.exe';
if (Test-Path $installedPath) {
& $installedPath --uninstall-service;
}

Are you able to tell from your CLI output if that script ran during the upgrade?

@jkirk
Copy link
Contributor Author

jkirk commented Oct 23, 2024

Quite good to reproduce:

screenshot_20241023T201159

PS C:\Windows\system32> & "C:\Program Files\RustDesk\RustDesk.exe" --uninstall-service; choco uninstall -y -skipautouninstall rustdesk.install; & "C:\Program Files\RustDesk\RustDesk.exe" --uninstall

PS C:\Windows\system32> choco install -y --version 1.2.6 rustdesk.install; & "C:\Program Files\RustDesk\RustDesk.exe" --install-service

PS C:\Windows\system32> choco install -y --version 1.3.1 rustdesk.install

This are the last lines in the log C:\ProgramData\chocolatey\logs\chocolatey.log:

2024-10-23 20:11:38,022 4424 [INFO ] - ============================================================
2024-10-23 20:11:38,338 4424 [INFO ] - Chocolatey v2.3.0
2024-10-23 20:11:38,343 4424 [DEBUG] - Chocolatey is running on Windows v 10.0.19045.0
2024-10-23 20:11:38,344 4424 [DEBUG] - Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
2024-10-23 20:11:38,345 4424 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old".
2024-10-23 20:11:38,352 4424 [DEBUG] - Command line: "C:\ProgramData\chocolatey\choco.exe" install -y --version 1.3.1 rustdesk.install
2024-10-23 20:11:38,353 4424 [DEBUG] - Received arguments: install -y --version 1.3.1 rustdesk.install
2024-10-23 20:11:38,379 4424 [DEBUG] - RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
2024-10-23 20:11:38,384 4424 [DEBUG] - Sending message 'PreRunMessage' out if there are subscribers...
2024-10-23 20:11:38,388 4424 [DEBUG] - [Pending] Removing all pending packages that should not be considered installed...
2024-10-23 20:11:38,420 4424 [DEBUG] - Performing validation checks.
2024-10-23 20:11:38,422 4424 [DEBUG] - Global Configuration Validation Checks:
2024-10-23 20:11:38,423 4424 [DEBUG] -  - Package Exit Code / Exit On Reboot = Checked
2024-10-23 20:11:38,425 4424 [DEBUG] - System State Validation Checks:
2024-10-23 20:11:38,426 4424 [DEBUG] -  Reboot Requirement Checks:
2024-10-23 20:11:38,427 4424 [DEBUG] -  - Pending Computer Rename = Checked
2024-10-23 20:11:38,428 4424 [DEBUG] -  - Pending Component Based Servicing = Checked
2024-10-23 20:11:38,429 4424 [DEBUG] -  - Pending Windows Auto Update = Checked
2024-10-23 20:11:38,430 4424 [DEBUG] -  - Pending File Rename Operations = Checked
2024-10-23 20:11:38,430 4424 [DEBUG] -  - Pending Windows Package Installer = Checked
2024-10-23 20:11:38,431 4424 [DEBUG] -  - Pending Windows Package Installer SysWow64 = Checked
2024-10-23 20:11:38,432 4424 [DEBUG] - Cache Folder Lockdown Checks:
2024-10-23 20:11:38,433 4424 [DEBUG] -  - Elevated State = Checked
2024-10-23 20:11:38,433 4424 [DEBUG] -  - Folder Exists = Checked
2024-10-23 20:11:38,435 4424 [DEBUG] -  - Folder lockdown = Checked
2024-10-23 20:11:38,437 4424 [INFO ] - 3 validations performed. 3 success(es), 0 warning(s), and 0 error(s).
2024-10-23 20:11:38,445 4424 [DEBUG] - The source 'https://community.chocolatey.org/api/v2/' evaluated to a 'normal' source type
2024-10-23 20:11:38,446 4424 [DEBUG] - 
NOTE: Hiding sensitive configuration data! Please double and triple
 check to be sure no sensitive data is shown, especially if copying
 output to a gist for review.
[...]
2024-10-23 20:11:38,451 4424 [DEBUG] - _ Chocolatey:ChocolateyInstallCommand - Normal Run Mode _
2024-10-23 20:11:38,455 4424 [INFO ] - Installing the following packages:
2024-10-23 20:11:38,456 4424 [INFO ] - rustdesk.install
2024-10-23 20:11:38,457 4424 [INFO ] - By installing, you accept licenses for the packages.
2024-10-23 20:11:38,555 4424 [DEBUG] - Running list with the following filter = ''
2024-10-23 20:11:38,556 4424 [DEBUG] - --- Start of List ---
2024-10-23 20:11:38,566 4424 [DEBUG] - Resolving resource PackageSearchResource for source C:\ProgramData\chocolatey\lib
2024-10-23 20:11:38,672 4424 [DEBUG] - chocolatey 2.3.0
2024-10-23 20:11:38,714 4424 [DEBUG] - rustdesk.install 1.2.6
2024-10-23 20:11:38,714 4424 [DEBUG] - --- End of List ---
2024-10-23 20:11:38,717 4424 [DEBUG] - Resolving resource PackageMetadataResource for source https://community.chocolatey.org/api/v2/
2024-10-23 20:11:38,929 4424 [INFO ] - [NuGet]   GET https://community.chocolatey.org/api/v2/Packages(Id='rustdesk.install',Version='1.3.1')
2024-10-23 20:11:38,957 4424 [INFO ] - [NuGet]   OK https://community.chocolatey.org/api/v2/Packages(Id='rustdesk.install',Version='1.3.1') 30ms
2024-10-23 20:11:38,994 4424 [DEBUG] - Resolving resource DependencyInfoResource for source https://community.chocolatey.org/api/v2/
2024-10-23 20:11:39,000 4424 [INFO ] - [NuGet]   CACHE https://community.chocolatey.org/api/v2/Packages(Id='rustdesk.install',Version='1.3.1')
2024-10-23 20:11:39,048 4424 [INFO ] - [NuGet] Resolving dependency information took 0 ms
2024-10-23 20:11:39,054 4424 [DEBUG] - Running beforeModify step for 'rustdesk.install'
2024-10-23 20:11:39,060 4424 [DEBUG] - Backing up package files for 'rustdesk.install'
2024-10-23 20:11:39,111 4424 [DEBUG] - Attempting to create directory "C:\ProgramData\chocolatey\lib-bkp\rustdesk.install".
2024-10-23 20:11:39,112 4424 [DEBUG] - Moving C:\ProgramData\chocolatey\lib\rustdesk.install to C:\ProgramData\chocolatey\lib-bkp\rustdesk.install\1.2.6
2024-10-23 20:11:39,115 4424 [DEBUG] - Moving 'C:\ProgramData\chocolatey\lib\rustdesk.install'
 to 'C:\ProgramData\chocolatey\lib-bkp\rustdesk.install\1.2.6'
2024-10-23 20:11:41,099 4424 [DEBUG] - Attempting to create directory "C:\ProgramData\chocolatey\lib\rustdesk.install".
2024-10-23 20:11:41,101 4424 [DEBUG] - Attempting to copy "C:\ProgramData\chocolatey\lib-bkp\rustdesk.install\1.2.6\rustdesk.install.nupkg"
 to "C:\ProgramData\chocolatey\lib\rustdesk.install\rustdesk.install.nupkg".
2024-10-23 20:11:41,104 4424 [DEBUG] - Attempting to copy "C:\ProgramData\chocolatey\lib-bkp\rustdesk.install\1.2.6\rustdesk.install.nuspec"
 to "C:\ProgramData\chocolatey\lib\rustdesk.install\rustdesk.install.nuspec".
2024-10-23 20:11:41,105 4424 [DEBUG] - Attempting to create directory "C:\ProgramData\chocolatey\lib\rustdesk.install\tools".
2024-10-23 20:11:41,106 4424 [DEBUG] - Attempting to copy "C:\ProgramData\chocolatey\lib-bkp\rustdesk.install\1.2.6\tools\chocolateyinstall.ps1"
 to "C:\ProgramData\chocolatey\lib\rustdesk.install\tools\chocolateyinstall.ps1".
2024-10-23 20:11:42,588 4424 [DEBUG] - Capturing package files in 'C:\ProgramData\chocolatey\lib\rustdesk.install'
2024-10-23 20:11:42,589 4424 [DEBUG] -  Found 'C:\ProgramData\chocolatey\lib\rustdesk.install\rustdesk.install.nupkg'
  with checksum 'DAE103EC8CB5F8B4EFE531878A12A2B6'
2024-10-23 20:11:42,590 4424 [DEBUG] -  Found 'C:\ProgramData\chocolatey\lib\rustdesk.install\rustdesk.install.nuspec'
  with checksum '5A1096CEB793ADF740BFFF97C32653EE'
2024-10-23 20:11:42,591 4424 [DEBUG] -  Found 'C:\ProgramData\chocolatey\lib\rustdesk.install\tools\chocolateyinstall.ps1'
  with checksum '2C1045BD990382BA703EE0BA4444E563'
2024-10-23 20:11:42,636 4424 [DEBUG] - [NuGet] Removed folder 'C:\ProgramData\chocolatey\lib\rustdesk.install\tools'.
2024-10-23 20:11:42,639 4424 [DEBUG] - [NuGet] Removed file 'rustdesk.install.nupkg' from folder 'C:\ProgramData\chocolatey\lib\rustdesk.install'.
2024-10-23 20:11:42,645 4424 [DEBUG] - Ensuring removal of package cache files.
2024-10-23 20:11:42,646 4424 [DEBUG] - Attempting to delete directory "C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.2.6".
2024-10-23 20:11:42,652 4424 [DEBUG] - Resolving resource DownloadResource for source https://community.chocolatey.org/api/v2/
2024-10-23 20:11:42,667 4424 [DEBUG] - Attempting to delete file "".
2024-10-23 20:11:42,668 4424 [INFO ] - Downloading package from source 'https://community.chocolatey.org/api/v2/'
2024-10-23 20:11:42,668 4424 [DEBUG] - Package download location 'https://community.chocolatey.org/api/v2/package/rustdesk.install/1.3.1'
2024-10-23 20:11:42,678 4424 [INFO ] - [NuGet]   GET https://community.chocolatey.org/api/v2/package/rustdesk.install/1.3.1
2024-10-23 20:11:43,149 4424 [INFO ] - [NuGet]   ServiceUnavailable https://community.chocolatey.org/api/v2/package/rustdesk.install/1.3.1 478ms
2024-10-23 20:11:43,164 4424 [WARN ] - [NuGet] Error downloading 'rustdesk.install.1.3.1' from 'https://community.chocolatey.org/api/v2/package/rustdesk.install/1.3.1'.
[NuGet] Response status code does not indicate success: 503 (Service Unavailable).
2024-10-23 20:11:43,166 4424 [INFO ] - [NuGet]   GET https://community.chocolatey.org/api/v2/package/rustdesk.install/1.3.1
2024-10-23 20:11:43,428 4424 [INFO ] - [NuGet]   OK https://community.chocolatey.org/api/v2/package/rustdesk.install/1.3.1 265ms
2024-10-23 20:11:43,442 4424 [INFO ] - [NuGet] Acquiring lock for the installation of rustdesk.install 1.3.1
2024-10-23 20:11:43,461 4424 [INFO ] - [NuGet] Acquired lock for the installation of rustdesk.install 1.3.1
2024-10-23 20:11:43,595 4424 [INFO ] - [NuGet] Installed rustdesk.install 1.3.1 from https://community.chocolatey.org/api/v2/ with content hash jy2xJVoTNZgVLswT4OGI9eiEIC2bwNbV994E3uq1NB73T9OTdiRfSxwvP/jYJEnI8SmVMr+Zz+Ckr1XltYHbgg==.
2024-10-23 20:11:43,613 4424 [DEBUG] - Skipping package hash validation as feature 'usePackageHashValidation' is not enabled.
2024-10-23 20:11:43,628 4424 [INFO ] - [NuGet] Adding package 'rustdesk.install.1.3.1' to folder 'C:\ProgramData\chocolatey\lib'
2024-10-23 20:11:43,694 4424 [INFO ] - [NuGet] Added package 'rustdesk.install.1.3.1' to folder 'C:\ProgramData\chocolatey\lib'
2024-10-23 20:11:43,697 4424 [DEBUG] - Attempting to delete file "C:\Users\sysadmin\AppData\Local\Temp\chocolatey\ChocolateyScratch\rustdesk.install/1.3.1\rustdesk.install.1.3.1.nupkg".
2024-10-23 20:11:43,699 4424 [DEBUG] - Attempting to delete file "C:\Users\sysadmin\AppData\Local\Temp\chocolatey\ChocolateyScratch\rustdesk.install/1.3.1\.nupkg.metadata".
2024-10-23 20:11:43,700 4424 [DEBUG] - Attempting to delete file "C:\Users\sysadmin\AppData\Local\Temp\chocolatey\ChocolateyScratch\rustdesk.install/1.3.1\rustdesk.install.1.3.1.nupkg.sha512".
2024-10-23 20:11:43,701 4424 [INFO ] - 
rustdesk.install v1.3.1 - Possibly broken
2024-10-23 20:11:43,734 4424 [INFO ] - rustdesk.install package files install completed. Performing other installation steps.
2024-10-23 20:11:43,783 4424 [DEBUG] - Setting installer args for rustdesk.install
2024-10-23 20:11:43,784 4424 [DEBUG] - Setting package parameters for rustdesk.install
2024-10-23 20:11:43,785 4424 [DEBUG] - Contents of 'C:\ProgramData\chocolatey\lib\rustdesk.install\tools\chocolateyinstall.ps1':
2024-10-23 20:11:43,795 4424 [DEBUG] - $ErrorActionPreference = 'Stop';

$packageArgs = @{
  packageName    = $env:ChocolateyPackageName
  fileType       = 'exe'
  url            = 'https://github.com/rustdesk/rustdesk/releases/download/1.3.1/rustdesk-1.3.1-x86_64.exe'
  silentArgs     = "--silent-install"
  validExitCodes = @(0)
  checksum       = 'fc20fd159eea217fa8ba30309aef177ec00913007f42b325e6b7dd1f21a2f245'
  checksumType   = 'sha256'
}

Install-ChocolateyPackage @packageArgs;

$installedPath = 'C:\Program Files\RustDesk\RustDesk.exe';
if (Test-Path $installedPath) {
  & $installedPath --install-service;
}

2024-10-23 20:11:43,822 4424 [DEBUG] - Calling built-in PowerShell host with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = '';[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::SystemDefault; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\rustdesk.install\tools\chocolateyinstall.ps1' -installArguments '' -packageParameters '' -preRunHookScripts $null -postRunHookScripts $null']
2024-10-23 20:11:43,836 4424 [DEBUG] - Redirecting System.Management.Automation.resources, Version=3.0.0.0, Culture=en-US, PublicKeyToken=31bf3856ad364e35, requested by ''
2024-10-23 20:11:45,278 4424 [DEBUG] - Host version is 5.1.19041.1, PowerShell Version is '5.1.19041.5007' and CLR Version is '4.0.30319.42000'.
2024-10-23 20:11:45,549 4424 [INFO ] - VERBOSE: Loading module from path 'C:\ProgramData\chocolatey\helpers\Chocolatey.PowerShell.dll'.
2024-10-23 20:11:45,571 4424 [DEBUG] - Returning loaded assembly type for 'Chocolatey.PowerShell'
2024-10-23 20:11:45,579 4424 [INFO ] - VERBOSE: Importing cmdlet 'Get-EnvironmentVariable'.
2024-10-23 20:11:45,580 4424 [INFO ] - VERBOSE: Importing cmdlet 'Get-EnvironmentVariableNames'.
2024-10-23 20:11:45,580 4424 [INFO ] - VERBOSE: Importing cmdlet 'Install-ChocolateyPath'.
2024-10-23 20:11:45,581 4424 [INFO ] - VERBOSE: Importing cmdlet 'Set-EnvironmentVariable'.
2024-10-23 20:11:45,581 4424 [INFO ] - VERBOSE: Importing cmdlet 'Test-ProcessAdminRights'.
2024-10-23 20:11:45,582 4424 [INFO ] - VERBOSE: Importing cmdlet 'Uninstall-ChocolateyPath'.
2024-10-23 20:11:45,583 4424 [INFO ] - VERBOSE: Importing cmdlet 'Update-SessionEnvironment'.
2024-10-23 20:11:45,604 4424 [DEBUG] - Cmdlets exported from Chocolatey.PowerShell.dll
2024-10-23 20:11:45,606 4424 [DEBUG] - Get-EnvironmentVariable
2024-10-23 20:11:45,607 4424 [DEBUG] - Get-EnvironmentVariableNames
2024-10-23 20:11:45,607 4424 [DEBUG] - Install-ChocolateyPath
2024-10-23 20:11:45,608 4424 [DEBUG] - Set-EnvironmentVariable
2024-10-23 20:11:45,608 4424 [DEBUG] - Test-ProcessAdminRights
2024-10-23 20:11:45,608 4424 [DEBUG] - Uninstall-ChocolateyPath
2024-10-23 20:11:45,608 4424 [DEBUG] - Update-SessionEnvironment
[...]
2024-10-23 20:11:45,729 4424 [DEBUG] - ---------------------------Script Execution---------------------------
2024-10-23 20:11:45,731 4424 [DEBUG] - Running 'ChocolateyScriptRunner' for rustdesk.install v1.3.1 with packageScript 'C:\ProgramData\chocolatey\lib\rustdesk.install\tools\chocolateyinstall.ps1', packageFolder:'C:\ProgramData\chocolatey\lib\rustdesk.install', installArguments: '', packageParameters: '', preRunHookScripts: '', postRunHookScripts: '',
2024-10-23 20:11:45,738 4424 [DEBUG] - Running package script 'C:\ProgramData\chocolatey\lib\rustdesk.install\tools\chocolateyinstall.ps1'
2024-10-23 20:11:45,814 4424 [DEBUG] - Running Install-ChocolateyPackage -silentArgs '--silent-install' -checksum 'fc20fd159eea217fa8ba30309aef177ec00913007f42b325e6b7dd1f21a2f245' -checksumType 'sha256' -fileType 'exe' -validExitCodes '0' -url 'https://github.com/rustdesk/rustdesk/releases/download/1.3.1/rustdesk-1.3.1-x86_64.exe' -packageName 'rustdesk.install' 
2024-10-23 20:11:45,844 4424 [DEBUG] - Running Get-ChocolateyWebFile -packageName 'rustdesk.install' -fileFullPath 'C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.3.1\rustdesk.installInstall.exe' -url 'https://github.com/rustdesk/rustdesk/releases/download/1.3.1/rustdesk-1.3.1-x86_64.exe' -url64bit '' -checksum 'fc20fd159eea217fa8ba30309aef177ec00913007f42b325e6b7dd1f21a2f245' -checksumType 'sha256' -checksum64 '' -checksumType64 '' -options 'System.Collections.Hashtable' -getOriginalFileName 'True' 
2024-10-23 20:11:45,876 4424 [DEBUG] - Running Get-OSArchitectureWidth -compare '64' 
2024-10-23 20:11:45,888 4424 [DEBUG] - CPU is 64 bit
2024-10-23 20:11:45,911 4424 [DEBUG] - Running Get-WebFileName -url 'https://github.com/rustdesk/rustdesk/releases/download/1.3.1/rustdesk-1.3.1-x86_64.exe' -defaultName 'rustdesk.installInstall.exe' 
2024-10-23 20:11:46,695 4424 [DEBUG] - Using header 'Content-Disposition' to determine file name.
2024-10-23 20:11:46,700 4424 [DEBUG] - File name determined from url is 'rustdesk-1.3.1-x86_64.exe'
2024-10-23 20:11:46,717 4424 [DEBUG] - Running Get-WebHeaders -url 'https://github.com/rustdesk/rustdesk/releases/download/1.3.1/rustdesk-1.3.1-x86_64.exe' -ErrorAction 'Stop' 
2024-10-23 20:11:46,719 4424 [DEBUG] - Setting the UserAgent to 'chocolatey command line'
2024-10-23 20:11:46,720 4424 [DEBUG] - Request Headers:
2024-10-23 20:11:46,726 4424 [DEBUG] -   'Accept':'*/*'
2024-10-23 20:11:46,727 4424 [DEBUG] -   'User-Agent':'chocolatey command line'
2024-10-23 20:11:47,217 4424 [DEBUG] - Response Headers:
2024-10-23 20:11:47,221 4424 [DEBUG] -   'Connection':'keep-alive'
2024-10-23 20:11:47,221 4424 [DEBUG] -   'x-ms-request-id':'5af334ad-101e-0019-5219-1361ee000000'
2024-10-23 20:11:47,222 4424 [DEBUG] -   'x-ms-version':'2023-11-03'
2024-10-23 20:11:47,223 4424 [DEBUG] -   'x-ms-creation-time':'Fri, 20 Sep 2024 14:32:22 GMT'
2024-10-23 20:11:47,224 4424 [DEBUG] -   'x-ms-lease-status':'unlocked'
2024-10-23 20:11:47,225 4424 [DEBUG] -   'x-ms-lease-state':'available'
2024-10-23 20:11:47,226 4424 [DEBUG] -   'x-ms-blob-type':'BlockBlob'
2024-10-23 20:11:47,226 4424 [DEBUG] -   'Content-Disposition':'attachment; filename=rustdesk-1.3.1-x86_64.exe'
2024-10-23 20:11:47,227 4424 [DEBUG] -   'x-ms-server-encrypted':'true'
2024-10-23 20:11:47,227 4424 [DEBUG] -   'Fastly-Restarts':'1'
2024-10-23 20:11:47,228 4424 [DEBUG] -   'Age':'4208'
2024-10-23 20:11:47,229 4424 [DEBUG] -   'X-Served-By':'cache-iad-kjyo7100077-IAD, cache-vie6341-VIE'
2024-10-23 20:11:47,231 4424 [DEBUG] -   'X-Cache':'HIT, HIT'
2024-10-23 20:11:47,232 4424 [DEBUG] -   'X-Cache-Hits':'25336, 1'
2024-10-23 20:11:47,233 4424 [DEBUG] -   'X-Timer':'S1729707096.063563,VS0,VE2'
2024-10-23 20:11:47,234 4424 [DEBUG] -   'Accept-Ranges':'bytes'
2024-10-23 20:11:47,235 4424 [DEBUG] -   'Content-Length':'21815424'
2024-10-23 20:11:47,236 4424 [DEBUG] -   'Content-Type':'application/octet-stream'
2024-10-23 20:11:47,237 4424 [DEBUG] -   'Date':'Wed, 23 Oct 2024 18:11:36 GMT'
2024-10-23 20:11:47,238 4424 [DEBUG] -   'ETag':'"0x8DCD9810A23E23E"'
2024-10-23 20:11:47,239 4424 [DEBUG] -   'Last-Modified':'Fri, 20 Sep 2024 14:32:22 GMT'
2024-10-23 20:11:47,239 4424 [DEBUG] -   'Server':'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0'
2024-10-23 20:11:47,239 4424 [DEBUG] -   'Via':'1.1 varnish, 1.1 varnish'
2024-10-23 20:11:47,253 4424 [INFO ] - File appears to be downloaded already. Verifying with package checksum to determine if it needs to be redownloaded.
2024-10-23 20:11:47,259 4424 [DEBUG] - Running Get-ChecksumValid -file 'C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.3.1\rustdesk-1.3.1-x86_64.exe' -checksum 'fc20fd159eea217fa8ba30309aef177ec00913007f42b325e6b7dd1f21a2f245' -checksumType 'sha256' -originalUrl 'https://github.com/rustdesk/rustdesk/releases/download/1.3.1/rustdesk-1.3.1-x86_64.exe' -ErrorAction 'Stop' 
2024-10-23 20:11:47,262 4424 [DEBUG] - checksum.exe found at 'C:\ProgramData\chocolatey\helpers\..\tools\checksum.exe'
2024-10-23 20:11:47,262 4424 [DEBUG] - Executing command ['C:\ProgramData\chocolatey\helpers\..\tools\checksum.exe' -c="fc20fd159eea217fa8ba30309aef177ec00913007f42b325e6b7dd1f21a2f245" -t="sha256" -f="C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.3.1\rustdesk-1.3.1-x86_64.exe"]
2024-10-23 20:11:47,505 4424 [DEBUG] - Command ['C:\ProgramData\chocolatey\helpers\..\tools\checksum.exe' -c="fc20fd159eea217fa8ba30309aef177ec00913007f42b325e6b7dd1f21a2f245" -t="sha256" -f="C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.3.1\rustdesk-1.3.1-x86_64.exe"] exited with '0'.
2024-10-23 20:11:47,507 4424 [DEBUG] - rustdesk.install's requested file has already been downloaded. Using cached copy at
 'C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.3.1\rustdesk-1.3.1-x86_64.exe'.
2024-10-23 20:11:49,293 4424 [DEBUG] - No runtime virus checking built into FOSS Chocolatey. Check out Pro/Business - https://chocolatey.org/compare
2024-10-23 20:11:49,295 4424 [DEBUG] - Verifying package provided checksum of 'fc20fd159eea217fa8ba30309aef177ec00913007f42b325e6b7dd1f21a2f245' for 'C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.3.1\rustdesk-1.3.1-x86_64.exe'.
2024-10-23 20:11:49,295 4424 [DEBUG] - Running Get-ChecksumValid -file 'C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.3.1\rustdesk-1.3.1-x86_64.exe' -checksum 'fc20fd159eea217fa8ba30309aef177ec00913007f42b325e6b7dd1f21a2f245' -checksumType 'sha256' -originalUrl 'https://github.com/rustdesk/rustdesk/releases/download/1.3.1/rustdesk-1.3.1-x86_64.exe' 
2024-10-23 20:11:49,295 4424 [DEBUG] - checksum.exe found at 'C:\ProgramData\chocolatey\helpers\..\tools\checksum.exe'
2024-10-23 20:11:49,295 4424 [DEBUG] - Executing command ['C:\ProgramData\chocolatey\helpers\..\tools\checksum.exe' -c="fc20fd159eea217fa8ba30309aef177ec00913007f42b325e6b7dd1f21a2f245" -t="sha256" -f="C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.3.1\rustdesk-1.3.1-x86_64.exe"]
2024-10-23 20:11:49,431 4424 [DEBUG] - Command ['C:\ProgramData\chocolatey\helpers\..\tools\checksum.exe' -c="fc20fd159eea217fa8ba30309aef177ec00913007f42b325e6b7dd1f21a2f245" -t="sha256" -f="C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.3.1\rustdesk-1.3.1-x86_64.exe"] exited with '0'.
2024-10-23 20:11:49,449 4424 [DEBUG] - Running Install-ChocolateyInstallPackage -packageName 'rustdesk.install' -fileType 'exe' -silentArgs '--silent-install' -file 'C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.3.1\rustdesk-1.3.1-x86_64.exe' -validExitCodes '0' -useOnlyPackageSilentArguments 'False' 
2024-10-23 20:11:49,456 4424 [DEBUG] - Running Get-OSArchitectureWidth -compare '32' 
2024-10-23 20:11:49,457 4424 [INFO ] - Installing rustdesk.install...
2024-10-23 20:11:49,503 4424 [DEBUG] - Running Start-ChocolateyProcessAsAdmin -validExitCodes '0' -workingDirectory 'C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.3.1' -statements '--silent-install' -exeToRun 'C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.3.1\rustdesk-1.3.1-x86_64.exe' 
2024-10-23 20:11:49,505 4424 [DEBUG] - Running Test-ProcessAdminRights
2024-10-23 20:11:49,506 4424 [DEBUG] - Test-ProcessAdminRights: returning True
2024-10-23 20:11:49,507 4424 [DEBUG] - Finishing 'Test-ProcessAdminRights'
2024-10-23 20:11:49,510 4424 [DEBUG] - Elevating permissions and running ["C:\Users\sysadmin\AppData\Local\Temp\chocolatey\rustdesk.install\1.3.1\rustdesk-1.3.1-x86_64.exe" --silent-install]. This may take a while, depending on the statements.

@jkirk
Copy link
Contributor Author

jkirk commented Oct 23, 2024

chocolateyBeforeModify.ps1 does not seem to be called anywhere, no?

@bdukes
Copy link
Owner

bdukes commented Oct 23, 2024

Ah, according to the docs:

In the upgrade scenario, the chocolateyInstall.ps1 script will be the one included in the new package. The chocolateyBeforeModify.ps1 script will be the one from the previously installed package.

So we can't update the 1.3.1 package to cause the 1.2.6 package to uninstall the service during an upgrade.

@jkirk
Copy link
Contributor Author

jkirk commented Oct 23, 2024

Can't you just put this in chocolateyInstall.ps1?

 if (Test-Path $installedPath) { 
   & $installedPath --uninstall-service; 
 } 

Nothing "bad" seem to happen, if --uninstall-service was already called before. But yes, some kind of check "is the service installed" would be good.

But we need some kind of "post-inst" script to call install-service? Is there something in chocolatey?

@jkirk
Copy link
Contributor Author

jkirk commented Oct 23, 2024

Maybe something like this? 🤷🏾

PS C:\Windows\system32> & "C:\Program Files\RustDesk\RustDesk.exe" --install-service;
PS C:\Windows\system32> Get-Service -Name "RustDesk"

Status   Name               DisplayName
------   ----               -----------
Running  RustDesk           RustDesk Service


PS C:\Windows\system32> & "C:\Program Files\RustDesk\RustDesk.exe" --uninstall-service;
PS C:\Windows\system32> Get-Service -Name "RustDesk"
Get-Service : Cannot find any service with service name 'RustDesk'.
At line:1 char:1
+ Get-Service -Name "RustDesk"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (RustDesk:String) [Get-Service], ServiceCommandException
    + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand

PS C:\Windows\system32>

Taken from here: https://stackoverflow.com/a/35065826

Sorry for the noise. I am obviously not a Powershell guy...

bdukes added a commit that referenced this issue Oct 23, 2024
@bdukes
Copy link
Owner

bdukes commented Oct 23, 2024

I just pushed a new version of the 1.3.1 package which always tries to uninstall the service before installing the new version. Thanks!

@jkirk
Copy link
Contributor Author

jkirk commented Oct 24, 2024

Cool! The quick test early in the morning went well:

PS C:\Windows\system32> & "C:\Program Files\RustDesk\RustDesk.exe" --uninstall-service; choco uninstall -y -skipautouninstall rustdesk.install; & "C:\Program Files\RustDesk\RustDesk.exe" --uninstall
Chocolatey v2.3.0
Uninstalling the following packages:
rustdesk.install

rustdesk.install v1.2.6
 Running auto uninstaller...

  Did you know licensed versions of Chocolatey are 95% effective with
   Automatic Uninstaller due to licensed enhancements and Package
   Synchronizer?

For the question below, you have 30 seconds to make a selection.
Uninstall may not be silent (could not detect). Proceed?([Y]es/[[N]o]):

 Skipping auto uninstaller - Installer type was not detected and no silent uninstall key exists.
If the application was not removed with a chocolateyUninstall.ps1,
 please remove it from Programs and Features manually.
 rustdesk.install has been successfully uninstalled.

Chocolatey uninstalled 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
PS C:\Windows\system32> choco install -y --version 1.2.6 rustdesk.install; & "C:\Program Files\RustDesk\RustDesk.exe" --install-service
Chocolatey v2.3.0
Installing the following packages:
rustdesk.install
By installing, you accept licenses for the packages.
Downloading package from source 'https://community.chocolatey.org/api/v2/'
Progress: Downloading rustdesk.install 1.2.6... 100%

rustdesk.install v1.2.6 [Approved]
rustdesk.install package files install completed. Performing other installation steps.
File appears to be downloaded already. Verifying with package checksum to determine if it needs to be redownloaded.
Hashes match.
Hashes match.
Installing rustdesk.install...
rustdesk.install has been installed.
  rustdesk.install may be able to be automatically uninstalled.
 The install of rustdesk.install was successful.
  Deployed to 'C:\Program Files\RustDesk'

Chocolatey installed 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
PS C:\Windows\system32> choco install -y --version 1.3.1 rustdesk.install
Chocolatey v2.3.0
Installing the following packages:
rustdesk.install
By installing, you accept licenses for the packages.
Downloading package from source 'https://community.chocolatey.org/api/v2/'
Progress: Downloading rustdesk.install 1.3.1... 100%

rustdesk.install v1.3.1 - Possibly broken
rustdesk.install package files install completed. Performing other installation steps.
File appears to be downloaded already. Verifying with package checksum to determine if it needs to be redownloaded.
Hashes match.
Hashes match.
Installing rustdesk.install...
rustdesk.install has been installed.
  rustdesk.install may be able to be automatically uninstalled.
 The install of rustdesk.install was successful.
  Deployed to 'C:\Program Files\RustDesk'

Chocolatey installed 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Not sure about the stance in chocolateyBeforeModify.ps1:

$installedPath = 'C:\Program Files\RustDesk\RustDesk.exe';
if (Test-Path $installedPath) {
& $installedPath --uninstall-service;
}

But apart of that, it looks good! Well done! Thx!

@jkirk jkirk changed the title rustdesk: Upgrade/Update hangs (1.2.3 -> 1.2.6) rustdesk: Upgrade/Update hangs Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants