Over the years I’ve bought a fair few of Packt Publishing’s IT books – they’re pretty good. Somehow though, I managed to remain blissfuly unaware of their free book a day thingy until recently.
It’s very good at it’s main aim, which is getting people to visit their site frequently. But I’m forgetful so it’s best for all concerned if a computer does that for me, and claims my free daily book.
As well as being forgetfull I’m also pretty lazy so I looked for a pre-existing solution, and found this:
Here’s how to install it on a Synology DS115J NAS
Step 1 – Install Node.js
Ok step 1 is actually to enable user home directories on the NAS so I’ve got somewhere to put my grabber intallation.
Do this via Control Panel > User > Advanced
Now to actually install Node.js. This is as simple as going into the Package Centre, finding Node, then clicking ‘Install’.
A quick SSH into the NAS to check the install worked..
synology> node -v
synology> npm -v
Yup. All good. Now to install the grabber itself.
Step 2 – Download the grabber
Ok, dumb question, how do I download directly from git to the Synology?
Turns out it’s dead easy. Make sure you’re in the directory you want to download it into, then just copy the ‘download zip’ link from the browser and ‘wget’ it..
synology> wget https://github.com/draconar/grab_packt/archive/master.zip
Easy enough. Now to unzip it..
synology> unzip master.zip
Now we have stuff to play with..
synology> cd grab_packt-master/
README.md package.json server.js
Step 3 – Install the grabber
For this, I’m using the instructions on the grabbers git page – which is also the README.md
the install command took a while, presumably because this is a new node install so none of the dependencies would already be there.
Copying the example .env file worked ok, but now how do I edit it? Ugh – vi.
Ok, done. (via Googling a Vi cheatsheet http://www.lagmonster.org/docs/vi.html)
Step 4 – Test run
Now to test it before attempting to set up a scheduled job…
synology> node server.js >> output.txt
synology> cat output.txt
----------- Packt Grab Started -----------
Book Title: Building Web Applications with ArcGIS
Claim URL: https://www.packtpub.com/freelearning-claim/19096/21478
----------- Packt Grab Done --------------
Blimey, that seemed to work ok first time.
Step 5 – Schedule
Ok, the instructions on the grabber site have slightly different paths to node and the home directories than I have.
synology> which node
But that’s fine as I’m going to use the Synology DSM admin stuff to set it up, but it’s good to know the absolute paths first…
In the DSM interface..
Control Panel > Task Scheduler
Create > User-defined script
The text of the command is:
/usr/bin/node /volume1/homes/garry/grab_packt-master/server.js >> /volume1/homes/garry/grab_packt-master/output.txt
Selecting the task from the list and then running via the admin interface seemed to work, and the output.txt file showed evidence of it running ok again.
A quick poke about in the schedule tab to run it once a day and we’re done!
We’ll see tomorrow if it all works as planned.
EDIT – Yup, all works.