Packages Tutorial

Hello World Package

  1. Create a new package directory:
ubuntu-rs@ubuntu-rs:/workspace/git_zammad$ mkdir Example-HelloWorld
ubuntu-rs@ubuntu-rs:/workspace/git_zammad$ cd Example-HelloWorld/
  1. Init your github repository:
ubuntu-rs@ubuntu-rs:/workspace/git_zammad/Example-HelloWorld$ git init
  1. Setup a szpm dummy source file:
ubuntu-rs@ubuntu-rs:/workspace/git_zammad/Example-HelloWorld$ git zammad-new-szpm
ubuntu-rs@ubuntu-rs:/workspace/git_zammad/Example-HelloWorld$ cat example-hello_world.szpm
{
  "name": "Example-HelloWorld",
  "version": "1.0.0",
  "vendor": "Example GmbH",
  "license": "GNU AFFERO GENERAL PUBLIC LICENSE",
  "url": "http://example.com/",
  "files": []
}
  1. Now we need some kind of change. In this case we will just make a public text file visible on our zammad server:
ubuntu-rs@ubuntu-rs:/workspace/git_zammad/Example-HelloWorld$ mkdir -p public/assets/
ubuntu-rs@ubuntu-rs:/workspace/git_zammad/Example-HelloWorld$ echo "Hello World" > public/assets/hello.txt
  1. To update the file list of our szpm file, we can use our alias. It will update the file list for our szpm file:
ubuntu-rs@ubuntu-rs:/workspace/git_zammad/Example-HelloWorld$ git zammad-update-szpm
ubuntu-rs@ubuntu-rs:/workspace/git_zammad/Example-HelloWorld$ cat example-hello_world.szpm
{
  "name": "Example-HelloWorld",
  "version": "1.0.0",
  "vendor": "Example GmbH",
  "license": "GNU AFFERO GENERAL PUBLIC LICENSE",
  "url": "http://example.com/",
  "files": [
    {
      "location": "public/assets/hello.txt",
      "permission": 644
    }
  ]
}
  1. Now we want create our first release. The alias will take the szpm file and render all listed files as based64 encoded files into our first release 1.0.0:
ubuntu-rs@ubuntu-rs:/workspace/git_zammad/Example-HelloWorld$ git zammad-create-zpm 1.0.0
ubuntu-rs@ubuntu-rs:/workspace/git_zammad/Example-HelloWorld$ cat example-hello_world-1.0.0.zpm
{
  "name": "Example-HelloWorld",
  "version": "1.0.0",
  "vendor": "Example GmbH",
  "license": "GNU AFFERO GENERAL PUBLIC LICENSE",
  "url": "http://example.com/",
  "files": [
    {
      "location": "public/assets/hello.txt",
      "permission": 644,
      "encode": "base64",
      "content": "SGVsbG8gV29ybGQK"
    }
  ]
}

As you can see, the data of the file needs to be base64 encoded. Be aware that my test scripts are very basic and only to simplify the explanation here. However, we can
use this file to update our zammad and get our file deployed.

  1. Take your final example-hello_world-1.0.0.zpm and install it in your zammad (Admin → Packages).

systemctl restart zammad Should always run after the installation of a package

  1. Your file is now available in your zammad e.g:

https://rolf.zammad.com/assets/hello.txt

2 Likes