How to install required programs for weewx on a Synology ds209+ii NAS

1,933 views
Skip to first unread message

Lucas Heijst

unread,
Nov 27, 2014, 8:48:42 AM11/27/14
to weewx-de...@googlegroups.com
To all Synology users: 

The synology (ds209+ii) NAS has a python 2.7 package. I was not able to get the required packages for weewx installed without getting compilation errors.
At last I found a way to install everything succesfully including proper system logging and an automatic startup of weewx after a system boot.

Note: The description below starts with a backup of an earlier installed weewx version. You can skip the backup and restore actions when you install weewx for the first time.

Luc

# note: the actions below are done in a putty session with user root
# delete old ipkg installation (not weewx)
rm -rf /volume1/@optware
rm -rf /usr/lib/ipkg

# backup current weewx version (in /home/weewx)
# note: I made a share "linux" on my disk station on volume 1. This share can be seen from Windows via a network share to 'linux', e,g. t:/0/weewx
mkdir /home
cp -rf /volume1/linux/0/weewx  /home/

# install ipkg
cd /volume1/linux/0
sh syno-e500-bootstrap_1.2-7_powerpc.xsh 

# find path to mysqladmin
cd /
find -name mysqladmin
./usr/syno/mysql/bin/mysqladmin

# boot diskstation to make syslog.deny active

# start a putty session with user root
ipkg update
ipkg upgrade
ipkg install py26-setuptools
# note: this command installs also pyton 2.6

ipkg install py26-configobj

ipkg install py26-cheetah

ipkg install py26-pil

ipkg install py25-usb
# note: this command installs also pyton 2.5

# solution for python2.5 module usb not found in python2.6
cp /volume1/linux/0/usb.pth /opt/lib/python2.6/site-packages/
# contents of usb.pth:
/opt/lib/python2.5/site-packages/

ipkg install mysql
# notes during installation:
To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/bin/mysqladmin -u root password 'new-password'
/opt/bin/mysqladmin -u root -h ds-luc3 password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt ; /opt/bin/mysqld_safe &

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
mysql - 4.1.22-3 - Popular free SQL database system

ipkg install py26-mysql

# change password of user root 
/opt/bin/mysqladmin -u root password '[mypassword]'

# solution for remembering path to ipkg after a boot
cp /volume1/linux/0/.profile  /root/
# contents of file .profile (the PATH line was changed):
umask 022
PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
export PATH
#This fixes the backspace when telnetting in.
#if [ "$TERM" != "linux" ]; then
#        stty erase
#fi
HOME=/root
export HOME
TERM=${TERM:-cons25}
export TERM
PAGER=more
export PAGER
PS1="`hostname`> "
alias dir="ls -al"
alias ll="ls -la"

# solution for logging inf and debug messages in /var/log/messages
cp /volume1/linux/0/syslog.deny  /etc.defaults/
# contents of file syslog.deny (lines debug and info commented out):
# These priorities in this config file are not logged
# refer to syslog.h
#alert
#crit
###debug
#emerg
#err
###info
notice
# Always keep these setting , as these are obselete
# refer to syslog.h
error
none
warn
panic

# solution for python2.5 module usb not found in python2.6
cp /volume1/linux/0/usb.pth /opt/lib/python2.6/site-packages/
# contents of file usb.pth:
/opt/lib/python2.5/site-packages/

# start-stop-restart command file for weewx
cp /volume1/linux/0/S01weewx.sh /usr/local/etc/rc.d/
# contents of file S01weewx.sh:
#!/bin/sh
### Initializing vars
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/usr/sbin:/usr/bin:/sbin:/bin
DESC="weewx"
WEEWX_HOME_DIR=/home/weewx
WEEWX_CONF_FILE=weewx.conf
WEEWX_FILE=weewxd
WEEWX_ARGS="--daemon"
PIDFILE=/var/run/weewx.pid
USER=root
# Function tot start the weather service
start_weatherservice() {
    
    echo "Trying to start $WEEWX_HOME_DIR/bin/$WEEWX_FILE $WEEWX_ARGS..." >&2
    
    # Check if the service isn't running already
    if [[ ! -e $PIDFILE ]]
    then
        # Start the weather service
        ( ( nohup $WEEWX_HOME_DIR/bin/$WEEWX_FILE $WEEWX_HOME_DIR/$WEEWX_CONF_FILE $WEEWX_ARGS ) & echo $! > $PIDFILE & ) > /dev/null
        echo "$WEEWX_HOME_DIR/bin/$WEEWX_FILE $WEEWX_HOME_DIR/$WEEWX_CONF_FILE $WEEWX_ARGS sucessfully started!" >&2
        return 1
   else
        echo "$WEEWX_HOME_DIR/bin/$WEEWX_FILE $WEEWX_ARGS was already running!" >&2
        return 0
    fi
}

