Wview è tra i software più leggeri e più stabili disponibili su Linux, ed è perfetto per essere installato su Raspberry Pi proprio perchè leggero ed affidabile.
Questa guida si riferisce al modello più recente, il Raspberry Pi 2

Tuttavia l’installazione potrebbe non risultare semplice. Fortunatamente sul web ho scovato questo semplice script bash che permette di installare wview in modo completo e sicuro senza la minima fatica 🙂

Pi2ModB1GB_-comp

Andate sul terminale ssh, collegatevi al Raspberry come utente “Pi” ed eseguite questi semplici passaggi:

# sudo nano installWview.sh

inserite all’interno del file questo codice:

#!/bin/bash

# installWview.sh
#
# Script to install WView weather station software on new Rapsberry Pi.
# This script is not meant to be used on an already configured system.
# This script could overwrite or break an existing confgiuration.
#
# By NetCodger 3/27/2015
#

# Make sure this script only runs on a Raspberry Pi.
if ! uname -a | grep “raspberrypi”; then
echo “This script is meant to only run on a Raspberry Pi.”
echo “This does not appear to be a Raspberry Pi.”
read -n 1 -p “Pres any key exit”
exit -1
fi

# Make sure that we are root
if [ $(id -u) != 0 ]; then
echo “Insufficient privilege to execute this script.”
echo
echo “Please re-run the script with sudo installWView.sh”
read -n 1 -p “Pres any key exit”
exit -1
fi

# Are you sure?
echo “This script is for installing WView on a new Raspberry Pi installatoin.”
echo “Installing on an already configured system could destroy any previous modifications.”

read -p “Are you sure you want to continue? (y/n)” -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi

# Update /etc/apt/sources.list to include download location for Wview software, if it does not already exist.
if ! grep -Fxq “deb http://www.wviewweather.com/apt/wheezy wheezy main” /etc/apt/sources.list; then
echo “deb http://www.wviewweather.com/apt/wheezy wheezy main” >> /etc/apt/sources.list
echo “deb-src http://www.wviewweather.com/apt/wheezy wheezy main” >> /etc/apt/sources.list
fi

# Update installed Raspbian(Debian) software.
apt-get update
apt-get –assume-yes –force-yes upgrade

# Update Pi firmware.
rpi-update

# Prompt user to set timezone as necessary.
dpkg-reconfigure tzdata

# Install web server and PHP
apt-get –no-install-recommends –assume-yes –force-yes –fix-missing install lighttpd

apt-get –no-install-recommends –assume-yes –force-yes –fix-missing install php5 php5-sqlite php5-cgi

# Configure lighttpd to enable PHP
if ! grep -Fxq ‘.php” => “/usr/bin/php5-cgi’ /etc/lighttpd/conf-enabled/10-cgi-php.conf; then
echo ‘server.modules += (“mod_cgi”)’ >> /etc/lighttpd/conf-enabled/10-cgi-php.conf
echo ‘ cgi.assign = (“.php” => “/usr/bin/php5-cgi”)’ >> /etc/lighttpd/conf-enabled/10-cgi-php.conf
fi

lighttpd-enable-mod fastcgi fastcgi-php

# Install WView weather station software.(But without installing Apache2.)
apt-get –no-install-recommends –assume-yes –force-yes –fix-missing install wview apache2-

# Create simlinks manually, since WView only does it for Apache2.
cd /var/www
ln -s /var/lib/wview/img weather
ln -s /var/lib/wviewmgmt wviewmgmt

cd /var/lib/wviewmgmt
ln -s system_status.php index.php

# Adjust fille permissions.
# Make wview config files writable for http user.
chmod 777 /etc/wview
chmod 666 /etc/wview/wview-conf.sdb
chmod 666 /etc/wview/wview-binary

# Create a ramdisk for Hi Low data.
# Saves SD card write cycles and
# speeds up Hi Low regeneration.
if ! grep -Fxq “tmpfs /wviewtmp tmpfs defaults,mode=0755,size=30m 0 0” /etc/fstab; then
mkdir /wviewtmp
echo “tmpfs /wviewtmp tmpfs defaults,mode=0755,size=30m 0 0” >> /etc/fstab
mount -a
fi

# Create persistent data store. Needed due to ramdisk.
mv /var/lib/wview/archive /var/lib/wview/archive-persistent
mv /var/lib/wview/img /var/lib/wview/img-persistent

# Link database files so that WView can find them.
if [ ! -d /var/lib/wview/archive ]; then
mkdir /var/lib/wview/archive

cat > /var/lib/wview/archive/README-IMPORTANT << ‘EOT1’
Due to the use of a ramdisk for the /wviewtmp directory
this directory should contain the following soft links.

ln -s /var/lib/wview/archive-persistent/wview-archive.sdb /var/lib/wview/archive/wview-archive.sdb
ln -s /var/lib/wview/archive-persistent/wview-archive.sql /var/lib/wview/archive/wview-archive.sql
ln -s /var/lib/wview/archive-persistent/wview-history.sdb /var/lib/wview/archive/wview-history.sdb
ln -s /var/lib/wview/archive-persistent/wview-noaa.sdb /var/lib/wview/archive/wview-noaa.sdb
ln -s /wviewtmp/wview-hilow.sdb /var/lib/wview/archive/wview-hilow.sdb

EOT1

ln -s /var/lib/wview/archive-persistent/wview-archive.sdb /var/lib/wview/archive/wview-archive.sdb
ln -s /var/lib/wview/archive-persistent/wview-archive.sql /var/lib/wview/archive/wview-archive.sql
ln -s /var/lib/wview/archive-persistent/wview-history.sdb /var/lib/wview/archive/wview-history.sdb
ln -s /var/lib/wview/archive-persistent/wview-noaa.sdb /var/lib/wview/archive/wview-noaa.sdb
ln -s /wviewtmp/wview-hilow.sdb /var/lib/wview/archive/wview-hilow.sdb

ln -s /wviewtmp/img /var/lib/wview/img
fi

# Create a service script that copies wview-hilow.sdb on startup or shutdown.
cat > /etc/init.d/tmpfsToPersistent << ‘EOT2’
#! /bin/bash
# /etc/init.d/tmpfsToPersistent

### BEGIN INIT INFO
# Provides: tmpfsToPersistent
# Required-Start: $local_fs $network $time $syslog ntp
# Required-Stop: $local_fs $network $time $syslog ntp
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Script to save data at shutdown.
# Description: Copies wview database from persistent to tmpfs at start and vice versa at shutdown.
### END INIT INFO

case “$1” in
start)
echo “Starting copy /var/lib/wview/archive-persistent/wview-hilow.sdb to /wviewtmp/wview-hilow.sdb a tmpfs location.”
if mount | grep “tmpfs on /wviewtmp” > /dev/null; then
cp -a /var/lib/wview/archive-persistent/wview-hilow.sdb /wviewtmp/
cp -ar /var/lib/wview/img-persistent/ /wviewtmp/img/
else
echo “/wview not mounted on tmpfs”
fi
;;
stop)
echo “Stopping copying /wviewtmp/wview-hilow.sdb to persistent storage”
cp -a /wviewtmp/wview-hilow.sdb /var/lib/wview/archive-persistent/
cp -ar /wviewtmp/img/* /var/lib/wview/img-persistent/
;;
*)
echo “Usage: /etc/init.d/tmpfsToPersistent {start|stop}”
exit 1
;;
esac

exit 0

EOT2

chmod 755 /etc/init.d/tmpfsToPersistent

update-rc.d tmpfsToPersistent defaults 10 50

# Setup automatic WView service start/stop
sed -i ‘s#$local_fs $network $time $syslog#$local_fs $network $time $syslog tmpfsToPersistent#’ /etc/init.d/wview

update-rc.d wview defaults 90 10

# Reboot and begin configuration of WView.
echo
echo “———————————-”
echo “Reboot Raspberry Pi and begin using Wview?”
echo “See WView manual about wviewconfig.”
echo
echo “Choose NO if you plan to run the RestoreWview script to import prior data.”
echo
read -p “Press y to reboot and n to exit” -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
reboot
fi

 

Salvate tenendo premuto “ctrl+x” e confermando con “y”

Modificate i permessi del file

# sudo chmod 777 installWview.sh

Iniziate l’installazione

# sudo ./installWview.sh

 

Seguite le indicazioni e riavviate.

Al riavvio puntate all’interfaccia web di wview: http://ip-raspberry/wviewmgmt/system_status.php