Give this a look, it's what I used while connecting two Unos via a USB hub plus the AlaMode shield via serial port. I'm pretty sure everything is in there but it's definitely a mixture of cut'n'paste from the BrewPi site and my own thinking out loud as I went along. You'll have to cope with the latter
Cheers!
Note: the script assumes the default RaspberryPi user name is 'pi'.
If you chose a different user name be sure to change all pertinent instances of 'pi' to your actual default user name.
Also, be sure to set the system date/time before the apt-get commands as otherwise security certificate errors may occur (security certificates are time sensitive).
=================================================
Multiple Arduino BrewPi Installation (2 USB, 1 Serial)
1.1.1. Determine the USB hub port identifiers
With only one Arduino connected, issue the following command to see which device node the Arduino is currently using:
$ ls /dev/ttyACM*
/dev/ttyACM0
$ udevadm info -a -n /dev/ttyACM0 | less
looking at parent device '/devices/platform/bcm2708_usb/usb1/1-1/1-1.3/1-1.3.4':
KERNELS=="1-1.3.4"
ATTRS{manufacturer}=="Arduino (www.arduino.cc)" (note the section for the Uno)
move Arduino to next USB port and repeat
KERNELS=="1-1.3.3"
1.1.2. Write the udev rules
Now that the identifier for each USB hub port has been obtained, the udev rules can be written.
KERNELS=="1-1.3.4" [Port 1]
KERNELS=="1-1.3.3" [Port 2]
$ sudo nano /etc/udev/rules.d/99-arduino.rules
SUBSYSTEM=="tty", KERNEL=="ttyACM*", KERNELS=="1-1.3.4", SYMLINK+="brewpi1"
SUBSYSTEM=="tty", KERNEL=="ttyACM*", KERNELS=="1-1.3.3", SYMLINK+="brewpi2"
[My third AVR is actually an AlaMode shield and connects via the RPi serial port so the above doesn't apply]
Once the udev rules file is created, disconnect your Arduino and then reload udev
before connecting all of the Ardiunos to their respective ports.
$ sudo /etc/init.d/udev reload
1.2. Install BrewPi
Install the BrewPi script and web interface manually as described in the manual installation process, noting the following changes:
$ git clone brewpi-script into subdirectories of /home/brewpi instead of directly into /home/brewpi.
[I used /home/brewpi/brewpi1, /home/brewpi/brewpi2 and /home/brewpi/brewpi3]
$ git clone brewpi-www into subdirectories of /var/www instead of directly into /var/www.
[I used /var/www/brewpi1. /var/www/brewpi2 and /var/www/brewpi3 to match each script installation directory]
Fix the permissions manually.
UNTESTED alternative to manual permission editing:
It looks like utils/fixPermissions.sh should work when run from each script instance
[My note: this does indeed work - and the per-instance execution is shown in Step 3 further along in this script where they belong]
If you have other content in /var/www, you will likely want to update webPath in fixPermissions.sh
to the directory of the corresponding web interface instance.
Do not use utils/updateCron.sh or the cron job string in the manual installation instructions.
Instead follow the directions in the cron section below.
INSTALLING BREWPI:
Backup RPints files:
backed up /var/www to /var/www_backup
backup up /var/www/index.php to rpints_index.php
Update all packages:
$ sudo apt-get update
$ sudo apt-get upgrade (FINALLY completed)
rebooted
Install missing PHP5 packages:
$ sudo apt-get install php5-cgi
Install missing MYSQL packages:
$ sudo apt-get install libapache2-mod-auth-mysql
Install missing PYTHON packages:
$ sudo apt-get install python-serial python-simplejson python-configobj python-psutil python-git
rebooted
3. Setting up users and permissions
Create user brewpi and group brewpi
$ sudo useradd -m -k /dev/null -G www-data,dialout brewpi
$ sudo passwd brewpi (set password = xxxxxxx)
Check brewpi rights
$ id brewpi
uid=1001(brewpi) gid=1004(brewpi) groups=1004(brewpi),20(dialout),33(www-data)
Add user pi to www-data and brewpi group
$ sudo usermod -a -G www-data pi
$ sudo usermod -a -G brewpi pi
NOTE: If you get the error "usermod: user 'pi' does not exist" then add user 'pi' then execute the usermod commands.
$ adduser pi
$ passwd pi (set the password twice)
Set the ownership of all files and subdirectories to brewpi and www-data (first two lines)
Give the group all permissions on all files (third and fourth line)
Give the group all permissions and set the sticky bit on all directories (fifth and sixth line).
$ sudo chown -R www-data:www-data /var/www
$ sudo chown -R brewpi:brewpi /home/brewpi
$ sudo find /home/brewpi -type f -exec chmod g+rwx {} \;
$ sudo find /home/brewpi -type d -exec chmod g+rwxs {} \;
$ sudo find /var/www -type d -exec chmod g+rwxs {} \;
$ sudo find /var/www -type f -exec chmod g+rwx {} \;
4. Installing BrewPi
4.2.1. Cloning the remote repository
For BrewPi1:
$ sudo -u brewpi git clone
https://github.com/BrewPi/brewpi-script /home/brewpi/brewpi1
For BrewPi2:
$ sudo -u brewpi git clone
https://github.com/BrewPi/brewpi-script /home/brewpi/brewpi2
For BrewPi3:
$ sudo -u brewpi git clone
https://github.com/BrewPi/brewpi-script /home/brewpi/brewpi3
4.3. The web interface: brewpi-www
4.3.1. Cloning the remote repository
Target www directory should be empty (automatic installer may delete it!)
$ sudo -u www-data git clone
https://github.com/BrewPi/brewpi-www /var/www/brewpi1
$ sudo -u www-data git clone
https://github.com/BrewPi/brewpi-www /var/www/brewpi2
$ sudo -u www-data git clone
https://github.com/BrewPi/brewpi-www /var/www/brewpi3
4.3.3. Fixing permissions after git commands
Edit the fixPermissions script in each BrewPi instance to match up with its path:
$ sudo nano /home/brewpi/brewpi1/utils/fixPermissions.sh
change webPath to point to subordinate brewpi1 folder:
webPath="/var/www/brewpi1"
Save the file and exit
$ sudo nano /home/brewpi/brewpi2/utils/fixPermissions.sh
change webPath to point to subordinate brewpi2 folder:
webPath="/var/www/brewpi2"
Save the file and exit
$ sudo nano /home/brewpi/brewpi3/utils/fixPermissions.sh
change webPath to point to subordinate brewpi3 folder:
webPath="/var/www/brewpi3"
Save the file and exit
Then execute each of the bash scripts:
$ cd /home/brewpi/brewpi1/utils
$ sudo bash fixPermissions.sh (for BrewPi1)
$ cd /home/brewpi/brewpi2/utils
$ sudo bash fixPermissions.sh (for BrewPi2)
$ cd /home/brewpi/brewpi3/utils
$ sudo bash fixPermissions.sh (for BrewPi3)
1.3. Modify the config files
1.3.1. Edit the script config files
The settings/config.cfg needs to be created in each script instance to properly configure them.
BrewPi1:
$ sudo nano /home/brewpi/brewpi1/settings/config.cfg
scriptPath = /home/brewpi/brewpi1/
wwwPath = /var/www/brewpi1/
port = /dev/brewpi1
altport = /dev/null
boardType = uno
Save the file and exit
BrewPi2:
$ sudo nano /home/brewpi/brewpi2/settings/config.cfg
scriptPath = /home/brewpi/brewpi2/
wwwPath = /var/www/brewpi2/
port = /dev/brewpi2
altport = /dev/null
boardType = uno
Save the file and exit
BrewPi3:
$ sudo nano /home/brewpi/brewpi3/settings/config.cfg
scriptPath = /home/brewpi/brewpi3/
wwwPath = /var/www/brewpi3/
port = /dev/ttyAMA0
altport = /dev/null
boardType = uno
Save the file and exit
1.3.2. Edit the web interface config files
config_user.php needs to be created in each web interface instance to properly configure them. Here are the config files Im using.
1. /var/www/brewpi1/config_user.php
<?php
// The default settings in config.php are overruled by the settings in config_user.php
// To use custom settings, copy this file to config_user.php and make your changes in config_user.php
// do not add a php closing tag, because newlines after closing tag might be included in the html
// Do not include a trailing slash on the path
$scriptPath = '/home/brewpi/brewpi1';
Save the file and exit
2. /var/www/brewpi2/config_user.php
<?php
// The default settings in config.php are overruled by the settings in config_user.php
// To use custom settings, copy this file to config_user.php and make your changes in config_user.php
// do not add a php closing tag, because newlines after closing tag might be included in the html
// Do not include a trailing slash on the path
$scriptPath = '/home/brewpi/brewpi2';
Save the file and exit
3. /var/www/brewpi3/config_user.php
<?php
// The default settings in config.php are overruled by the settings in config_user.php
// To use custom settings, copy this file to config_user.php and make your changes in config_user.php
// do not add a php closing tag, because newlines after closing tag might be included in the html
// Do not include a trailing slash on the path
$scriptPath = '/home/brewpi/brewpi3';
Save the file and exit
1.4. Set up cron jobs to start the scripts
Create cron job files for each script instance.
1.4.1. brewpi1
$ sudo nano /etc/cron.d/brewpi1
PYTHON=/usr/bin/python
SCRIPTPATH=/home/brewpi/brewpi1
MAILTO=""
* * * * * brewpi $PYTHON $SCRIPTPATH/brewpi.py --config $SCRIPTPATH/settings/config.cfg --checkstartuponly --dontrunfile; [ $? != 0 ] && $PYTHON -u $SCRIPTPATH/brewpi.py --config $SCRIPTPATH/settings/config.cfg 1>$SCRIPTPATH/logs/stdout.txt 2>>$SCRIPTPATH/logs/stderr.txt &
Save the file and exit
1.4.1. brewpi2
$ sudo nano /etc/cron.d/brewpi2
PYTHON=/usr/bin/python
SCRIPTPATH=/home/brewpi/brewpi2
MAILTO=""
* * * * * brewpi $PYTHON $SCRIPTPATH/brewpi.py --config $SCRIPTPATH/settings/config.cfg --checkstartuponly --dontrunfile; [ $? != 0 ] && $PYTHON -u $SCRIPTPATH/brewpi.py --config $SCRIPTPATH/settings/config.cfg 1>$SCRIPTPATH/logs/stdout.txt 2>>$SCRIPTPATH/logs/stderr.txt &
Save the file and exit
1.4.1. brewpi3
$ sudo nano /etc/cron.d/brewpi3
PYTHON=/usr/bin/python
SCRIPTPATH=/home/brewpi/brewpi3
MAILTO=""
* * * * * brewpi $PYTHON $SCRIPTPATH/brewpi.py --config $SCRIPTPATH/settings/config.cfg --checkstartuponly --dontrunfile; [ $? != 0 ] && $PYTHON -u $SCRIPTPATH/brewpi.py --config $SCRIPTPATH/settings/config.cfg 1>$SCRIPTPATH/logs/stdout.txt 2>>$SCRIPTPATH/logs/stderr.txt &
Save the file and exit
Restart CRON:
$ sudo /etc/init.d/cron restart
REBOOTED!
[ALL UNOS HAVE HEARTBEATS!]
http://xx.xxx.xxx.xxx:85/brewpi1/index.php
http://xx.xxx.xxx.xxx:85/brewpi2/index.php
http://xx.xxx.xxx.xxx:85/brewpi3/index.php
All functions on brewpi1 are operational
All functions on brewpi2 are operational
AlaMode is operational on brewpi3 but One-Wire pin assignment conflicts with AVR pins committed to the on-board RTC I2C port
- will need to modify the pins definitions in the sketch and in the web interface)
Made all web pages (index.php) password protected
- used same procedure as multiple files
- apparently the scope of .htaccess includes subdirectories
Done and done!
[edit: I've been cleaning this up and hopefully making the steps clearer]