Synology Package Sample to illustrate how scripts and wizards are executed

I had troubles to use variables in various scripts or to create wizards via shell scripts. So I have created a dummy package logging useful information in a file to understand what’s going on during the installation, the upgrade and the uninstallation of a Synology Package.

Click to Read More

This package is named MODS SPK Tracer and is available on my SPK Server. Obviously, i has been created with my Synology Package Creator tool for Windows 😉

Once installed, upgraded or removed (and obviously reinstalled), you can access its log file either by clicking on its icon in DSM’s Main Menu, or by via the Package Center.

Mods SPK Tracer

This package comes with shell scripts creating on the fly “installation”, “upgrade” and “uninstallation” wizard (,, The purpose is to illustrate how to inject environment variables in the JSON wizard and how to use php in such scripts. Briefly said, they must generate a JSON wizard and store it in the standard log file $SYNOPKG_TEMP_LOGFILE

While testing those wizard scripts, I have discovered that, at runtime, only the running script is stored in the temporary folder. The other ones are not available. No way therefore to call another script from the running one.

The Wizards are exporting one variable to the installation scripts, for illustration purpose (I.e.: how to prompt the user for some input to be used later by the scripts)

Finally, the wizard scripts also logs the environment variables exported for them by the DSM. Not a lot are available during the execution of the wizard because the SPK is actually not yet expanded.

The package comes next with the standard installation scripts, calling all a generic script that log the environment variables exported for them by the DSM. So, you can see in which script you have access to which variable. The scripts preinst, postinst, preuninst, postuninst, preupgrade and postupgrade have access to the same variables. But it’s not the case for the start-stop-status script.

Those scripts are also displaying info during the installation/upgrade/uninstallation process for the user. For that purpose, they write in the standard log file $SYNOPKG_TEMP_LOGFILE. Obviously the wizard scripts can’t use this trick to display information to the user. But they don’t need that as they actually display real screens (rendition of their JSON).

Notice: often, variables accessible for a script must be persisted in a file to be retrieved later by another script. Ex.: the postinst script can store a variable received from the install_uifile wizard in a file so it can be read by the postupgrade or postuninst script later.

Notice: the log file is only available in the Package Center if its path is returned by the start-stop-status script.

Notice: the INFO file of this Package is quite standard.

What’s interesting is to see the order of execution. Ex.: for an upgrade

SPK Tracer order

Also, during an upgrade, the script to stop, preuninst and postuninst are the versions of the previous package, not the versions of the new package !!! (Obviously).

During an upgrade, preupgrade and preinst scripts are executed from a temporary folder (/volume1/@tmp/pkginstall/scripts), while postupgrade, postinst, and the script to start, are executed from the target installation directory (/var/packages/<Package Name>/scripts)





Leave a Reply

Your email address will not be published. Required fields are marked *