cgi-bin scripts for the Photo Wall #2

After we discussed about how to scale the images for the Photo Wall on a desktop computer in the first part of this blog, we may imagine that keeping an additional computer running just to serve the photo wall it’s not really efficient. Fortunately, the photos are usually stored on a NAS. For the nerds under us they are most probably on a Linux machine, so the first part of this blog is helpful for them. For the “yet to become” nerds, the photos are on a commercial NAS like for example a Synology DiskStation. And for them it’s the current post. DiskStation is also a Linux machine, but kind of a more special one.

Luckily everything one needs to run the resize script on a DiskStation can be installed from Synology and needs no extra packages from additional sources (yes, I don’t want to “play” on my NAS; It’s to valuable)

  1. You need to activate SSH access on your DS
  2. You must install WebStation; I configured mine to use Apache HTTP Server; probably Nginx would also be fine.
  3. Some interesting configuration is around /usr/local/etc/httpd/conf/httpd.conf and I created /usr/local/etc/httpd/sites-enabled/httpd-vhost.conf with the sole line:

    ScriptAlias /cgi-bin/ /var/services/web/cgi-bin/

    Update 2017-03; With the update to Synology 6.1, the interesting configuration is under: /usr/local/etc/apache22/conf/httpd22.conf.
    At the end I added the line:
    Include sites-enabled/*.conf2
    and in the file: /usr/local/etc/httpd/sites-enabled/httpd-vhost.conf2 I added the ScriptAlias from above.
    This is btw. a workaround as some mysterious component of Synology resets the content of /usr/local/etc/httpd/sites-enabled/httpd-vhost.conf with every new start of the DiskStation.

  4. Notice that /var/services/web links to the folder web on your DS-“visible” tree.
  5. Create cgi-bin folder below web and adjust its permissions to a+r; It could be you need also a+x.
  6. Place the script in the given folder, restart your DiskStation and here you are, ready to get http:///cgi-bin/getPic.sh?900:123

Some notes about the script: unlike the “pure Linux” version of the script which uses GraphicsMagick, this one here uses ImageMagick. Why ? Because ImageMagick is already on the DiskStation by default. Which means I had to rewrite the code to use ImageMagick while it still runs with nice performance. I hope you’ll enjoy !

As mentioned also in the other blog, this is a Proof of Concept and nothing more. It provides NO protection in terms of security and I definitely NOT recommend you to run this script on a DiskStation which can be accessed from Internet or from an insecure Intranet. Notice the license terms and the readme and use it ONLY if you know what you’re doing.

For any questions, bug reports, suggestions, use the appropriate thread in the Raspberry PI forum.

Advertisements
Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: