Difference between revisions of "Install xpl hub"

From xPL
Jump to: navigation, search
(Launch the hub at startup)
(Ubuntu)
Line 79: Line 79:
 
  respawn
 
  respawn
 
  setuid control
 
  setuid control
  setgid staff
+
  setgid users
 
   
 
   
 
  #-------------------------------------------------------------------------------
 
  #-------------------------------------------------------------------------------

Revision as of 13:17, 16 March 2014

My xPL hub is based on John Bent's xPL ToolKit for Perl.

Install the hub

Download the tarball. It contains:

  • xpl-hub.pl: the hub
  • xpl-monitor.pl: a monitor which allows to view the xPL messages
  • xpl-send.pl: a utility for sending xPL messages
  • xPL: a directory containing Perl functions common to all the scripts

Move it to the location you want the scripts to reside. This could be /opt/xPL or /usr/opt/xPL. I personally create a control user who will run these scripts and I place the files in /home/control/Documents/Controls on a Linux machine or in /Users/control/Documents/Controls on a Mac.

Obviously, if you place the scripts in a different location than mine, you will have to adapt the path everywhere it is given here.

Extract it:

tar -xvjpf xPL_base.tar.bz2

Test the hub

Lanch the hub:

su control
/home/control/Documents/Controls/xpl-hub.pl -v

Monitor xPL messages: open a second terminal window and:

su control
/home/control/Documents/Controls/xpl-monitor.pl -v

Send a message: open a third terminal window and:

/home/control/Documents/Controls/xpl-send.pl -vc hbeat.end world=hello

You should see the corresponding world=hello message in the second terminal window.

If it works, stop all the running xPL scripts.

Launch the hub at startup

Launching the xPL system on a machine requires the following sequencing:

  • once the file system and the Ethernet connections are up, the xPL hub can be started
  • once the hub is up, most of the xPL clients can be started
  • some xPL clients may have to wait for other clients to be up and running

Ubuntu

On Ubuntu, the sequencing can base on events.

Because of this, one has to allow the members of group users to emit events without typing-in a password. To do so, edit /etc/sudoers and add:

# Allow users to emit upstart events
%users ALL=(ALL) NOPASSWD:/sbin/initctl

In order to have the system launch the xPL hub, edit /etc/init/xpl-hub.conf:

################################################################################
# xPL hub - hub for the home control automation system
#
description "xPL hub"
emits       xpl-hub_started
version     "1.0"
author      "Francois Corthay"

#-------------------------------------------------------------------------------
# Configuration variables
#
env SCRIPTS_DIR='/home/control/Documents/Controls'
env SCRIPT_NAME='xpl-hub.pl'
env LOG_FILE='/tmp/xpl-hub.log'

#-------------------------------------------------------------------------------
# Start and stop conditions
#
start on (local-filesystems and net-device-up)
stop on shutdown
respawn
setuid control
setgid users

#-------------------------------------------------------------------------------
# Startup signalling
#
post-start script
  sudo initctl emit xpl-hub_started
end script

#-------------------------------------------------------------------------------
# Start daemon
#
exec $SCRIPTS_DIR/$SCRIPT_NAME -l $LOG_FILE

Once the xPL hub has been launched, the xpl-hub_started event is emeiited.

Test launching the daemon:

service xpl-hub start
service xpl-hub status

Reboot the machine and check for the daemon:

service xpl-hub status
ps ax | grep -v grep | grep -i xpl

Mac OS