# Function to stop the weatherservice
stop_weatherservice() {
    echo "Trying to stop $WEEWX_HOME_DIR/bin/$WEEWX_FILE $WEEWX_ARGS..." >&2
    
    if [ -f "$PIDFILE" ]
    then
        # Let read the PID id from the file
        read PID < $PIDFILE
        
        if [ -d "/proc/$PID" ]
        then
            # It is running, so kill it
            kill -9 "$PID"
            rm -f $PIDFILE
            
            # Give it some time to exit
            sleep 5
            
            # Check if it was really killed
            if [ -d "/proc/$PID" ]
            then
                echo "Couldn't kill PID $PID!" >&2
            else
                echo "$WEEWX_HOME_DIR/bin/$WEEWX_FILE (PID:$PID) was killed!" >&2
            fi
        else
            # It is'nt running, remove the PIDfile
            rm -f "$PIDFILE"
        fi
    else
        echo "$WEEWX_HOME_DIR/bin/$WEEWX_FILE $WEEWX_ARGS isn't running!" >&2
    fi
}
# Start, stop, restart actions
case "$1" in
    start)
        start_weatherservice
    ;;
    stop)
        stop_weatherservice
    ;;
    restart)
        stop_weatherservice
        sleep 5
        start_weatherservice
    ;;
    *)
        echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
        exit 3
    ;;
esac
:

# install less file browser
ipkg install less

# Note: The actions below are done within the GUI of the disk station:
1. Control panel  - Webservices – Enable Webstation – Enable MySQL
2. Package Center – Install phpMyAdmin
3. log in with user root password [mypassword]
4. Check if all (weewx) databases are still present
5. Rename stats databse to stats_[date]


# Note: the actions below are done in a putty session with user root
# install pyephem (almanac)
cd /volume1/linux/0
tar -xvf pyephem-3.7.5.2.tar.gz
cd /volume1/linux/0/pyephem-3.7.5.2 
python2.6 setup.py build 
python2.6 setup.py install 

# install urllib3 (needed by weewx-wd)
cd /volume1/linux/0
tar -xvf urllib3-1.8.2.tar.gz
cd /volume1/linux/0/urllib3-1.8.2 
python2.6 setup.py build 
# set PYTHONPATH to get an install without error
export PYTHONPATH=/opt/local/lib/python2.5/site-packages
python2.6 setup.py install 

# restore weewx version
mkdir /home
mkdir /home/weewx
cp -rf /volume1/linux/1/weewx  /home

# backfill stats database
cd /home/weewx
./bin/wee_config_database_wd weewx.conf --backfill-stats

# finished

# how to upgrade weewx (to a higher version 2.x)
cd /volume1/linux/0
tar -xvf weewx-2.7.0.tar.gz
cd /volume1/linux/0/weewx-2.7.0
python2.6 setup.py build 
python2.6 setup.py install 

Jerzy Suzanowicz

unread,
Nov 27, 2014, 10:04:39 AM11/27/14
to weewx-de...@googlegroups.com
I've managed install and run all necessary components with standard Synology packages on DS-212. 
Let me know if anyone interested. :)

Lucas Heijst

unread,
Nov 27, 2014, 10:08:19 AM11/27/14
to weewx-de...@googlegroups.com
On Thursday, 27 November 2014 12:04:39 UTC-3, Jerzy Suzanowicz wrote:
I've managed install and run all necessary components with standard Synology packages on DS-212. 
Let me know if anyone interested. :)

Jerzy, I'm interested. Please post the steps you did to install everything.

Thanks in advance!

Luc 

Jerzy Suzanowicz

unread,
Nov 27, 2014, 11:27:36 AM11/27/14
to weewx-de...@googlegroups.com
Yes, its all what is needed: ephem, pymysql etc. Needs few tricks to compile additional modules but its doable. 
I have created synology .spk package for weewx to make thing easer to integrate into synology native startup/monitoring/upgrade mechanism so after Synology DSM next upgrade you dont need to worry about redo all again (with your solution it will set to synology defaults).
Over the weekend I'll create some tutorial for ARM based DS but it should comply with all synology boxes.

check out: http://weewx.suzanowicz.pl. work in progress but weewx 3.0 is working :)   

Lucas Heijst

unread,
Nov 27, 2014, 11:56:43 AM11/27/14
to weewx-de...@googlegroups.com
Hi Jerzy,

I like your web page! Good it's in English.

I noticed you have v3.0 working with meso. Did meso work right away or have you made any changes?

One minor thing. For some characters an old man like me (age 63) needs a magnifying glass (or has to set windows scaling to 175%) to read the text.

Luc

Jerzy Suzanowicz

