Synology WordPress 404 on Synology after restarting NAS

Each time I restart my NAS (for update reasons), I have errors 404 when trying to reach any post of my WordPress blog, until I re-set permalinks' settings. I finally fixed it by updating my WordPress with latest Synology's package.

Click to Read More

A long time ago, rebooting my NAS started to result systematically in 404 in my WordPress blog. I found a manual fix here: simply resetting WordPress permalinks' settings was solving the problem... until the next reboot :(

But I never understood why rebooting my NAS was resulting in the lost of permalinks' settings. And could find a definitive solution.

I finally took today an hour to reproduce and further investigate the problem (motivated by the shiny sun outside :p). I found that restarting only the WordPress Package was also resulting in this issue. I noticed more precisely that the .htaccess file was deleted when starting the package (not when stopping). I am sure that removing access rights on the .htaccess file for WordPress, as described here for example, would be a solution. But the not best one.

I found the best solution by accident. A long time ago, as I was interested in a version of WordPress more recent than the one available via Synology's packages, I did a manual upgrade with the official WordPress setup. Since that time, I never did an update anymore with Synology's Package Manager, but used the native WordPress update via its own Dashboard:

WordPress-Update

Today, I did a backup of WordPress' installation folders and updated Synolgy's WordPress Package. Once the update accomplished, I noticed that the .htaccess was containing information specific to Synology:

# Synology PHP
AddHandler default-handler .htm .html .shtml
AddHandler php-fastcgi .php
AddType text/html .php
Action php-fastcgi /php56-fpm-handler.fcgi
# Synology PHP

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L] </IfModule>

# END WordPress

