This page regroups stuff that I have done on my synology to make it my "low power" server at home.Bootstrap your synology: install optwareFirst 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:
ipkg install optware-devel mkdir /volume1/@src In terms of directory structure, I use The path I use is the following one for the users: export PATH=/opt/local/bin:/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/syno/bin:/usr/syno/sbin export LD_LIBRARY_PATH=/lib:/usr/lib:/opt/lib:/opt/local/lib Mosh native compilation on synologySince the mobile shell mosh is not part (yet) of optware packages, I decided to compile it directly on my synology. Since it was not that obvious, I thought I would share the steps that made it work
ipkg install openssh /opt/etc/openssh/sshd_config to suit your needs.
ipkg install ncurses-dev ipkg install ncursesw-dev
mkdir /opt/arm-none-linux-gnueabi/lib_disabled mv /opt/arm-none-linux-gnueabi/lib/libpthread* /opt/arm-none-linux-gnueabi/lib_disabled cp /lib/libpthread.so.0 /opt/arm-none-linux-gnueabi/lib/ cd /opt/arm-none-linux-gnueabi/lib/ ln -s libpthread.so.0 libpthread.so ln -s libpthread.so.0 libpthread-2.5.so
cd /volume1/@src/ wget --no-check-certificate https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz tar zxvf protobuf-2.5.0.tar.gz cd protobuf-2.5.0 ./configure --prefix=/opt/local make make install find /opt/local -mmin -5 > ../install-protobuf-files.lst
cd /volume1/@src/ tar zxvf mosh-1.2.4.tar.gz cd mosh-1.2.4 ./configure --disable-hardening --without-utempter --prefix=/opt/local make make install strip /opt/local/bin/mosh-server strip /opt/local/bin/mosh-client find /opt/local -mmin -5 > ../install-mosh-files.lst
cd /volume1/@src/ # DS211+ tar zxf gcc421_glibc25_88f6281-GPL.tgz #DS211+ cp arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/bin/locale /opt/bin/ cp arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/bin/localedef /opt/bin/ cp -r arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/usr/share/i18n /usr/share localdef -a /opt/bin/localedef -c -f UTF-8 -i en_US en_US.UTF-8
LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 export LANG LC_ALL
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/syno/bin:/usr/syno/sbin:/opt/bin:/opt/sbin:/opt/local/bin LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LD_LIBRARY_PATH=/lib:/usr/lib:/opt/lib:/opt/local/lib Now you should be able to do mosh user@host Do not forget if you are behind a port forwarder or NAT to select and forward the UDP port that mosh client should use (e.g. Rsync version that detects renamingIf you reorder your files and photos normally rsync would take ages to perform the backup but there is a patch not integrated in mainstream that deals with that: cd /volume1/@src/ wget "http://www.samba.org/ftp/rsync/src/rsync-3.1.0.tar.gz" wget "http://www.samba.org/ftp/rsync/src/rsync-patches-3.1.0.tar.gz" #wget "https://bugzilla.samba.org/attachment.cgi?id=7435" -O detect-renamed.diff tar zxf rsync-3.1.0.tar.gz tar zxf rsync-patches-3.1.0.tar.gz #cp detect-renamed.diff rsync-3.0.9/patches cd rsync-3.1.0 patch -p1 <patches/detect-renamed.diff patch -p1 <patches/detect-renamed-lax.diff ./configure --prefix=/opt/local make install strip /opt/local/bin/rsync find /opt/local -mmin -5 > ../install-rsync-files.lst Make sftp workFor some reason openssh package does not provide sftp, in order to enable it install: ipkg install openssh-sftp-server and add in Subsystem sftp /volume1/@optware/libexec/sftp-server Backup your data with history: rsnapshotrsnapshot is an rsync based backup system that I like: it is simple yet efficient.
ipkg install rsnapshot
My configuration is the following /opt/etc/rsnapshot.conf :
config_version 1.2 snapshot_root /volumeUSB1/usbshare/backup/rsnapshot cmd_cp /opt/bin/cp cmd_rm /opt/bin/rm #cmd_rsync /usr/syno/bin/rsync cmd_rsync /opt/local/bin/rsync cmd_ssh /opt/bin/ssh cmd_du /opt/bin/du interval daily 7 interval weekly 4 interval monthly 6 link_dest 1 verbose 2 loglevel 3 logfile /volume1/backup/rsnapshot.log #rsync_long_args -av --progress --delete --numeric-ids --relative --delete-excluded --syno-acl rsync_long_args -av --progress --delete --numeric-ids --relative --delete-excluded lockfile /opt/var/run/rsnapshot.pid backup / synosys/ exclude_file=/opt/etc/incexcl-synosys backup / synodata/ exclude_file=/opt/etc/incexcl-synodata You can notice that, to be safe, I am performing the backup to an external USB disk that I attach to the synology (located in /volumeUSB1/usbshare ).All the directories (include and exclude) are specified in the /opt/etc/incexcl-synosys file which has the following format:+ /etc/ + /root/ + /usr/ + /usr/syno/ + /usr/syno/etc/ + /usr/syno/apache/ - /usr/syno/* - /usr/* + /opt/ + /opt/etc/ + /opt/share/ + /opt/share/lib/ - /opt/share/* + /opt/lib/ + /opt/lib/ipkg/ - /opt/lib/* - /opt/* - /*
ipkg install nail /opt/etc/nail.rc to reflect your smtp server and credentials (here the domain is a google apps business one):set hold set append set ask set crt set dot set keep set emptybox set indentprefix="> " set quote set sendcharsets=iso-8859-1,utf-8 set showname set showto set newmail=nopoll set autocollapse ignore received in-reply-to message-id references ignore mime-version content-transfer-encoding fwdretain subject date from to set smtp=smtp.gmail.com:587 set smtp-use-starttls set ssl-verify=ignore set ssl-ca-file=/opt/etc/Thawte_Premium_Root_CA.pem set from="user@yourdomain.com" set smtp-auth-user=user@yourdomain.com set smtp-auth-password="YOURPASSWORD"
#minute hour mday month wday who command#minute hour mday month wday who command 55 23 * * 0,1,2,3,4,5,6 root /opt/bin/rsnapshot -v daily || nail -s "bkp `date +%Y%m%d` daily" user@yourdomain.com < /volume1/backup/rsnapshot.log 0 02 * * 0 root /opt/bin/rsnapshot -v weekly || nail -s "bkp `date +%Y%m%d` weekly" user@yourdomain.com < /volume1/backup/rsnapshot.log 0 04 1 * * root /opt/bin/rsnapshot -v montly || nail -s "bkp `date +%Y%m%d` monthly" user@yourdomain.com < /volume1/backup/rsnapshot.log Restart cron: /usr/syno/etc/rc.d/S04crond.sh stop /usr/syno/etc/rc.d/S04crond.sh start Install an apache server coexisting with synology's one
ipkg install apache
#LoadModule ext_filter_module libexec/mod_ext_filter.so
Include etc/apache2/extra/httpd-ssl.conf
vi /opt/etc/apache2/httpd.conf Listen 80
cd /opt/etc/apache2 ln -s /usr/syno/etc/ssl/ssl.crt/server.crt ln -s /usr/syno/etc/ssl/ssl.key/server.key
vi /usr/syno/apache/conf/httpd.conf-user Listen 8080 vi /usr/syno/apache/conf/extra/httpd-ssl.conf Listen 8443 Restart all apache servers: /opt/sbin/apachectl stop /usr/syno/etc/rc.d/S97apache-user.sh restart /opt/sbin/apachectl start Install self signed custom certificates for your domainSince I was tired of chrome's complaints that my domain was using synology.com certificates, I decided to generate my own custom ones following this link: http://forum.synology.com/wiki/index.php/How_to_generate_custom_SSL_certificates. Here is what I did:
cd /opt/etc/ssl openssl genrsa -des3 -out ca.key 1024
openssl req -new -key ca.key -out ca.csr
openssl x509 -days 3650 -signkey ca.key -in ca.csr -req -out ca.crt
openssl genrsa -out server.key 1024
openssl req -new -key server.key -out server.csr
openssl x509 -days 3650 -CA ca.crt -CAkey ca.key -set_serial 01 -in server.csr -req -out server.crt
cp server.key server.crt /opt/etc/apache2/ssl/
SSLCertificateFile /opt/etc/ssl/server.crt SSLCertificateKeyFile /opt/etc/ssl/server.key
/opt/sbin/apachectl stop /opt/sbin/apachectl start Protect via https some internal http servicesSomtimes you have some service that has a web interface on a specific port (e.g. 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 Perform some https redirections towards synology default services without opening the ports on router 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 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 interfaceSynocommunity 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 renamingI use two tools that I find handy;
ipkg install perl-file-rename
ipkg install perl wget http://www.j3e.de/linux/convmv/convmv-1.15.tar.gz tar xzvf convmv-1.15.tar.gz cd convmv-1.15 sed -i -e 's/usr/opt/1p' convmv ./convmv cp convmv /opt/bin Here is an example of how to use convmv recursively on current directory to fix encoding: /opt/bin/convmv -f iso-8859-1 -t utf8 --notest -r .
#!/opt/bin/bash for i in `find . | grep "\?"`; do rename "s/\?//g" "$i"; done Install temporary easy file sharing service: jirafeauIn order to share some files for a given period of time I have installed jirafeau. Here are the steps that I followed:
ipkg install php-apache php-pear vi /opt/etc/apache2/httpd.conf LoadModule php5_module libexec/libphp5.so <IfModule php5_module> AddType application/x-httpd-php .php </IfModule> <IfModule dir_module> DirectoryIndex index.html index.php index.php3 index.cgi index.htm </IfModule>
vi /opt/etc/apache2/extra/httpd-ssl-vhost-user.conf Alias /jirafeau /opt/share/lib/jirafeau-jirafeau/ <Directory /opt/share/lib/jirafeau-jirafeau> Order deny,allow Allow from all SSLRequireSSL </Directory> /opt/sbin/httpd -k restart
$cfg['web_root'] = 'https://yourdomain.com/jirafeau/'; $cfg['upload_password'] = 'UPLDPASSWD" Tools to installipkg install git Install pythonipkg install python27 ipkg install py27-setuptools Subtitles downloader
|
Main Page >