Skip to content

Commit 5e5bb6a

Browse files
committed
pritunl-client: Refactor manifest
* Add arm64 version * Update checkver & autoupdate * Refactor service management logic
1 parent 1fc74ab commit 5e5bb6a

1 file changed

Lines changed: 109 additions & 28 deletions

File tree

bucket/pritunl-client.json

Lines changed: 109 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,131 @@
11
{
22
"version": "1.3.4466.51",
3-
"description": "OpenVPN Client",
3+
"description": "A free and open source cross platform OpenVPN client.",
44
"homepage": "https://client.pritunl.com",
55
"license": {
66
"identifier": "Freeware",
7-
"url": "https://github.com/pritunl/pritunl-client-electron/blob/master/LICENSE"
7+
"url": "https://github.com/pritunl/pritunl-client-electron/blob/HEAD/LICENSE"
88
},
9+
"suggest": {
10+
"Microsoft Visual C++ 2015-2022 Redistributable": "extras/vcredist2022"
11+
},
12+
"url": "https://github.com/pritunl/pritunl-client-electron/releases/download/1.3.4466.51/Pritunl.exe#/dl.exe",
13+
"hash": "sha512:704afa0da898efc80aa9897b2cd0d5df8e4732382e0ee5d31461c3d3b80abb68a05a3c6f155039af264619e8a85014c60421400cd75d3d7db512e19040b74f40",
14+
"innosetup": true,
915
"architecture": {
1016
"64bit": {
11-
"url": "https://github.com/pritunl/pritunl-client-electron/releases/download/1.3.4466.51/Pritunl.exe#/dl.exe",
12-
"hash": "d6b43bf1832d2f2f3f44d7942bb9d6a6c32f17ec4acc711a2458daa8db7cda8b"
17+
"installer": {
18+
"script": [
19+
"Get-ChildItem -Path $dir -Include '*,2*' -Recurse -File | Remove-Item -Force -ErrorAction SilentlyContinue",
20+
"Get-ChildItem -Path $dir -Include '*,1*' -Recurse -File | Rename-Item -NewName { $_.Name -replace ',\\d', '' }"
21+
]
22+
}
23+
},
24+
"arm64": {
25+
"installer": {
26+
"script": [
27+
"Get-ChildItem -Path $dir -Include '*,1*' -Recurse -File | Remove-Item -Force -ErrorAction SilentlyContinue",
28+
"Get-ChildItem -Path $dir -Include '*,2*' -Recurse -File | Rename-Item -NewName { $_.Name -replace ',\\d', '' }"
29+
]
30+
}
1331
}
1432
},
15-
"innosetup": true,
16-
"pre_install": "if (-not (is_admin)) { error 'This package requires admin privileges to install'; break }",
17-
"post_install": "Invoke-ExternalCommand \"$dir\\post_install.exe\" -RunAs | Out-Null",
18-
"uninstaller": {
19-
"script": [
20-
"if (-not (is_admin)) { error 'This package requires admin privileges to uninstall'; break }",
21-
"Invoke-ExternalCommand \"$dir\\pre_uninstall.exe\" -RunAs | Out-Null",
22-
"Remove-Item 'C:\\ProgramData\\Pritunl' -Recurse -Force"
23-
]
24-
},
33+
"pre_install": "if (-not (is_admin)) { abort \"`n[ERROR] $app requires admin rights to $cmd.\" }",
34+
"post_install": [
35+
"$service_name = 'pritunl'",
36+
"$path_regex = [regex]::Escape((Split-Path -Path $dir -Parent))",
37+
"Start-Service -Name $service_name -ErrorAction SilentlyContinue",
38+
"if ($PSVersionTable.PSVersion -ge [version]::new(6, 0)) {",
39+
" $services = Get-Service -Name $service_name -ErrorAction SilentlyContinue",
40+
"} else {",
41+
" $name_filter = \"Name = '$service_name'\"",
42+
" $services = Get-CimInstance -ClassName Win32_Service -Filter $name_filter -ErrorAction SilentlyContinue |",
43+
" Select-Object -Property *, @{ Name = 'BinaryPathName'; Expression = { $_.PathName } }",
44+
"}",
45+
"$service = $services | Where-Object { $_.BinaryPathName -match $path_regex }",
46+
"if ($service -and @($service.Status, $service.State) -contains 'Running') { return }",
47+
"if ($service) { abort \"`n[ERROR] Service '$service_name' exists but failed to start. Installation terminated.\" }",
48+
"if ($services) {",
49+
" Write-Host \"`nINFO Identified a stale or conflicting service instance. Initiating removal...\" -ForegroundColor DarkGray",
50+
" Stop-Service -Name $service_name -Force -ErrorAction SilentlyContinue; Start-Sleep -Milliseconds 1500",
51+
" if ($PSVersionTable.PSVersion -ge [version]::new(6, 0)) {",
52+
" Remove-Service -Name $service_name -ErrorAction SilentlyContinue",
53+
" } else {",
54+
" Start-Process -FilePath 'sc.exe' -ArgumentList @('delete', $service_name) -NoNewWindow -Wait",
55+
" }",
56+
" $timer = [System.Diagnostics.Stopwatch]::StartNew()",
57+
" while ($timer.Elapsed.TotalSeconds -lt 16) {",
58+
" $current_elapsed = $timer.Elapsed.TotalSeconds",
59+
" $percent = [System.Math]::Min(($current_elapsed / 15) * 100, 100)",
60+
" $progress_params = @{",
61+
" Activity = 'Service Management'; PercentComplete = $percent",
62+
" CurrentOperation = \"Elapsed: $current_elapsed s / Timeout: 15 s\"",
63+
" Status = \"Waiting for '$service_name' to be fully de-registered...\"",
64+
" }",
65+
" $check = Get-Service -Name $service_name -ErrorAction SilentlyContinue",
66+
" if ($null -eq $check) {",
67+
" $progress_params['Status'] = 'Service successfully uninstalled.'",
68+
" $progress_params['PercentComplete'] = 100",
69+
" $progress_params['Completed'] = $true",
70+
" Write-Progress @progress_params",
71+
" break",
72+
" }",
73+
" Write-Progress @progress_params",
74+
" Start-Sleep -Milliseconds 2500",
75+
" }",
76+
" $timer.Stop()",
77+
" abort 'Please reboot your computer to complete the uninstallation, then try again.'",
78+
"}",
79+
"$service_config = @{",
80+
" Name = $service_name",
81+
" BinaryPathName = \"`\"$dir\\pritunl-service.exe`\"\"",
82+
" DisplayName = 'Pritunl Client Helper Service'",
83+
" Description = 'Provides core helper functions for the Pritunl VPN client. Disabling this service will prevent the Pritunl client from functioning correctly.'",
84+
" StartupType = 'Automatic'",
85+
"}",
86+
"New-Service @service_config | Out-Null",
87+
"$failure_actions = [byte[]](",
88+
" 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,",
89+
" 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xb8, 0x0b, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,",
90+
" 0x88, 0x13, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x88, 0x13, 0x00, 0x00",
91+
")",
92+
"$registry_path = \"HKLM:\\SYSTEM\\CurrentControlSet\\Services\\$service_name\"",
93+
"Set-ItemProperty -Path $registry_path -Name 'FailureActions' -Value $failure_actions",
94+
"Set-ItemProperty -Path $registry_path -Name 'FailureActionsOnNonCrashFailures' -Value 1",
95+
"Start-Service -Name $service_name -ErrorAction SilentlyContinue"
96+
],
2597
"bin": [
26-
[
27-
"pritunl.exe",
28-
"pritunl",
29-
"--no-main"
30-
]
98+
"pritunl.exe",
99+
"pritunl-client.exe"
31100
],
32101
"shortcuts": [
33102
[
34103
"pritunl.exe",
35104
"Pritunl"
36105
]
37106
],
38-
"checkver": "([\\d.]+)/Pritunl.exe",
107+
"pre_uninstall": "if (-not (is_admin)) { abort \"`n[ERROR] $app requires admin rights to $cmd.\" }",
108+
"uninstaller": {
109+
"script": [
110+
"Stop-Service -Name 'pritunl' -Force -ErrorAction SilentlyContinue",
111+
"Stop-Process -Name 'pritunl', 'pritunl-service' -Force -ErrorAction SilentlyContinue",
112+
"Start-Sleep -Milliseconds 1500",
113+
"if ($cmd -ne 'uninstall') { return }",
114+
"if ($PSVersionTable.PSVersion -lt [Version]::new(6, 0)) {",
115+
" Start-Process -FilePath 'sc.exe' -ArgumentList @('delete', 'pritunl') -NoNewWindow -Wait",
116+
"} else {",
117+
" Remove-Service -Name 'pritunl' -ErrorAction SilentlyContinue",
118+
"}"
119+
]
120+
},
121+
"checkver": {
122+
"github": "https://github.com/pritunl/pritunl-client-electron"
123+
},
39124
"autoupdate": {
40-
"architecture": {
41-
"64bit": {
42-
"url": "https://github.com/pritunl/pritunl-client-electron/releases/download/$version/Pritunl.exe#/dl.exe",
43-
"hash": {
44-
"url": "https://raw.githubusercontent.com/pritunl/pritunl-client-electron/master/SHA256",
45-
"regex": "$version[\\r\\n]+$sha256.*?$basename"
46-
}
47-
}
125+
"url": "https://github.com/pritunl/pritunl-client-electron/releases/download/$version/Pritunl.exe#/dl.exe",
126+
"hash": {
127+
"url": "https://raw.githubusercontent.com/pritunl/pritunl-client-electron/HEAD/SHA512",
128+
"regex": "(?s)$version.+?$sha512.+?$basename"
48129
}
49130
}
50131
}

0 commit comments

Comments
 (0)