And now, when restarting WordPress, the .htaccess is not deleted anymore (and permalink's settings are not lost). There is certainly a good explanation, that I ignore, but at least I won't suffer 404 anymore.

And next time I update manually WordPress, I will pay attention to backup the .htaccess as specially clearly recommended here, as well as merging that .htaccess with the updated one after the update of the Permalinks' structure:

  1. Backup your database. Read Backing Up Your Database for a detailed explanation.
  2. Backup ALL your WordPress files in your WordPress directory. Don't forget your .htaccess file.
  3. Verify the backups you created are there and usable. This is essential.
  4. Ensure first four steps are completed. Do not attempt the upgrade unless you have completed the first four steps.
  5. Delete the old WordPress files on your site, but DO NOT DELETE

    • wp-config.php file;
    • wp-content folder; Special Exception: the wp-content/cache and the wp-content/plugins/widgets folders should be deleted.
    • wp-images folder;
    • wp-includes/languages/ folder--if you are using a language file do not delete that folder;
    • .htaccess file--if you have added custom rules to your .htaccess, do not delete it;
    • robots.txt file--if your blog lives in the root of your site (ie. the blog is the site) and you have created such a file, do not delete it.
  6. Upload the new files from your computer's hard drive to the appropriate WordPress folder on your site.
  7. Run the WordPress upgrade program and follow the instructions on the screen.
  8. Update Permalinks and .htaccess. Update your Permalink Structure and merge the custom rules, if necessary, into your .htaccess file.
  9. Install updated Plugins and Themes. Please review the list of Plugins that work in Version 4.8. Check for Theme Compatibility with 4.8 and ask your Theme author for any new version.

Synology Synology: "DSM updating in process..." forever

I recenlty tried to update my DSM 6.1.1-15101 from pacth 3 to 4. For some unknown reasons, the update never ends which results in various "issues". The only solution I found to exit that situation was to kill the upgrade process.

Click to Read More

Once the update started, the progress eventually appeared stuck...

Updating Synology

After 2 hours, I decided to open the admin interface (http://<MySyno>:<adminPort>) and was able to log in. But back into the Control Panel, I saw the message "DSM updating is in process..."...

DSM Updating

It would not have been a big issue if it didn't prevent me to update any packages. Trying to do so was resulting in a popup blocking any automatique on manual installation/update. I was also unable to restart or shutdown properly the NAS for the same reason.

To solve this situation I had to kill the upgrade process:

  1. Open a SSH console using Putty to connect onto the NAS
  2. Login as administrator
  3. Enter the root mode using the command: sudo -i
  4. Kill the update processes typing the command: kill -9 $(ps aux | grep -e SYNO.Core.Ugrade |grep -v grep | awk '{ print $2 }')

I was next able to update other packages... I did next restart the NAS but for some reasons, it never rebooted completed (neither detected by the Synology Assistant nor accessible via the Admin webUI). I had therefore to do a hard reboot :(

Now, although I am still unable to reboot properly or upgrade DSM, I can at least install (or update) packages, possibly to help me in backuping everything before a complete reset.

NB.: I also tried to upgrade from SSH, without success.

Using the feature auto, I got an error message:

root@Hades:~# synoupgrade --check
UPGRADE_CHECKNEWDSM
Available update: DSM 6.1.2-15132, patch type: dsm, restart type: reboot, reboot type: now

root@Hades:~# synoupgrade --download
UPGRADE_DOWNLOADDSM
New update has been downloaded

root@Hades:~# ls -la /volume1/@autoupdate
total 223684
drwx------ 2 root root 4096 Jun 16 18:49 .
drwxr-xr-x 37 root root 4096 Jun 16 18:49 ..
-rw-r--r-- 1 root root 229038080 Jun 14 11:50 DSM_DS1815%2B_15132.pat

root@Hades:~# synoupgrade --check-pat ./DSM_DS1815+_15132.pat
UPGRADE_CHECK_PAT
Patch type is DSM
ErrSysAvailSize

root@Hades:~# synoupgrade --auto
UPGRADE_AUTO
New update has been downloaded
Start DSM update...
ServerUpgrade failed

Using an explicit download or the explicit path of the patch auto-downloaded, I get no error:

root@Hades:~# synoupgrade --patch /volume1/@autoupdate/DSM_DS1815%2B_15132.pat
UPGRADE_PATCH
Start DSM update...
root@Hades:~#

root@Hades:~# wget https://global.download.synology.com/download/DSM/release/6.1.2/15132/DSM_DS1815%2B_15132.pat
--2017-06-16 18:34:22-- https://global.download.synology.com/download/DSM/release/6.1.2/15132/DSM_DS1815%2B_15132.pat
Resolving global.download.synology.com... 52.222.227.46, 52.222.227.228, 52.222.227.163, ...
Connecting to global.download.synology.com|52.222.227.46|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 229038080 (218M) [binary/octet-stream] Saving to: 'DSM_DS1815+_15132.pat'

100%[==================================================================================================================>] 229,038,080 10.0MB/s in 30s

2017-06-16 18:34:53 (7.23 MB/s) - 'DSM_DS1815+_15132.pat' saved [229038080/229038080]

root@Hades:~# synoupgrade --check-pat /root/DSM_DS1815+_15132.pat
UPGRADE_CHECK_PAT
Patch type is DSM
Check patch successfully

root@Hades:~# synoupgrade --patch /root/DSM_DS1815+_15132.pat
UPGRADE_PATCH
Start DSM update...
root@Hades:~#

Fortunatelly, in all cases, the DSM is not suck in "updating in process"

Synology Synology Package Creator for shell scripts and php pages

I did upgrade "Mods", my Windows Tool used to create dummy packages adding shortcuts on DSM's desktop to open web pages.

Now, "Mods" is able to package shell scripts and php webpages...

Mods

Mods

Click to Read More

It is available here on GitHub.

For example, you could package apps like Chris Hager's Most Simple Ajax Chat Ever

Simple Chat on DSM

Simple Chat on DSM

Or package a more advanced tool like php Server Monitor

Server Monitor

Server Monitor

Server Monitor Running

Server Monitor Running

This Tool is available here on GitHub.

Synology Create a VPN to download from a Synology

In order to hide my NAS, I wanted it to use its own VPN, while my public IP was still visible when surfing with any other devices in my LAN.

To do so, I subscribed to HMA! (HideMyAss!) and applied their configuration procedure on my Synology. Et voilà.

Click to Read More

I did try both a L2TP and a OpenVPN VPN with success. Tricks:

  • For a L2TP VPN, use your PPTP password and NOT your account password
  • For a OpenVPN VPN, use your account password
  • Although using Port Forwarding to access my NAS from internet, I did not had to open the required ports !!!
    • L2TP: UDP 500, 4500 and 1701
    • Open VPN : 443 if using TCP, 553 is using UDL
  • If you are using a DDNS, go to the  Control Panel > External Access and Click Update to verify the public IP of your NAS. It must now be your VPN IP.
  • Check that downloading a torrent (with this procedure), your tracker IP is your VPN IP.
  • Check you IP calling ipify from your NAS.
    • A very simple way to do this is to call the following php page on your Web Station:
<?php 
 $ip = file_get_contents('https://api.ipify.org');
 echo "My public IP address is: " . $ip;
?>
  • Soon after enabling the VPN, I started to be attacked on Telnet port! I am using Security's Auto-Block feature to prevent brute force attacks.
  • On a mobile device (or anything else) connected directly to Internet (not via your LAN), type your VPN IP in a browser. You should see the default home page of your web station if this one is enabled.
    • I would recommend to replace this default page by a php page returning a header 404.
<?php
 header("HTTP/1.0 404 Not Found");
?>
  • If you are using a DDNS on your NAS, you won't be able to access your router and VDSL modem via that domain name. Indeed, only your NAS is accessible via this VPN IP. If possible, configure another DDNS on your VDSL modem or router.
    • Ex.: I am using duckdns.org for free. They have a great support page here with detailed configurations for many different devices.
    • Doing so, you can access your NAS and your router or modem via their own Domain name.
  • "Tested OK" both when accessed from LAN or from Internet:
    • Download Station via Synology Download Station for Chrome (https://www.download-station-extension.com)
    • JDownloader via Chrome extension and via https://my.jdownloader.org
    • Plex Server via App or via http://DDNS name:port/web or via http://plex.tv
    • DSM via its admin port
    • Apps: DS Cam, DS File, DS Audio, DS Get, DS Photo, DS Video, DS Cloud and DS Note are all wokring fine using Quick Connect (All those I tested via their DDNS name + custom port or DSM admin port worked too)
    • Cloud Sync (with Hubic)
    • FTP Server

SynologyTips Synology's Could Sync Consuming Internet Quota With Google Drive

I noticed that between 50GB and 100Gb of my Internet Quota was consumed per day since two weeks. After investigation, I found it was due to the Cloud Sync service of my Synology Nas "looping" infinitely.

Click to Read More

The first step was to identify the device downloading some many Gb per day.

I did enable the logging service on my router and turn on the logging of its firewall for all outgoing connections.

I did export the log of the firewall into notepad++, cleaned up a bit the log to keep the source and destination IP only.

I did copy that into Excel and created a pivot table to see which source was doing many connection and onto which external IP (eliminating known destinations as the DNS of google 8.8.8.8 and 8.8.4.4, the Synology's KeepAlive service 118.163.30.162, Broadcast 192.168.0.255, ...) I saw that most connections were onto 172.217.16.193, 172.217.21.202, 172.217.22.42, ... from my NAS.

Using a IP who IS service, I found that 172.217 belongs to Google. Why was my NAS connection to Google ? I did look all the packages installed on my NAS and "tilt": Cloud Sync was configured to sync two google accounts... Having a quick look into the current status of Cloud Sync, I noticed it was "syncing" 1 file... apparently for ever.

I did connect on my NAS via Telnet and looked into /var/log/cloudsync/daemon.log

In there, I found that cloud sync was logging, in a loop, errors like:

Dec 10 11:19:26 [ERROR] gd-pull-event-by-list-handler.cpp(89): ListDirectory: ListRemoteSubitems failed (retrying) [-1000] User rate limit exceeded
Dec 10 11:19:26 [ERROR] gd-transport.cpp(2195): error reason: [rateLimitExceeded].
Dec 10 11:19:26 [ERROR] gd-transport.cpp(2196): error message: [Rate Limit Exceeded].
Dec 10 11:19:26 [ERROR] gd-transport.cpp(2238): Hit rate limitation.
Dec 10 11:19:26 [ERROR] gd-transport.cpp(3082): [-1000] User rate limit exceeded. URL='https://www.googleapis.com/drive/v2/files?fields=nextLink%2Citems%28id%2Ctitle%2CmimeType%2CfileSize%2CmodifiedDate%2Cmd5Checksum%2CdownloadUrl%2CalternateLink%2Cparents%28id%29%2Clabels%28trashed%29%29&q=trashed%20%3D%20false%20and%20%271QmcGFz7PI0P_0TUlaAJkNfzWRw%27%20in%20parents'

I will look into a solution to this issue and temporarily unlinked the Google Drive account from Coud Sync...

voilà voilà.

SynologyTips Send Custom Notifications from scripts running on a Synology [new]

This is an update of a old post written for DSM 4 and 5: how to use the native Notification Mechanism of Synology to sent custom notifications. It's now tested on my DS1815+ with DSM 6.0.

Click to Read More

First, define the Notifications to be sent:

  1. Open a dos command prompt, and execute: telnet <YourSynoHostname>
    1. As an alternative, I am using the free telnet client "Putty" to open SSH Console.
  2. Login as administrator
  3. Once connected via telnet, enter the root mode with the command 'sudo -i', using here also the password of your administrator
  4. Execute next: cd /usr/syno/synoman/webman/texts/
  5. Execute: ls
  6. Now you see a list of folders for each language supported by your Synology. You must at least defined your custom notifications in the 'enu' version and next the version that match your language.
  7. Copy the file with the definition of the existing notifications in a shared folder to edit it easily: cp enu/mails /volume1/web/
    1. I presume here that the web station is enabled, otherwise, copy the file 'mails' in any other shared folder.
    2. As an alternative, you can use the Package "Config File Editor" to edit "/usr/syno/synoman/webman/texts/enu/mails"
  8. Edit now this file 'mails' (e.g.: with notepad++: \\<yourSynoHostname>\web\mails)
  9. Add your new custom "tags" at the end of the file with an adequate definition (see bellow for an example). You must specify a Title, a Subject, the text, and a Category with its priority. The category is used to group the Notifications in the DSM > Control Panel > Notification > Advanced Tab. For each Category, specify one of the possible values with a "Priority", separated by a coma. The priority is used to filter the notifications in the "Advanced" tab (Look at existing tags in the file for illustration):
    1. Possible values for "Category"
      1. Backup/Restore: group under 'Backup and Restoration' in the "Advanced" tab
      2. CMS
      3. External Storage
      4. HA: grouped under 'High-availability cluster'
      5. AHA: not displayed in the "Advanced" tab but related to External Storage
      6. Storage: grouped under 'Internal Storage'
      7. USB Copy: not displayed in the "Advanced" tab but related to External Storage
      8. Power System: grouped under 'Power supply'
      9. System
      10. PerfEvent: not displayed in the "Advanced" tab but related to System
    2. Possible values for "Priority"
      1. Important: displayed as Critical
      2. (no value): displayed as Informative
        Synology Notifications

        Synology Notifications

  10. Save your changes (E.g.: back to the telnet console, execute: cp /volume1/web/mails enu/mails)

Examples:

[MySqlBkpError] Category: Backup/Restore,Important
Title: Database backup failed
Subject: Database backup on %HOSTNAME% has failed

Dear User,

Database backup on %HOSTNAME% has failed.

[MySqlBkpOK] Category: Backup/Restore
Title: Database backup completed
Subject: Database backup on %HOSTNAME% has succeeded

Dear User,

Database backup on %HOSTNAME% has successfully completed.

Next, define how to sent those custom Notifications if and only if they are in a Category which does not appear in the "Advanced" tab of the "Control Panel" > "Notifications" pane > "Advanced" tab (Ex.: the categoryPerfEvent). It's indeed via that Tab that you should to enable  the desired delivery modes: "email", "sms", .... which is obviously only possible for Notifications in a Category which is displayed.

  1. Go back to the telnet console and execute: cp /usr/syno/etc/notification/notification_filter.settings /volume1/web/

    1. As an alternative, you can use the Package "Config File Editor" to edit "/usr/syno/etc/notification/notification_filter.settings"
  2. Edit the file 'notification_filter.settings' (E.g. with notepad++)
  3. At the end of that file, insert a configuration line for each custom tag, specifying how the notification must be sent (Look at the other line for illustrations). Possible delivery mode are:
    1. mail
    2. sms
    3. mobile
    4. cms: this is the native popup notification mechanism of DSM, enabled by default for all notifications
    5. msn: not supported anymore since 17th July 2014
    6. skype: not supported anymore since 17th July 2014
  4. Copy the file back to its original location: cp /volume1/web/notification_filter.settings /usr/syno/etc/

Examples:

MySqlBkpOK="mail"

MySqlBkpError="mail"

Now, reboot your Synology

It seems that in the past, I was able to apply my changes in those files without a reboot. But while testing this trick on DSM 6.x, I didn't find how to do it without a reboot.

Finally, modify your script to sent your notifications:

  1. Edit your script (E.g. with notepad++).
  2. Add where required the following command: /usr/syno/bin/synonotify <YourCustomTag>
  3. Save your changes.

In the example here after, I sent notifications depending on the success or failure of the previous command:

if [ $? -eq 0 ] then /usr/syno/bin/synonotify MySqlBkpOK
else /usr/syno/bin/synonotify MySqlBkpError
fi

Finally, check that the "Notifications" are enabled on your Synology and tick options like emails, SMS, ... for the new tags if required:

  1. In your DSM, go to “Control Panel” > “Notification” > “E-Mail”
  2. Tick the option “Enable e-mail notifications”.
  3. Complete all the fields in that tab. At least: SMTP server, SMTP port, SMTP authentication and Primary email.
  4. Send also a test mail from this tab to verify your settings.
  5. Go next to the "Advanced" tab
  6. Tick the "E-mail" option (and possibly others) for the new tags which appear now in the list.
    1. If the tags do not appear, close and reopen the control panel. restart your DSM!
    2. The tags appear with their Title under their Category
Notifications Configuration

Notifications Configuration

And here are the outcomes: a popup message and an email

Database Backup Email

Database Backup Email

Database Backup Custom Notification

Database Backup Custom Notification

Pay attention that the tags are case sensitive ! Also backup the changes you made in the file 'mails' and 'notification_category' as they will be overwritten for sure when you will update the DSM... Finally, delete the files 'mails' and 'notification_category' from your web folder...

Notice: the user EConceptApplications suggested on Synology Forum to use a script as here under to automatically reinsert the notifications

grep -q "MySqlBkpOK" /usr/syno/etc/notification/notification_filter.settings
if [ $? -ne 0 ] then

echo MySqlBkpOK="mail" >> /usr/syno/etc/notification/notification_filter.settings

fi

Notice: a reader, k13tas, suggested that it was much easier to reuse an existing notification tag and customize its text via Control Panel > Notification > Advanced. Indeed, those changes are not lost after a DSM update.

Notice: a reader, Rusmin, posted here that he found how to pass parameters to be used  in the notification message, via a hash json string. In his sample, one passes the value "value1" via a variable named %VAR1%. The value can obviously come from any variable of your shell script. Ex.: $PPID, $MyVariable, $$, etc...

Usage: /usr/syno/bin/synonotify tag_event [hash_json_string]

/usr/syno/bin/synonotify Tag_Name '{"[%VAR1%]": "value1", "[%VAR2%]": "value2"}'

As creating manually custom notifications is far from ideal, please vote for my feature request on Synology's forumhttp://forum.synology.com/enu/viewtopic.php?f=3&t=92727

Synology Synology upgrade to DSM 6.0

A few notes about the upgrade from DSM 5 to 6

Click to Read More

  • First, stop Plex (as it prevents DSM 6.0 to install)
  • Upgrade to DSM 6.0
  • Upgrade all the required Packages
  • Start Plex
  • Not working anymore:
    • Login in a telnet session as 'root'
    • 'homes' link in /var/services is pointing at /volume1/@fake_home_link
      • open a ssh session as root,
      • do: rm homes
      • and: ln -s /volume1/homes homes
    • Access right to shared folders
      • admin has no access anymore to various shared folders. Ex.: /volume1/homes/admin
      • Go to DSM > Control Panel > User
      • Edit the 'admin' account and got the the 'permissions' tab
      • Reapply the access rights
    • Web Console.

      • Doesn't open anymore... It must now be accessed under the web path /webman/3rdparty, via its url: http://hades:5050/webman/3rdparty/webconsole/wc.cgi.
      • I did a new package to start it automatically. See attachments at the bottom of this post. Once installed, open Web Console and change your password (default is "admin") using the command:  #users modify admin
    • JDownloader (does not start anymore)
      • Java Manager not installed anymore. It is replaced by the new Java package for a more convenient installation procedure.
      • Edit the file S99jdownloader.sh to replace “/volume1/@appstore/JavaManager/Java/bin/java” by “/usr/local/bin/java”
      • In that file also change the path to create the pid file into a folder where admin is granted write access !
      • Login into a ssh session and enter the root mode (sudo -i)
      • Execute “rm /var/run/S99jdownloader.pid”
      • Check that all files in /volume1/@appstore/jdownloader belong to 'admin'
      • Exit the root mode
      • Execute “sh S99downloader.sh start”
      • Check the output in the nohup.out file
    • Filebot does not run anymore
      • Reinstall the “Unofficial Java Installer”
    • FileBot Node does not start anymore
      • Uninstall filebot and filebot-node
      • Uninstall node.js and java 8
      • Delete all the old scheduled tasks related to filebot
      • Delete the input and the output folders (where media files to be renamed are located)
      • Recreate empty input and output folders (as admin - via the File Station, not as root)
      • CTRL-F5 in the browser to fully refresh DSM
      • Install the unofficial java installer of RedNoah + node.js v4
      • Install filebot (version from Package Center) and filebot-node (the version filebot-node-0.2.0-B1-noarch of RedNoah)
      • If it does still not run, test it via a SSH
        • login as admin
        • DO NOT RUN ANYTHING AS ROOT. So, don't execute: sudo -i
        • cd /var/packages/filebot-node/target/
        • ./start
        • Check the errors returned by this command if any
        • Check also the logs: cat /var/log/messages
      • filebot-node is installed in /volume1/@appstore/filebot-node with
        • a sytmbolic link from /var/packages/filebot-node/target/ and
        • a symbolic link from /usr/local/filebot-node
        • filebot-node schedule a task to run its command /usr/local/filebot-node/task xxx where xxx is the id of a task defined into /volume1/@appstore/filebot-node/data/task/xxx.argsp
    • AcpiOnLan (DSM SSO login not working anymore)
      • the port to access DSM in admin mode (required to do a login via the page /webman/login.cgi) is not anymore stored in /etc/synoinfo.conf with the key secure_admin_port or admin_port respectively for http and https. AcpiOnLan was fetching the port in that file. Instead, AcpiOnLan must now fetches external_port_dsm_https or external_port_dsm_http
    • WordPress
      • After the update of WordPress, as usually, I had to save (although not changed) the current option selected in the "Settings" > "Permalink Settings" otherwise no page was accessible anymore via permalinks (as returned by google search).
      • The automated WordPress update failed to complete. I should have enabled ftp first. I did a manual upgrade.. But the problem was most probably with the owner of the files... (See next)
      • Upgrading plugins didn't work either... But this problem was solved by executing, as root: chown -R http:http /volume1/web/wordpress

SynologyTips DNS name resolution not working anymore after Package update

After updating my Synology with the latest version of the DNS Server, this one was not resolving my domain names anymore. I had to reset to "resolution service" to solve that issue.

Click to Read More

To access my blog, hosted on my NAS, from my intranet but using its public domain name, I had to define the same domain name on my DNS Server, with A records pointing to the NAS' IP... (see details here).

When my DNS Server does not run anymore, trying to access my blog from my intranet, using its domain name, I get the web page of my ADSL Modem. Is IP address is indeed the one obtained when resolving my domain name using a public DNS Server.

To check if my DNS Server runs fine, I simply had to run a dos cmd prompt and type ping www.beatificabytes.be. If I get the local IP of my NAS, it works fine. If I get the public IP of my ADSL modem, there is something wrong...

It's not the first time that I have this issue after updating my DSM or the DNS Server. But each time, the solution is the same: I have to uncheck and recheck the options “Enable resolution services” in my Synology’s “Control Panel > DNS Server > Resolution” settings.

NB.: I have next to reboot my mobile devices. on PC, possibly execute "ipconfig /release" and then "ipconfig /renew" in a command prompt.

Synology Control ACPI-Enabled network devices from a Synology

Acpi On Lan

Acpi On Lan

"ACPI-On-Lan" is a package I have created for my Synology DS 713+ (also tested on my DS 3612sx).

It installs a website that list all your network devices. Depending on the OS, you can possibly send a sleep, shutdown or hibernate command to the device. ACPI-On-Lan tries also to reach each device (using a ping) and checks if there is a default web page accessible on the device (Ex. a configuration or administration page). Finally, it can send Wake-On-Lan magic packets to wake-up devices currently switched off.

Click to Read More

Disclaimer

This package is a prototype made for learning purpose. I did test many development techniques and libraries I never touched before: ajax/jquery, boostrap, .Net click-once deployment, creation of Synology spk packages, WebAPI/Microsoft .Net Owin, Newtonsoft.Json, running shell commands from php, etc... So don't expect the most amazing bits out of there. It's just this well known Big Ball of Mud  :oops:

This is not a beta version (even not an alpha), which would be well designed. My prototype is a Quick and Dirty App made of various pieces of code dropped together. It must be complete rewritten properly or at least deeply re-factored. Briefly said, I don't want my name to be associated with this ugly mess (even if most scientists seem to produce such a code :D).

Nevertheless, and although still really incomplete (as most prototypes), it works on my own NAS and I have already been asked to share it. So, here it is:

Some details

A few details on ACPI-On-Lan's basics first:

  • it reuses the login cgi module of the Synology to authenticate the user
  • it parses the ARP table of the Synology to find the devices available on the LAN.
  • it pings the devices using the "inetutil" library (from ipkg)
  • it does not use any database
  • it stores all the details about the network devices in a file with json format. If you plan to uninstall the package, you must backup those files manually first.
  • for hibernate, sleep, standby, restart Windows PC, it talk to a Windows Service hosting WebAPI services.
  • this Windows Service was intended to be deployed via click-once. Because I didn't want to resign the click-once setup for each new deployment url, the Windows Service is installed now via MSI. However, the Windows Service is still self-installing (simply run the exe once and it will do the complete setup)
  • all commands (ping, WOL, ...) are executed server side (by the NAS). So the Web UI can be used from the WAN without requiring direct access to each devices on the LAN.

Notice also that:

  • the web UI doesn't render well on mobiles.
  • there is not support yet to shutdown MAC, LINUX or ANDROID devices. I am planning to look how to use RPC commands (later this year ;) )
  • Windows mobiles are not yet supported.
  • there are still some bugs when refreshing the status of some devices and a wrong state can sometimes be displayed. Also an action to "shutdown" the NAS is displayed although not yet implemented.
  • it's not possible to define a specific port for the website possibly hosted on a device (Ex.: a custom local port of a port forwarded from the modem/router in order to access the device from the WAN)
  • I have to yet filled the spk's "texts" files to translate the package.

Prerequisite:

You will have to install the package 'inetutil' on your NAS. This is required to be able to ping the devices while not running as super user (i.e.: 'root').

The package 'inetutil' can be easily installed via the graphic interface "IpkgGUI" once IPKG is installed. And there are many tutorial on the web to install IPKG. If you are not afraid, you can try my own installation script*, described here ("IpkgGUI" is a graphical interface to manage IPKG packages. It is available as a Community Package for Synology on https://www.cphub.net)

(*) Notice that you can install the package "ACPI-On-Lan" first and than connect on your NAS via telnet. The script to install IPKG is deployed with "ACPI-On-Lan". Once connected, run: sh /var/packages/AcpiOnLan/target/application/service/installipkg.sh

If you want to be able to send Sleep/Restart/Hibernate/shutdown command to Windows PC, you will need the Microsoft .Net Framework 4.5. This service is not required if you only want to send WOL commands to Windows machines.

Setup:

1) Download the package attached at the bottom of this page and install it manually via the "Package Manager" of Synology. 5 clicks and ~that's it~.

Manual Installation of ACPI On Lan

Manual Installation of ACPI On Lan

2) It can theoretically be installed on any volume (if you have several).

Install On Any Volume

Install On Any Volume

3) And you can "run it after installation"

RunAfterInstallation

The setup of the package will mainly:

  • deploy the sources under /var/packages/AcpiOnLan/
    • the web application will be in /var/packages/AcpiOnLan/target/application
    • all the data of AcpiOnLan will be stored next to the web application in a file named Computers.json
  • create a php alias AcpiOnLan to "redirect" the http calls into the folder here above
  • force open_basedir = null for the new web site "AcpiOnLan"
  • add an icon into the DSM Start Menu
Acpi On Lan Icon

Acpi On Lan Icon

4) Once ACPI-On-Lan opened in a browser, you will have access to a menu "install srvc". Click on it to download the MSI which installs the Windows Service (Do this on Windows only!).

Install AcpiOnLan Windows Service

Install AcpiOnLan Windows Service

5) The download of AcpiOnLanInstaller.msi will most probably be blocked by your browser/antivirus as it's not a common download. If you want it, you have to accept the download ("Keep" within Chrome)

