Synology: My Own Knowledge Base

I always forget plenty of details useful to work on my Synology, such as path, tips & tricks, command or service names, etc.. So, to retrieve them more easily, I will publish them here.

Click to Read More

Post under construction…

Connect on a Synology

  • via SSH console: see here
  • via GateOne on DSM: see here

Synology Commands

  • Located in /usr/syno and /usr/syno/sbin resp. for binaries and script requiring root privileges
  • Interesting scripts in /usr/syno/etc.defaults/rc.sysv/ (to be used as root)
    • ./apparmor.sh {start|stop|restart|try-restart|reload|force-reload|status|kill|add_packages_profile|remove_packages_profile}
    • ./share-preapre.sh start
    • ./sftp.sh reload
    • ./tfpt.sh reload
    • ./ningx.sh reload
    • ./synomount.sh {start|stop}
    • ./pgsql.sh {start|stop|restart|reload|status}
    • ./S80samba.sh {start|stop}
    • ./S83nfsd.sh {start|stop}
    • ./inetd.sh { prestart_telnetd | poststop_telnetd | prestart_cups_lpd | poststop_cups_lpd }

Other command paths:

Interesting Paths

  • Web folder: /var/services/web
    • Reference onto /volumex/web
  • Package folder: /var/packages/<Package Name>
    • See 3rd Party Packages bellow
  • Link onto all 3rd party packages
    • /usr/syno/synoman/webman/3rdparty

Synology Services

  • Names:
    • Packages’ service name: pkgctl-<package>
    • Ex.: pkgctl-WebStation
    • For others, execute: /usr/syno/sbin/synoservicecfg –list
  • Config
    • path: /usr/syno/etc/synoservice.d/<service>
  •  Commands:

Need to be root:

    • /usr/syno/sbin/synoservice −−help
    • /usr/syno/sbin/synoservicecfg −−help (alias of above)
    • /usr/syno/sbin/synoservicectl −−help (limited features of above)
    • /usr/syno/sbin/synoservicemigrate −−help
    • Ex.: synoservice −−restart pkgctl-WebStation

No need to be root:

    • /usr/syno/sbin/synopkg
    • /usr/syno/sbin/synopkgctl
  •  Status for Packages:
    • Each service has a file named “enabled” which is created when the service is started via the Packager Center UI (/var/packages/<package>/enabled).
    • This file is deleted once one stops the service via the Package Center UI.
    • This file is not deleted if one stops the service with the command line /usr/syno/sbin/synoservicecfg –stop pkgctl-<package>
    • This ile is not recreated if one (re)starts the service with the command line /usr/syno/sbin/synoservicecfg –start pkgctl-<package>
    • Command line ex.:
      • /usr/syno/sbin/synoservicecfg –stop “pkgctl-AudioStation”
      • output: warn: The runkey of service [pkgctl-AudioStation] has been set to “No”
      • /usr/syno/sbin/synoservicectl –stop “pkgctl-AudioStation”
      • output: pkgctl-AudioStation stoped.
  • List all Services
    • /usr/syno/sbin/synoservicecfg –list
    • /usr/syno/sbin/synoservicecfg –list-config
  • More options
    • /usr/syno/sbin/synoservicecfg —help-dev

3rd Party Packages

  • Access path: /usr/syno/synoman/webman/3rdparty/
    • This is a link to the binaries/web page/scripts of the actual application to run.
    • ls -la /usr/syno/synoman/webman/3rdpart/<packagename> will give you the actual path
  • Access Url: http://<YourNas>:<Admin Port>/webman/3rdparty/<Package Name>/….
    • To check the URL of a 3rd Party Package, simply Right Click on it in DSM’s Main Menu and select “Open in new window”
  • Setup path (scripts, config, enabled “flag”, INFO): /var/packages/<package>/
    • This is the location of all info used be DSM to install, access and run the package
    • Link onto the package itself /var/packages/<package>/target => /volume<x>/@appstore/<Package Name>
      • target/ is only created after the installation and can therefore not be used in Package’s pre-installation script.
    • Link onto the package configuration : /var/packages/<package>/etc => /usr/syno/etc/packages/<Package Name>
      • etc/ is only created after the installation and can therefore not be used in Package’s pre-installation script.
  • Installation path: /volume<x>/@appstore/<package>
    • This is the path to the binaries/web page/scripts of the application.
    • Found via: ls -la /var/packages/<package>/target
  • Configuration path: /usr/syno/etc/packages/<package>
    • This is the path where the configuration settings of the application can be stored.
    • This path is not deleted during an upgrade/uninstallation.
    • Found via: ls -la /var/packages/<package>/etc
  • List the custom feeds: cat /usr/syno/etc/packages/feeds

So, concretely, the structure of a Package Folder under /var/packages/<Package name> is like:

  • conf/
  • enabled
  • etc -> /usr/syno/etc/packages/<Package name>
  • INFO
  • scripts/
    • postinst
    • postuninst
    • postupgrade
    • preinst
    • preuninst
    • preupgrade
    • start-stop-status
  • target -> /volume<x>/@appstore/<Package name>
  • WIZARD_UIFILES/
    • install_uifile or install_uifile.sh
    • uninstall_uifile or uninstall_uifile.sh
    • upgrade_uifile or upgrade_uifile.sh
    • NB.: each file can be postfixed with the language. Ex.: install_uifile_enu or install_uifile_fre

NB: Sometimes, ‘target’ can be a link on -> /usr/local/packages/@appstore/<Package name>

