Synology

This page regroups stuff that I have done on my synology to make it my "low power" server at home.

Bootstrap your synology: install optware

First step is to install optware so that with ipkg packet manager you can install a lot of useful programs/services and an environment to compile natively on the synology programs that are lacking in optware distribution:

Make sftp work

For some reason openssh package does not provide sftp, in order to enable it install:

ipkg install openssh-sftp-server

and add in /opt/etc/openssh/sshd_config the missing sftp command reference:

Subsystem sftp /volume1/@optware/libexec/sftp-server

Backup your data with history: rsnapshot

rsnapshot is an rsync based backup system that I like: it is simple yet efficient.

Install it with:

ipkg install rsnapshot

Configure it and make sure that rsync used is the synology one i.e. /usr/syno/bin/rsync and that you use the --syno-acl option if you are keen to preserve any windows ACL in the backup process (not my case because I want the rename detection feature explained above).

restrict synology's apache to respectively use port 8080/8443 instead of 80/443 to let them free for ipkg's apache by modifying /usr/syno/apache/conf/httpd.conf-user and /usr/syno/apache/conf/extra/httpd-ssl.confListen directive:

copy the necessary server certificate and key in the apache directory:

cp server.key server.crt /opt/etc/apache2/ssl/

be sure that apache does use them by editing /opt/etc/apache2/extra/httpd-ssl-vhost-user.conf and checking that the right patch is used

SSLCertificateFile /opt/etc/ssl/server.crt

SSLCertificateKeyFile /opt/etc/ssl/server.key

restart apache

/opt/sbin/apachectl stop/opt/sbin/apachectl start

Protect via https some internal http services

Somtimes you have some service that has a web interface on a specific port (e.g. http://192.168.0.2:1234/servicehttp) but not supporting https that you do not want to expose directly to the outside world in order not to have your password in the clear. In order to overcome this issue you can use the proxy feature of apache by editing /opt/etc/apache2/extra/httpd-ssl-vhost-user.confthe following way:

SSLProxyEngine on

ProxyRequests Off

ProxyVia Off

<Proxy *>

Order deny,allow

Allow from all

</Proxy>

<Location /servicehttp>

Order deny,allow

Allow from all

AuthName "Private area"

AuthType Basic

AuthUserFile /opt/etc/apache2/htpasswd

Require valid-user

ProxyPass http://192.168.0.2:1234/servicehttp

ProxyPassReverse http://192.168.0.2:1234/servicehttp

SSLRequireSSL

</Location>

Create login and password using the following command /opt/sbin/htpasswd /opt/etc/apache2/htpasswd username

If you do not want to open some ports on your router and forward them to your synology NAS to enable remote access (e.g. 7001 and 5001) you can use the proxy feature of apache to do it by simply editing /opt/etc/apache2/extra/httpd-ssl-vhost-user.conf the following way:

ProxyPass /filestation https://192.168.0.2:7001/

ProxyPassReverse /filestation/ https://192.168.0.2:7001/

ProxyPass /synology https://192.168.0.2:5001/

ProxyPassReverse /synology/ https://192.168.0.2:5001/

Install other sources of packages on synology web interface

Synocommunity is a great source of packages to add to the ones provided by synology.

Interesting packages like transmission can be found that is a good replacement of synology's download station.

Files renaming

I use two tools that I find handy;

perl-file-rename that I find extremely useful and powerful that handles regexp

Automatic rss based file downloading

flexget is a good tool and easy to configure to automate file download based on rss feed matching names.

It can be installed by:

ipkg install sqlite

easy_install flexget

A typical user configuration can be the following:

cat .flexget/config.yml

presets:

global:

transmission:

host: localhost

port: 9091

username: username

password: password

email:

active: True

from: flexget@yourdomain.com

to: user@yourdomain.com

smtp_host: smtp.yourdomain.com

smtp_port: 25

smtp_login: false

tv:

quality: webdl|hdtv <720p

series:

- Serie name one

- Serie name two

tasks:

stream1:

rss: http://streamsiteone.com/feed/

preset: tv

priority: 10

stream2:

rss: http://streamsitetwo.com/?cat=9

preset: tv

priority: 20

In order to check flexget configuration you can issue:

flexget --check

Launch of flexget task can be automated using cron job, edit /etc/crontab and add:

007***root/opt/local/bin/flexget --cron >/dev/null 2>&1

Relaunch cron service through:

/usr/syno/etc/rc.d/S04crond.sh stop

/usr/syno/etc/rc.d/S04crond.sh start

If you want to update flexget in the future just do:

pip install --upgrade flexget

If you experience some issues with seen status or database you can reset it with the following command that should be used only as a last resort:

flexget --reset

Disable power/memory hungry media indexing and thumbnail generation

/usr/syno/etc/rc.d/S??synoindexd.sh stop

/usr/syno/etc/rc.d/S??synomkflvd.sh stop

/usr/syno/etc/rc.d/S??synomkthumbd.sh stop

killall -9 convert

killall -9 ffmpeg

chmod a-x /usr/syno/etc/rc.d/S??synoindexd.sh

chmod a-x /usr/syno/etc/rc.d/S??synomkflvd.sh

chmod a-x /usr/syno/etc/rc.d/S??synomkthumbd.sh

Alternatively you can respectively rename the variables SYNOMKTHUMBD, SYNOMKFLVD in the above files so that it does nothing.

Note that the above steps need to be reiterated at each synology software update...

Fill mkv stereo-mode field correctly for Archos Video Player to turn your TV into right 3D mode

If you happen to have an Archos TV connect and a 3D capable TV (I strongly recommend 3D passive technology) and want to have your TV switched to the appropriate 3D mode automagically you can fill the right field value of your mkv file using this process:

install mkv tools:

ipkg install mkvtoolnix

find the right video track using:

mkvinfo file.mkv

Let's assume for the example sake that track1 contains the video

assign the right value for the stereo-mode field of the mkv depending on the type of video:

Transmission tweaks

If you have installed transmission through Synocommunity your configuration file is located here: /volume1/@appstore/transmission/var/settings.json. Make sure to stop transmission on the synology web interface or using the below commands before editing this file so that your modifications are taken into account:

/var/packages/transmission/scripts/start-stop-status stop

vi /volume1/@appstore/transmission/var/settings.json

/var/packages/transmission/scripts/start-stop-status start

learn to use transmission-remote located here: /volume1/@appstore/transmission/bin/transmission-remote

periodically you can check if your download and seed is complete based on your seedratio and then decide to move the completed files somewhere and remove it from transmission. This script does this for you:

Useful tools

replace dumb vi by vim

ipkg install vim

ln -s /opt/bin/vim /opt/bin/vi

Toubleshooting: if your synology is not booting anymore

It happened to me that the synology didn't boot anymore or asks to be migrated under synology assistant. If your synology is in that state verify that you have not swapped the disks... and it is always possible to telnet to the synology using this synology secret password that changes everyday.

Note that your synology might be stuck in 1/11970 and this corresponds to password 101-0101.