Skip to content

Dustcloud Raspberry Pi Installation

JackGruber edited this page Jun 1, 2018 · 20 revisions

Tested on RASPBIAN STRETCH WITH DESKTOP https://www.raspberrypi.org/downloads/raspbian/

Dustloud works with php7. Php5 is no longer available in Rasbpbian Stretch. If you still want to use php5, you can use the following instructions. Otherwise skip this step.


PHP 5 Version

First of all you need to add the repo for php5 jessie, stretch doesn't support php5 anymore.

#You may be asked to set a root password for mySQL (on stretch you are not)

  • apt-get install apache2 php php5-mysqlnd mysql-server python3 python3-pip git

Raspbian stretch:

  • sudo apt-get install apache2 php php-mysqli mysql-server python3 python3-pip git php-mbstring php-phar php-json

Both versions:

#Set the default port for apache to 81

  • sed -i -e 's/Listen 80/Listen 81/g' /etc/apache2/ports.conf
  • sed -i -e 's/:80>/:81>/g' /etc/apache2/sites-enabled/000-default.conf
  • pip3 install pymysql python-miio pillow bottle
  • git clone --depth=1 https://github.com/dgiese/dustcloud.git
  • cd dustcloud/dustcloud

#If you set a password, you'll need to append "-p" to the mysql commands

  • mysql -e "CREATE USER 'dustcloud'@'localhost' IDENTIFIED by 'dustcloudpw';"
  • mysql -e "GRANT USAGE ON *.* TO 'dustcloud'@'localhost';"
  • mysql -e "CREATE DATABASE IF NOT EXISTS dustcloud;"
  • mysql -e "GRANT ALL PRIVILEGES ON dustcloud.* TO 'dustcloud'@'localhost';"
  • cat dustcloud.sql | mysql dustcloud

#create a page on your apache server (accessible as "your_ip_or_domainname:81/dustcloud"

  • mkdir /var/www/html/dustcloud
  • cp www/* /var/www/html/dustcloud/
  • mv /var/www/html/dustcloud/conf.sample.php /var/www/html/dustcloud/conf.php
  • sed -i -e 's/user123/dustcloud/g' /var/www/html/dustcloud/conf.php
  • sed -i -e "s/'password' => '',/'password' => 'dustcloudpw',/g" /var/www/html/dustcloud/conf.php

# install composer (Dependency Manager for PHP)

#replace the 123.123.123.123 with your own external ip address

  • sed -i -e 's/pymysql.connect("localhost","dustcloud","","dustcloud")/pymysql.connect("localhost","dustcloud","dustcloudpw","dustcloud")/g' server.py
  • sed -i -e 's/my_cloudserver_ip = "10.0.0.1"/my_cloudserver_ip = "123.123.123.123"/g' server.py

#create a folder for the server.py and the startscript

  • chmod +x server.sh

  • mkdir /dustcloud

  • cp server.* /dustcloud/

  • cp build_map.py /dustcloud/

  • a2enmod rewrite

Method 1: allow python3 to create sockets in restricted range

  • setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/python3.5

Method 2: do a iptables port redirection for port 80 to 5080 (need to run server.py with -sport 5080)

  • iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 5080