AcpiOnLanInstaller Blocked

AcpiOnLanInstaller Blocked

6) Once you run the msi, recent version of Windows will also prevent its execution

AcpiOnLanInstaller Stopped by Windows

AcpiOnLanInstaller Stopped by Windows

7) You will have to approve the installation by clicking on "More Info" here above and then "Run Anyway"

AcpiOnLanInstaller Forced

AcpiOnLanInstaller Forced

8) Once the msi is running, it will copy the required files and do a first run of the service. When the service is run interactively (it's the case when run by rom the msi), it install/uninstall itself instead of starting WebAPI Services. But it means that the antivirus will again react. Due to installation timeout this could disturb the setup...

AcpiOnLanInstaller AntiVirus

AcpiOnLanInstaller AntiVirus

9) The Windows Service will be installed and will register itself the port the url where it will run its WebAPI services (It uses 'netsh' for that purpose)

Installation

Installation

Et voilà, the Windows Service should now be running.

IMPORTANT NOTICE 1: as the Windows Service was designed to be deployed via Click-Once, it was not assumed to be launched "As Administrator" directly (An exe "run" via Click-Once can by the way not require elevated rights). So, if run without such rights, the exe of the Windows Service will stop itself automatically and restarts "As Administrator" (You could be prompted to provide adhoc credentials).

