Discussion
Sergey Mikhailenko · Feb 21, 2021

Install ZPM in one line

Hi developers.
I often miss the ZPM program on a clean system.
Nothing complicated? Take and install.
And in one line? Especially in a docker container.
There is a solution. I'm very happy with it;)
Maybe the line can be shortened?

set $namespace="%SYS", name="DefaultSSL" do:'##class(Security.SSLConfigs).Exists(name) ##class(Security.SSLConfigs).Create(name) set url="https://pm.community.intersystems.com/packages/zpm/latest/installer" Do ##class(%Net.URLParser).Parse(url,.comp) set ht = ##class(%Net.HttpRequest).%New(), ht.Server = comp("host"), ht.Port = 443, ht.Https=1, ht.SSLConfiguration=name, st=ht.Get(comp("path")) quit:'st $System.Status.GetErrorText(st) set xml=##class(%File).TempFilename("xml"), tFile = ##class(%Stream.FileBinary).%New(), tFile.Filename = xml do tFile.CopyFromAndSave(ht.HttpResponse.Data) do ht.%Close(), $system.OBJ.Load(xml,"ck") do ##class(%File).Delete(xml)
8
1 554
Discussion (12)2
Log in or sign up to continue

Nice!  Only 666 characters in sequence. 
A mystic number  devil  yes I like it

Oh, how unexpected! Let's cut it down a bit to get another nice number of characters.

zn "%SYS",n="SL" d:'##class(Security.SSLConfigs).Exists(n) ##class(Security.SSLConfigs).Create(n) s u="https://pm.community.intersystems.com/packages/zpm/latest/installer" D ##class(%Net.URLParser).Parse(u,.c) s h=##class(%Net.HttpRequest).%New(),h.Server=c("host"),h.Port=443,h.Https=1,h.SSLConfiguration=n,s=h.Get(c("path")) q:'s $System.Status.GetErrorText(s) s x=##class(%File).TempFilename("xml"),f=##class(%Stream.FileBinary).%New(),f.Filename=x d f.CopyFromAndSave(h.HttpResponse.Data) d h.%Close(),$system.OBJ.Load(x,"ck") do ##class(%File).Delete(x)

I think, there is a "small problem" at start...

zn "%SYS",n=SL ...

will not work as expected ;-))

but what about this line with 552 chars

zn "%SYS" s n="SL" d ##class(Security.SSLConfigs).Create(n):'##class(Security.SSLConfigs).Exists(n),##class(%Net.URLParser).Parse("https://pm.community.intersystems.com/packages/zpm/latest/installer",.c) s h=##class(%Net.HttpRequest).%New(),h.Server=c("host"),h.Port=443,h.Https=1,h.SSLConfiguration=n,s=h.Get(c("path")) q:'s $System.Status.GetErrorText(s) s x=##class(%File).TempFilename("xml"),f=##class(%Stream.FileBinary).%New(),f.Filename=x d f.CopyFromAndSave(h.HttpResponse.Data) d h.%Close(),$system.OBJ.Load(x,"ck") do ##class(%File).Delete(x)

I only rewrote your line, but haven't tried to execute

Bravo for this initiative.

For your information, this is at least the 5th or 6th time that I return to this page to use this magic command :)

Hi, Guillaume!
It’s very nice, I scattered this code in all my projects on openexchange, so that it was always at hand

By the way, I saw a shorter line from Sergei Shutov:

zn "%SYS" d ##class(Security.SSLConfigs).Create("z") s r=##class(%Net.HttpRequest).%New(),r.Server="pm.community.intersystems.com",r.SSLConfiguration="z" d r.Get("/packages/zpm/latest/installer"),$system.OBJ.LoadStream(r.HttpResponse.Data,"c")

I tried the line on my local windows IRIS install and I am getting the following error...

ERROR #5002: ObjectScript error: <METHOD DOES NOT EXIST>zGetInstallerProperties+11^%ZPM.PackageManager.Developer.Utils.1 *%GetData,%SQL.StatementResult
  > ERROR #5574: Error reported while running generator for parameter '%ZPM.PackageManager.Developer.Processor.CSPApplication:ATTRIBUTES'
    > ERROR #5030: An error occurred while compiling class '%ZPM.PackageManager.Developer.Processor.CSPApplication'
Detected 1 errors during load.
2022-06-30 14:58:21 0 %ZPM.Installer: ERROR #5002: ObjectScript error: <METHOD DOES NOT EXIST>zGetInstallerProperties+11^%ZPM.PackageManager.Developer.Utils.1 *%GetData,%SQL.StatementResult
  > ERROR #5574: Error reported while running generator for parameter '%ZPM.PackageManager.Developer.Processor.CSPApplication:ATTRIBUTES'
    > ERROR #5030: An error occurred while compiling class '%ZPM.PackageManager.Developer.Processor.CSPApplication'
2022-06-30 14:58:21 0 %ZPM.Installer: Installation failed at 2022-06-30 14:58:21
2022-06-30 14:58:21 0 %Installer: Elapsed time 10.222858s
Time spent 10.295294
ERROR #5002: ObjectScript error: <METHOD DOES NOT EXIST>zGetInstallerProperties+11^%ZPM.PackageManager.Developer.Utils.1 *%GetData,%SQL.StatementResult
  > ERROR #5574: Error reported while running generator for parameter '%ZPM.PackageManager.Developer.Processor.CSPApplication:ATTRIBUTES'
    > ERROR #5030: An error occurred while compiling class '%ZPM.PackageManager.Developer.Processor.CSPApplication'
      > ERROR #5090: An error has occurred while creating projection %ZPM.Installer:Reference.
Detected 1 errors during load.

Sorry.... HealthShare HealthConnect 

IRIS for Windows (x86-64) 2022.1 (Build 209U) Tue May 31 2022 12:16:40 EDT

I figured it out, it would not allow me to do it under Admin or _system. When I added myself to my local machine and made sure I had all privs, it allowed me to execute it without issue.