My Synology automation scripts
This project should be converted to Ansible. Any volunteers?
I have a Synology DS214play NAS box and its command line is pretty limited. Most of the commands are trimmed down copies of their UNIX counterparts. I like my NAS being NAS, but I also wanted to be able to do useful things with it, assuming it's powered 24/7. To make its command line usable for myself in a long-term, I decided to spend some time on proper configuration. Unfortunately my NAS model isn't permitted to use Synology's Docker package, so the whole activity included:
-
ipkg
installation: this will give you basic commands such asvim
orbash
-
Debian chroot: this will let you run a Debian userland, which gives you
apt-get
and the possibility of running all sorts of stuff on your Synology box. I found it useful when experimenting with command-line backup solutions such aszbackup
, which don't exist inipkg
repository.
I stole some ideas from:
http://www.hang321.net/en/2015/06/09/debian-chroot-on-dsm-5-2/
- Enable SSH on your Synology http://forum.synology.com/wiki/index.php/Enabling_the_Command_Line_Interface
- Go to https://synocommunity.com/ and add the Community Packages to Synology software sources.
- From the community packages tab, install Python.
- From the community packages tab, install Debian chroot.
- Upon installing, start Debian chroot.
SSH to your NAS:
ssh root@nas_ip
Get the simple Python script which imitates wget
, but unlike Synology's
wget(1)
has HTTPS support (http://www.koszek.com/blog/2015/10/04/wget-in-9-lines-of-python-for-hostile-environments/):
wget -O - 'http://pastebin.com/raw.php?i=PcbNtyh9' | tr '\r' ' ' > wget2
chmod 755 wget2
./wget2 https://github.com/wkoszek/synology/archive/0.1.1.tar.gz
gunzip 0.1.1.tar.gz
tar xf 0.1.1.tar
cd synology-0.1.1
./bootstrap.sh
(you may want to pick the latest synology-x.x.x
release).
This should initiate the bootstrap procedure.
Upon running bootstrap.sh
following things will happen:
ipkg
will be fetched and installed.- ASH config will be updated to add
ipkg
toPATH
.profile
will be updated with some usable aliases and mandatory settings- SSH keys will be generated.
- SSH configuration will be installed for GitHub.com in case you want to push from your NAS
- Updated start script for Debian chroot will be installed. It basically mounts home directories in the chroot directory, and also adds USB-mounted volumes there.
- Debian's chroot environment will be started and updated.
- Informational message will be printed.
- Wojciech Adam Koszek, [email protected]
- http://www.koszek.com