Previledge Required

Previledge Required

IMPORTANT NOTICE 2: when the Windows Service is installed via the msi, NEVER run the exe yourself from a command prompt of from the Windows Explorer. Again because the service has not been designed to be installed via a msi (with 'installutil' tool or with an installer class) a "self-installation/uninstallation" process has been foreseen if and only if the exe is run "interactively". So, if you run the exe after the installation of the msi, it will do a self-uninstallation of the service.You have to run it once more to reinstall it.

IMPORTANT NOTICE 3: The worst wase occurs if you run the exe once ad then uninstall the msi via the Control Panel > Add & Remove Programs. Indeed the msi will simply run the exe which will actually do a self-reinstallation of the service. So you will still have the service defined in the "Local Services" but neither the exe nor the entry in "Add & Remove Programs" anymore. To fix this, Quickly reinstall the msi, which will do a self-uninstallation of the service. Than run the exe interactively (from Windows Explorer) to redo a self-installation of the service. And you will end with the service defined in the "Local Services", the exe available and the entry in "Add & Remove Programs" (which can now be used to safely uninstall the service). Sorry for that. I will improve the process to prevent the msi to put such a mess asap.

Quick guide:

1) When you access Acpi-On-Lan, you have to log in with a DSM account

AcpiOnLan Login

