installer/windows: make upgrade possible (#3345)

* First custom message

* Update text - change welcome dialog size

* dialogs workflow ok - config.yaml ko

* Delete on uninstall using custom action

* config file not deleted during upgrade

* remove useless registryvalue

* little fixes

* Fix back button in case of upgrade for verifyreadydlg

* same versions considered as upgrade

* same versions considered as upgrade

* Backup config file - does not work when changing install folder

* Installer version is taken from the version of storagenode.exe file

* registry read for retrieving install folder - parsing not working

* doesn't work

* Fix path extraction

* Separate install dir extraction from file movement

* Check the result of BackupConfigFile and RestoreConfigFile actions

* Set INSTALLFOLDER to the extracted path
This commit is contained in:
Fadila 2019-10-29 20:31:20 +01:00 committed by GitHub
parent cd0940724c
commit 1828caf69b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 39 deletions

View File

@ -3,7 +3,7 @@
Customized to collect user input for storage node config.
First-time install dialog sequence:
- WixUI_WelcomeDlg
- StorjWelcomeDlg
- WixUI_LicenseAgreementDlg
- InstallDirConfigDlg
- IdentityDirDlg
@ -58,8 +58,9 @@ Patch dialog sequence:
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
<Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchSNOBoard">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
<Publish Dialog="StorjWelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">NOT Installed</Publish>
<Publish Dialog="StorjWelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
<Publish Dialog="StorjWelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">NOT Installed OR NOT WIX_UPGRADE_DETECTED</Publish>
<Publish Dialog="StorjWelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH AND NOT WIX_UPGRADE_DETECTED</Publish>
<Publish Dialog="StorjWelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">NOT Installed AND WIX_UPGRADE_DETECTED</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="StorjWelcomeDlg">1</Publish>
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="InstallDirConfigDlg">LicenseAccepted = "1"</Publish>
@ -112,9 +113,9 @@ Patch dialog sequence:
<Publish Dialog="AllocatedBandwidthConfigDlg" Control="Next" Event="SpawnDialog" Value="ValidationErrorDlg" Order="3"><![CDATA[STORJ_BANDWIDTH_VALID<>"1"]]></Publish>
<Publish Dialog="AllocatedBandwidthConfigDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">STORJ_BANDWIDTH_VALID="1"</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="AllocatedBandwidthConfigDlg" Order="1">NOT Installed</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="StorjWelcomeDlg" Order="2">Installed AND PATCH</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="AllocatedBandwidthConfigDlg" Order="1">NOT Installed AND NOT WIX_UPGRADE_DETECTED</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH AND NOT WIX_UPGRADE_DETECTED</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="StorjWelcomeDlg" Order="2">Installed AND PATCH OR WIX_UPGRADE_DETECTED</Publish>
<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:fire="http://schemas.microsoft.com/wix/FirewallExtension">
<Product Id="{E97D368F-CB18-45B5-8799-1EBB10728A99}" Name="Storj V3 Storage Node" Language="1033" Version="0.0.0" Manufacturer="Storj Labs Inc." UpgradeCode="{B32CF5FC-0665-4712-B88A-22D299565F9E}">
<Product Id="*" Name="Storj V3 Storage Node" Language="1033" Version="!(bind.FileVersion.Storagenodeexe)" Manufacturer="Storj Labs Inc." UpgradeCode="{B32CF5FC-0665-4712-B88A-22D299565F9E}">
<Package Platform="x64" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." AllowSameVersionUpgrades="yes" Schedule="afterInstallExecute"/>
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="Storage Node" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="StorjFolder" Name="Storj">
@ -62,9 +62,6 @@
<ServiceControl Id="StoragenodeUpdaterStartService" Start="install" Stop="both" Remove="uninstall" Name="storagenode-updater" Wait="yes" />
</Component>
<Component Id="RemoveFiles" Guid="{26A01B8E-A9F3-4BF8-9FFC-50CDE0A4DF68}" Win64="yes">
<RemoveFile Id="ConfigFile" Name="config.yaml" On="uninstall" />
</Component>
<Component Id="dashboardShortcut" Guid="{C48A862E-869D-4FD4-A215-D47092A40BAA}" Win64="yes">
<!-- We use a standard shortcut to 'cmd.exe /C "start http://localhost:14002"' instead of util:InternetShortcut,
so it appears as an App Shortcut with icon in the Windows Start Menu. In contrast, InternetShortcut does
@ -77,18 +74,21 @@
<RegistryValue Root="HKCU" Key="Software\Storj\Storage Node" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</ComponentGroup>
<Property Id="WIXUI_INSTALLDIR">INSTALLFOLDER</Property>
<Property Id="STORJ_STORAGEDIR">STORAGEDIR</Property>
<Property Id="STORJ_STORAGE">1.0</Property>
<Property Id="STORJ_BANDWIDTH">2.0</Property>
<Property Id="STORJ_IDENTITYDIR">IDENTITYDIR</Property>
<Property Id="STORJ_DEFAULTIDENTITYDIR">
<DirectorySearch Id='search1' Path='[PersonalFolder]' />
<DirectorySearch Id='search2' Path='[AppDataFolder]\Storj\Identity\storagenode'/>
<DirectorySearch Id='search1' Path='[PersonalFolder]' />
<DirectorySearch Id='search2' Path='[AppDataFolder]\Storj\Identity\storagenode'/>
</Property>
<Property Id="STORJ_SERVICE_COMMAND">
<RegistrySearch Id="ServiceCommand" Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\storagenode" Name="ImagePath" Type="raw" />
</Property>
<SetDirectory Action="SetIdentityDir" Id="IDENTITYDIR" Value="[STORJ_DEFAULTIDENTITYDIR]" Sequence="first">STORJ_DEFAULTIDENTITYDIR</SetDirectory>
<SetDirectory Action="SetInstallFolder" Id="INSTALLFOLDER" Value="[STORJ_INSTALLDIR]" Sequence="execute">WIX_UPGRADE_DETECTED</SetDirectory>
<UIRef Id="CustomInstallDir" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Open dashboard" />
@ -106,10 +106,24 @@
<Binary Id="StorjDLL" SourceFile="$(var.Storj.TargetDir)Storj.CA.dll" />
<CustomAction Id='StoragenodeSetup' Directory='INSTALLFOLDER' Execute='deferred' Impersonate='no'
ExeCommand="&quot;[INSTALLFOLDER]storagenode.exe&quot; setup --config-dir &quot;[INSTALLFOLDER]\&quot; --identity-dir &quot;[IDENTITYDIR]\&quot; --operator.email &quot;[STORJ_EMAIL]&quot; --operator.wallet &quot;[STORJ_WALLET]&quot; --contact.external-address &quot;[STORJ_PUBLIC_ADDRESS]&quot; --storage.path &quot;[STORAGEDIR]\&quot; --storage.allocated-bandwidth &quot;[STORJ_BANDWIDTH] TB&quot; --storage.allocated-disk-space &quot;[STORJ_STORAGE] TB&quot; --log.output &quot;winfile:///[INSTALLFOLDER]\storagenode.log&quot;"
/>
ExeCommand="&quot;[INSTALLFOLDER]storagenode.exe&quot; setup --config-dir &quot;[INSTALLFOLDER]\&quot; --identity-dir &quot;[IDENTITYDIR]\&quot; --operator.email &quot;[STORJ_EMAIL]&quot; --operator.wallet &quot;[STORJ_WALLET]&quot; --contact.external-address &quot;[STORJ_PUBLIC_ADDRESS]&quot; --storage.path &quot;[STORAGEDIR]\&quot; --storage.allocated-bandwidth &quot;[STORJ_BANDWIDTH] TB&quot; --storage.allocated-disk-space &quot;[STORJ_STORAGE] TB&quot; --log.output &quot;winfile:///[INSTALLFOLDER]\storagenode.log&quot;" />
<CustomAction Id="DeleteConfigFile" Directory='INSTALLFOLDER'
ExeCommand="cmd /C &quot;del config.yaml&quot;" Execute="deferred" Return="ignore" Impersonate="no" />
<CustomAction Id="ExtractInstallDir" BinaryKey="StorjDLL" DllEntry="ExtractInstallDir" Execute="immediate" Return="check" />
<CustomAction Id="BackupConfigFile" Directory='INSTALLFOLDER'
ExeCommand="cmd /C &quot;move config.yaml config.yaml.bak&quot;" Execute="deferred" Return="check" Impersonate="no" />
<CustomAction Id="RestoreConfigFile" Directory='INSTALLFOLDER'
ExeCommand="cmd /C &quot;move config.yaml.bak config.yaml&quot;" Execute="deferred" Return="check" Impersonate="no" />
<InstallExecuteSequence>
<Custom Action='StoragenodeSetup' Before='InstallServices'>NOT Installed</Custom>
<Custom Action='StoragenodeSetup' Before='InstallServices'>NOT Installed AND NOT WIX_UPGRADE_DETECTED</Custom>
<Custom Action='DeleteConfigFile' After='RemoveFiles'>(REMOVE="ALL") AND NOT WIX_UPGRADE_DETECTED</Custom>
<!-- legacy: save config file as old versions of the installer will remove it -->
<Custom Action='ExtractInstallDir' Before='SetInstallFolder'>WIX_UPGRADE_DETECTED</Custom>
<Custom Action='BackupConfigFile' Before='InstallExecute'>WIX_UPGRADE_DETECTED</Custom>
<Custom Action='RestoreConfigFile' After='RemoveExistingProducts'>WIX_UPGRADE_DETECTED</Custom>
</InstallExecuteSequence>
</Product>
</Wix>

View File

@ -2,6 +2,7 @@ using Microsoft.Deployment.WindowsInstaller;
using System;
using System.Globalization;
using System.IO;
using System.Text.RegularExpressions;
namespace Storj
{
@ -182,5 +183,20 @@ namespace Storj
session["STORJ_BANDWIDTH_VALID"] = "1";
return ActionResult.Success;
}
[CustomAction]
public static ActionResult ExtractInstallDir(Session session)
{
string line = session["STORJ_SERVICE_COMMAND"];
session.Log($"ExtractInstallDir registry value: {line}");
Regex pattern = new Regex(@"--config-dir ""(?<installDir>.*)""");
Match match = pattern.Match(line);
string path = match.Groups["installDir"].Value;
session.Log($"ExtractInstallDir extracted path: {path}");
session["STORJ_INSTALLDIR"] = path;
return ActionResult.Success;
}
}
}