Volumes

  • Volume Raid storage calculator: https://www.synology.com/fr-fr/support/RAID_calculator

Logs

  • Main Log path: /var/log/
  • Package installation log: /var/log/synopkg.log
  • Services log:  /var/log/synoservice.log
  • Services’ path start/stop logs: /var/log/startup
  • Apache’s log: /usr/local/etc/apache22/logs /usr/local/etc/apache24/logs
  • nginx’s log: /var/log/nginx/

If something goes wrong and you look for information, delete all existing logs (rm -R) and redo the failing operation. Next, look for newly created logs 😉

Web Server

The Web server can be nginx, apache22 or apache24, as:

  • Configured globally in the Web Station > General Settings > HTTP back end Server or
  • Configure per Virtual Host in Web Station > Virtual Host

Config files are per Web server types:

  • Apache 22’s configs are under /usr/local/etc/apache22. Ex.:
    • virtualhost config file: /usr/local/etc/apache22/sites-enabled/httpd-vhost.conf (notice: changes in this file are lost after restarting the Web Station)
    • httpd conf file:  /usr/local/etc/apache22/conf/httpd22.conf
  • Apache 24’s configs are under /usr/local/etc/apache24
  • Nginx’s configs are under usr/local/etc/nginx

But also in the Web Station configs:

  • Virtual Host, depending if using php56 or php 70, are also in  /var/packages/WebStation/etc/php56/conf.d/webstation_vhost.ini (notice: changes in this file are lost after restarting the Web Station)

Restart Web Server:

  • synoservicecfg restart nginx
  • synoservice restart pkgctl-Apache2.4
  • synoservice restart pkgctl-WebStation

Interesting website info here.

Plex Server

  • Plex Media Server data path: /Volume<x>/Plex/Library/Application Support/Plex Media Server/
  • Complete Server Backup:
    • Stop Plex Media Server (via the Package Center)
    • Copy the directory mentioned above to backup Plex’s database et configuration.
    • Restart Plex Media Server
  • Database Backup:
    • Backups are in /Volume<x>/Plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/
    • Stop Plex Media Server (via the Package Center)
    • Move away the followin file
      • com.plexapp.plugins.library.db
      • com.plexapp.plugins.library.db-shm
      • com.plexapp.plugins.library.db-wal
    • Rename the latest (or any older) com.plexapp.plugins.library.db-YYYY-MM-DD into com.plexapp.plugins.library.db
    • Restart Plex Media Server

Synology Certificates

They are (in most recent DSM version) under /usr/syno/etc/certificate/system

Synology Model

Notifications

  • Notification messages: /usr/syno/synoman/webman/texts/enu/mails
  • Notification sending mode: /usr/syno/etc/notification/notification_filter.settings
  • Other Notification messages (unknown usage): /usr/local/share/notification/dsm/enu/mails
  • Command:
    • /usr/syno/bin/synonotify <notification>  ‘{“[%VAR1%]”: “value1”, “[%VAR2%]”: “value2”}’
  • Debugging:
    • syno_hibernate_debug_tool –enable 10
    • syno_hibernate_debug_tool –disable

Event Logs

  • Event messages: Events : /usr/syno/synosdk/texts/enu/events
  • Command:
    • synologset1 [sys | man | conn] [info | warn | err] eventID(%X) [substitution strings…]

Package Installation scripts

  • Documentation about installation scripts are here .
  • The etc folder of the package is a link onto /usr/syno/etc/packages/<Package Name>/
  • A script must exit 0 to succeed. Any other value will fail the installation/upgrade/uninstallation.
  • One can redirect all errors into the log with code like this:

exec 2<&-
exec 2>>/var/log/MyPackageErr.log

  • All information logged in $SYNOPKG_TEMP_LOGFILE are displayed at the end of the installation/upgrade/uninstallation in any cases (success or failure).
  • Add a <br> at the end of each line in $SYNOPKG_TEMP_LOGFILE to have a nice display. Ex.: sed -i ‘s/$/<br>/’ “$SYNOPKG_TEMP_LOGFILE”
  • One can decide to fail an installation/upgrade/uninstallation with code like this:

if [ -s “/var/log/MyPackageErr.log” ]; then
sed -i ‘s/$/<br>/’ “/var/log/MyPackageErr.log”
cat /var/log/MyPackageErr.log >> $SYNOPKG_TEMP_LOGFILE
exit 1
fi

  • Add or Remove an port configuration in the firewall by command:

SERVICETOOL=”/usr/syno/bin/servicetool”
FWPORTS=”/var/packages/<Package Name>/scripts/<Package Name>.sc”

In the ‘posinst’ script:

${SERVICETOOL} –install-configure-file –package ${FWPORTS} >> /dev/null

In the ‘preuninst’ script:

if [ “${SYNOPKG_PKG_STATUS}” == “UNINSTALL” ]; then
${SERVICETOOL} –remove-configure-file –package $<Package Name>.sc >> /dev/null
fi

The structure of the <Package Name>.sc file is described here https://help.synology.com/developer-guide/integrate_dsm/install_ports.html

Following ports are used by Synology : https://www.synology.com/en-us/knowledgebase/DSM/tutorial/Network/What_network_ports_are_used_by_Synology_services

Using commands is only required with firmware version < 6.0-5936

Loading


Categories:

Tags:


Comments

2 responses to “Synology: My Own Knowledge Base”

  1. Tosko Avatar
    Tosko

    Hi , thank you for this useful info

    Do you know by chance how to mount encrypted share via ssh ?

    Regards

Leave a Reply

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