AcpiOnLan Login

2) When you run Acpi-On-Lan for the very first time, it will search for your LAN (possibly one per Ethernet port on your NAS)

AcpiOnLan Looking For Network

AcpiOnLan Looking For Network

3) Next, it will scan the LAN(s) (look into the ARP table)

AcpiOnLan Scanning Network

AcpiOnLan Scanning Network

4) Finally, it will display a list of network devices found. For each device, you will have to "Set the OS" and "Set an Icon" (Except if you are happy with the default icons).

AcpiOnLan Set OS and Icon

AcpiOnLan Set OS and Icon

5) If there is an hyperlink symbol next to a device, it means that there is a we page available. You can click on it. Also to refresh the status of a device, you can use the menu "Check".

6) Depending on the OS:

  • if the device if on, you will have actions to Hibernate, Sleep, Standby, Shutdown or Restart the device.
  • Once you have clicked on an action, an Abort action is made available for a few second.
  • If the device is off, you will only have a Wol action.

The recycle bin can be used to hide a device and you can edit the name of the device.

AcpiOnLan Actions

AcpiOnLan Actions

7) Finally, you have various menu

AcpiOnLan Menu

AcpiOnLan Menu

  • Reload: will reload the list of devices (and add newly detected ones if any)
  • Flush: will empty the ARP table and reload the list of devices (you will have to 'reload' again until all the devices appear. Possibly ping manually your devices from a telnet session to populate the ARP table... I will possibly add such a feature in the UI soon or later)
  • Check: check the status of all the devices displayed in the list not checked since 5 minutes. Notice: up to 3 devices are checked simultaneously by the UI (limitation for mobile devices slow to execute jquery)
  • Forced Check: check the status of all the devices displayed in the list even if checked within the latest 5 minutes.
  • Reset All: delete all the devices from the list (including your customization like icons/OS/hostnames). The network will net be rescanned. Notice that your previous data will actually be backuped in a subfolder "backups" and named Computers.x.json. You can manually restore them.
  • Show All: will show all devices previously hidden by clicking on its recycle bin. Clicking again on its recycle bin will un-hide the device.
  • Hide: Hide all devices marked to be hidden (to be used after the menu Show All)
  • Log Out: guess ;)