View File

@ -16,44 +16,49 @@
<Control Id="Bitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="234" TabSkip="no" Text="!(loc.WelcomeDlgBitmap)" />
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Disabled="yes" Text="!(loc.WixUIBack)" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<!-- Upgrade text -->
<Control Id="UpgradeDescription" Type="Text" X="135" Y="80" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="The Setup Wizard will upgrade your the Storj V3 Storage Node installation. This operation will not modify your storage node's configuration." >
<Condition Action="show">WIX_UPGRADE_DETECTED</Condition>
<Condition Action="hide">NOT WIX_UPGRADE_DETECTED</Condition>
</Control>
<!-- Installation text -->
<Control Id="Description" Type="Text" X="135" Y="70" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="The Setup Wizard will install the Storj V3 Storage Node on your computer." >
<Condition Action="show">NOT Installed OR NOT PATCH</Condition>
<Condition Action="hide">Installed AND PATCH</Condition>
<Condition Action="show">(NOT Installed OR NOT PATCH) AND NOT WIX_UPGRADE_DETECTED</Condition>
<Condition Action="hide">(Installed AND PATCH) OR WIX_UPGRADE_DETECTED</Condition>
</Control>
<Control Id="RequirementsIntro" Type="Text" X="135" Y="105" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="Before you begin, make sure you meet the following requirements:" >
<Condition Action="show">NOT Installed OR NOT PATCH</Condition>
<Condition Action="hide">Installed AND PATCH</Condition>
<Condition Action="show">(NOT Installed OR NOT PATCH) AND NOT WIX_UPGRADE_DETECTED</Condition>
<Condition Action="hide">(Installed AND PATCH) OR WIX_UPGRADE_DETECTED</Condition>
</Control>
<Control Id="AuthToken" Type="Text" X="135" Y="130" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="- You've received an authorization token from Storj Labs" >
<Condition Action="show">NOT Installed OR NOT PATCH</Condition>
<Condition Action="hide">Installed AND PATCH</Condition>
<Condition Action="show">(NOT Installed OR NOT PATCH) AND NOT WIX_UPGRADE_DETECTED</Condition>
<Condition Action="hide">(Installed AND PATCH) OR WIX_UPGRADE_DETECTED</Condition>
</Control>
<Control Id="Identity" Type="Text" X="135" Y="142" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="- You've generated a new identity for your storage node" >
<Condition Action="show">NOT Installed OR NOT PATCH</Condition>
<Condition Action="hide">Installed AND PATCH</Condition>
<Condition Action="show">(NOT Installed OR NOT PATCH) AND NOT WIX_UPGRADE_DETECTED</Condition>
<Condition Action="hide">(Installed AND PATCH) OR WIX_UPGRADE_DETECTED</Condition>
</Control>
<Control Id="Wallet" Type="Text" X="135" Y="154" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="- You have an ERC20 compatible wallet to receive payouts" >
<Condition Action="show">NOT Installed OR NOT PATCH</Condition>
<Condition Action="hide">Installed AND PATCH</Condition>
<Condition Action="show">(NOT Installed OR NOT PATCH) AND NOT WIX_UPGRADE_DETECTED</Condition>
<Condition Action="hide">(Installed AND PATCH) OR WIX_UPGRADE_DETECTED</Condition>
</Control>
<Control Id="PortForwarding" Type="Text" X="135" Y="166" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="- You've configured port forwarding for your storage node" >
<Condition Action="show">NOT Installed OR NOT PATCH</Condition>
<Condition Action="hide">Installed AND PATCH</Condition>
<Condition Action="show">(NOT Installed OR NOT PATCH) AND NOT WIX_UPGRADE_DETECTED</Condition>
<Condition Action="hide">(Installed AND PATCH) OR WIX_UPGRADE_DETECTED</Condition>
</Control>
<Control Id="LearnMoreLink" Type="Hyperlink" X="135" Y="181" Width="320" Height="16" Transparent="yes">
<Text><![CDATA[<a href="https://documentation.storj.io/setup/gui-windows">Learn more</a>]]></Text>
<Condition Action="show">NOT Installed OR NOT PATCH</Condition>
<Condition Action="hide">Installed AND PATCH</Condition>
<Condition Action="show">(NOT Installed OR NOT PATCH) AND NOT WIX_UPGRADE_DETECTED</Condition>
<Condition Action="hide">(Installed AND PATCH) OR WIX_UPGRADE_DETECTED</Condition>
</Control>
<Control Id="ClickNextInstruction" Type="Text" X="135" Y="208" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="Click Next to continue or Cancel to exit the Setup Wizard." >
<Condition Action="show">NOT Installed OR NOT PATCH</Condition>
<Condition Action="hide">Installed AND PATCH</Condition>
<Condition Action="show">(NOT Installed OR NOT PATCH) AND NOT WIX_UPGRADE_DETECTED</Condition>
<Condition Action="hide">(Installed AND PATCH) OR WIX_UPGRADE_DETECTED</Condition>
</Control>
<!-- Patch text -->
<Control Id="PatchDescription" Type="Text" X="135" Y="80" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.WelcomeUpdateDlgDescriptionUpdate)" >
<Condition Action="show">Installed AND PATCH</Condition>
<Condition Action="hide">NOT Installed OR NOT PATCH</Condition>
<Condition Action="show">(Installed AND PATCH) AND NOT WIX_UPGRADE_DETECTED</Condition>
<Condition Action="hide">(NOT Installed OR NOT PATCH) OR WIX_UPGRADE_DETECTED</Condition>
</Control>
<Control Id="Title" Type="Text" X="135" Y="20" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.WelcomeDlgTitle)" />
</Dialog>