unread,
Nov 27, 2014, 12:03:46 PM11/27/14
to weewx-de...@googlegroups.com
scaling is temporary as I'm mainly testing this on the phone, thank you for good tip as it will be for whole family so clear reading is important.
meso works with no changes.
Forecast 3.0, mwall had put link to new custom extensions somewhere on group.

Lucas Heijst

unread,
Nov 27, 2014, 1:37:59 PM11/27/14
to weewx-de...@googlegroups.com
On Thursday, 27 November 2014 14:03:46 UTC-3, Jerzy Suzanowicz wrote:
meso works with no changes.
Forecast 3.0, mwall had put link to new custom extensions somewhere on group.

Hi Jerzy,

The new forecast is working now, but I got an error when I add (meso function) user.sync.SyncService to restful_services.

Nov 27 15:30:41 weewx[22663]: engine: Caught unrecoverable exception in engine:
Nov 27 15:30:41 weewx[22663]:     ****  'archive_database'
Nov 27 15:30:41 weewx[22663]:     ****  Traceback (most recent call last):
Nov 27 15:30:41 weewx[22663]:     ****    File "/home/weewx/bin/weewx/engine.py", line 831, in main
Nov 27 15:30:41 weewx[22663]:     ****      engine = EngineClass(config_dict)
Nov 27 15:30:41 weewx[22663]:     ****    File "/home/weewx/bin/weewx/engine.py", line 70, in __init__
Nov 27 15:30:41 weewx[22663]:     ****      self.loadServices(config_dict)
Nov 27 15:30:41 weewx[22663]:     ****    File "/home/weewx/bin/weewx/engine.py", line 137, in loadServices
Nov 27 15:30:41 weewx[22663]:     ****      self.service_obj.append(weeutil.weeutil._get_object(svc)(self, config_dict))
Nov 27 15:30:41 weewx[22663]:     ****    File "/home/weewx/bin/user/sync.py", line 80, in __init__
Nov 27 15:30:41 weewx[22663]:     ****      self.archive_db_dict = self.config_dict['Databases'][self.config_dict['StdArchive']['archive_database']]
Nov 27 15:30:41 weewx[22663]:     ****    File "/opt/local/lib/python2.6/site-packages/configobj.py", line 554, in __getitem__
Nov 27 15:30:41 weewx[22663]:     ****      val = dict.__getitem__(self, key)
Nov 27 15:30:41 weewx[22663]:     ****  KeyError: 'archive_database'
Nov 27 15:30:41 weewx[22663]:     ****  Exiting.

Maybe it has to do with the weewx-wd package which is not working for weewx v3.0.0a1 and commented out b me.

Luc

Thomas Keffer

unread,
Nov 27, 2014, 2:16:05 PM11/27/14
to Lucas Heijst, weewx-de...@googlegroups.com
Looks like module user/sync.py has not been converted to work with V3.

-tk

shaggy

unread,
Jan 10, 2015, 5:37:21 PM1/10/15
to weewx-de...@googlegroups.com
Jerzy,

do you have a current version of the .spk file?  I am experimenting with a new Synology NAS, and am looking for the best way to get weewx running on it.  For some reason, I can't access your website at the moment (DNS not playing).

Thanks!

Jerzy Suzanowicz

unread,
Jan 12, 2015, 9:36:04 AM1/12/15
to weewx-de...@googlegroups.com
I'm not using weewx any more. And my spk isnt updated for current weewx version

Jerzy Suzanowicz

unread,
Jan 13, 2015, 4:36:49 AM1/13/15
to weewx-de...@googlegroups.com

Chotechai Piyavongsiri

unread,
Mar 27, 2019, 9:21:13 PM3/27/19
to weewx-development
Hi, thanks a lot for the very detailed guide. I managed to get my weewx up on my ds411+ii (intel-based), though just tested the simulator station.
I already have my weewx operating on my Android-turn-to-ubuntu tv box. My questions are:
- how do I transfer all my setup, including all extensions, to the Synology. I'm not sure which folders on Synology I should copy to.

Thank you.
…...

ljm.h...@gmail.com

unread,
Mar 27, 2019, 11:24:12 PM3/27/19
to weewx-development
Sorry, it is too long ago for me to remember the details. Years ago I switched for weewx to raspberry PI systems because the Synology installation had problems.

Chotechai Piyavongsiri

unread,
Mar 28, 2019, 1:25:34 AM3/28/19
to weewx-development
Thanks for your prompt reply. So I'd better stay on my Linux box.

A e r f m o s f e r a

unread,
Dec 18, 2021, 3:47:22 AM12/18/21
to weewx-development
Hi Jerzy, your dashboard is a personal work or some public template? can it be shared? Is awesome your weather station site.
Reply all
Reply to author
Forward
0 new messages