NOTICE: your devices will be listed only if they have been switched-on at least one and in touch with the NAS during that time (I.e.: if they have been added into the ARP table).  Some devices although switched-on are never in touch with the NAS. EX.: power lines Ethernet adapters, ... I will plan a procedure to ping all the IP in the LAN so all such devices are touched (if switched-on). In the mean time, you will have to ping them yourself from a telnet session. Ex.: ping -c 1 192.168.0.1

Synology Script to automate IPKG installation on Synology

Installing ipkg is not difficult, but I hate to do it manually each time I (re)install a Synology... So, here attached is a script to install it automatically.

Click to Read More

First Installation:

  1. Copy on your NAS the script attached at the bottom of this post (Ex.: into \\<YourSyno>\web\admin as used for the illustration here after).
  2. Connect as root on your NAS (Ex.: via telnet using the command 'telnet <YourSyno>', the login 'root' and the password of your 'admin' account)
  3. Execute the script (Ex.: use the command 'sh /volume1/web/admin/installipkg.sh')
  4. Check which processor your have on your NAS and select the right option accordingly. The script will show you the cpu found using 'cpuinfo'. But you can double-check here (NB.: I have a DS713+ which is currently not listed. I didn't test ipkg for the other versions).
Automatic Installation of Ipkg

Automatic Installation of Ipkg

You can now use ipkg directly in a shell or via the (really) great UI named "IpkgGUI". This one is available as a Community Package from cphub.net. Add "https://www.cphub.net" as a Package Source in the Package Center's settings pane and install IpkgGUI.

Ipkg GUI

Ipkg GUI

Re-installation/upgrade:

If ipkg is already installed, the script will remove it automatically and reboot the NAS before proceeding further with the installation (A reboot takes a bit more than one minute to shutdown and a bit more than two minutes to restart on my DS 713+). After the reboot, thanks to a script inserted into /etc/rc.local, the setup will continue automatically.

Automatic Installation of Ipkg With Reboot

Automatic Installation of Ipkg With Reboot

Installation status:

(After the reboot, reconnect to the NAS). You can now check the status of the setup in its log, using the command: cat /root/ipkg.log. The output should looks like this:


[Mon Dec 15 17:34:44 CET 2014] Installing IPKG...
Optware Bootstrap for syno-i686.
Extracting archive... please wait
bootstrap/
bootstrap/bootstrap.sh
bootstrap/ipkg-opt.ipk
bootstrap/ipkg.sh
bootstrap/optware-bootstrap.ipk
bootstrap/wget.ipk
Creating temporary ipkg repository...
Installing optware-bootstrap package...
Unpacking optware-bootstrap.ipk...Done.
Configuring optware-bootstrap.ipk...Done.
Installing ipkg...
Unpacking ipkg-opt.ipk...Done.
Configuring ipkg-opt.ipk...Done.
Removing temporary ipkg repository...
Installing wget...
Installing wget (1.12-2) to root...
Installing wget (1.12-2) to root...
Installing wget (1.12-2) to root...
Installing wget (1.12-2) to root...
Installing wget (1.12-2) to root...
Installing wget (1.12-2) to root...
Installing wget (1.12-2) to root...
Installing wget (1.12-2) to root...
Installing wget (1.12-2) to root...
Configuring wget
Successfully terminated.
Creating /opt/etc/ipkg/cross-feed.conf...
Setup complete.

Notice: after the setup of ipkg, this one is upgraded and updated once automatically.

PS.: If you don't choose the right version of the boostrap, the installation of ipkg will fail. While trying to run it, you could see errors like "line 1: syntax error: unexpected word (expecting ")")". Try to install the right package. The script should delete the previous installation and install the new one as explained above.