Difference between revisions of "Install clock"
(→Ubuntu) |
(→Install xPL clock device) |
||
(5 intermediate revisions by one user not shown) | |||
Line 5: | Line 5: | ||
= Install xPL clock device = | = Install xPL clock device = | ||
− | Download the [http://www.dspc.ch/xPL/Downloads/xpl-clock.pl xPL device] | + | Download the [http://www.dspc.ch/xPL/Downloads/xpl-clock.pl xPL device] script to xPL scripts directory: |
− | + | ||
− | + | ||
SCRIPTS_BASE_DIR=/home/control/Documents/Controls | SCRIPTS_BASE_DIR=/home/control/Documents/Controls | ||
− | + | cd $SCRIPTS_BASE_DIR | |
+ | wget http://www.dspc.ch/xPL/Downloads/xpl-clock.pl | ||
chown control:users $SCRIPTS_BASE_DIR/*.pl | chown control:users $SCRIPTS_BASE_DIR/*.pl | ||
chmod 775 $SCRIPTS_BASE_DIR/*.pl | chmod 775 $SCRIPTS_BASE_DIR/*.pl | ||
Line 15: | Line 14: | ||
= Test xPL clock device = | = Test xPL clock device = | ||
− | Open a terminal window (on any machine with xPL installed) and monitor the xPL protocol: | + | Open a terminal window and launch the device: |
+ | SCRIPTS_BASE_DIR=/home/control/Documents/Controls | ||
+ | $SCRIPTS_BASE_DIR/xpl-clock.pl -v | ||
+ | |||
+ | Open a second terminal window (on any machine with xPL installed) and monitor the xPL protocol: | ||
SCRIPTS_BASE_DIR=/home/control/Documents/Controls | SCRIPTS_BASE_DIR=/home/control/Documents/Controls | ||
$SCRIPTS_BASE_DIR/xpl-monitor.pl -vf | $SCRIPTS_BASE_DIR/xpl-monitor.pl -vf | ||
Line 23: | Line 26: | ||
= Launch the xPL clock device at startup = | = Launch the xPL clock device at startup = | ||
− | The xPL | + | The xPL clock device is to be launched after the xPL hub. |
+ | |||
+ | == Debian with SystemD == | ||
+ | |||
+ | On Debian with [https://wiki.debian.org/systemd systemd] (such as [https://www.raspbian.org/ Raspbian] | ||
+ | or [https://www.ubuntu.com/ Ubuntu]), the scripts can be defined as services. | ||
+ | |||
+ | Edit <code>/lib/systemd/system/xpl-clock.service</code>: | ||
+ | [Unit] | ||
+ | Description=xPL clock | ||
+ | After=xpl-hub.service | ||
+ | |||
+ | [Service] | ||
+ | Type=simple | ||
+ | User=control | ||
+ | Group=users | ||
+ | ExecStart=/home/control/Documents/Controls/xpl-clock.pl -n home | ||
+ | Restart=always | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | |||
+ | Activate the service: | ||
+ | su | ||
+ | systemctl enable xpl-clock.service | ||
+ | service xpl-clock start | ||
+ | |||
+ | Reboot and check: | ||
+ | ps aux | grep -v grep | grep -i xpl | ||
+ | ps ax | grep -i xpl | grep -v grep | sed 's/.*\/Controls\///' | ||
+ | systemctl list-units --type=service --state=running | grep xpl | ||
+ | service xpl-clock status | ||
− | == Ubuntu == | + | == Ubuntu with Upstart == |
On Ubuntu, the xPL clock device starts-up once <code>xpl-hub_started</code> has been emitted. | On Ubuntu, the xPL clock device starts-up once <code>xpl-hub_started</code> has been emitted. | ||
− | Edit <code>/etc/init/xpl- | + | Edit <code>/etc/init/xpl-clock.conf</code>: |
################################################################################ | ################################################################################ | ||
# xPL clock, sends ticks every minute | # xPL clock, sends ticks every minute | ||
Line 95: | Line 129: | ||
launchctl list | grep -i xpl | launchctl list | grep -i xpl | ||
− | [[Category: install]] | + | [[Category: all]] [[Category: install]] [[Category: xPL]] |
Latest revision as of 12:53, 24 February 2019
Triggering events at given times in the day is done with the help of an xPL device sending time messages every minute.
Before all, make sure you have installed an xPL hub.
Contents
[hide]Install xPL clock device
Download the xPL device script to xPL scripts directory:
SCRIPTS_BASE_DIR=/home/control/Documents/Controls cd $SCRIPTS_BASE_DIR wget http://www.dspc.ch/xPL/Downloads/xpl-clock.pl chown control:users $SCRIPTS_BASE_DIR/*.pl chmod 775 $SCRIPTS_BASE_DIR/*.pl
Test xPL clock device
Open a terminal window and launch the device:
SCRIPTS_BASE_DIR=/home/control/Documents/Controls $SCRIPTS_BASE_DIR/xpl-clock.pl -v
Open a second terminal window (on any machine with xPL installed) and monitor the xPL protocol:
SCRIPTS_BASE_DIR=/home/control/Documents/Controls $SCRIPTS_BASE_DIR/xpl-monitor.pl -vf
The monitor should echo the clock ticks every minute.
Launch the xPL clock device at startup
The xPL clock device is to be launched after the xPL hub.
Debian with SystemD
On Debian with systemd (such as Raspbian or Ubuntu), the scripts can be defined as services.
Edit /lib/systemd/system/xpl-clock.service
:
[Unit] Description=xPL clock After=xpl-hub.service [Service] Type=simple User=control Group=users ExecStart=/home/control/Documents/Controls/xpl-clock.pl -n home Restart=always [Install] WantedBy=multi-user.target
Activate the service:
su systemctl enable xpl-clock.service service xpl-clock start
Reboot and check:
ps aux | grep -v grep | grep -i xpl ps ax | grep -i xpl | grep -v grep | sed 's/.*\/Controls\///' systemctl list-units --type=service --state=running | grep xpl service xpl-clock status
Ubuntu with Upstart
On Ubuntu, the xPL clock device starts-up once xpl-hub_started
has been emitted.
Edit /etc/init/xpl-clock.conf
:
################################################################################ # xPL clock, sends ticks every minute # description "xPL clock" version "1.0" author "Francois Corthay" #------------------------------------------------------------------------------- # Configuration variables # env SCRIPTS_DIR='/home/control/Documents/Controls' env SCRIPT_NAME='xpl-clock.pl' env PARAMETERS='-n home' #------------------------------------------------------------------------------- # Start and stop conditions # start on xpl-hub_started stop on shutdown respawn setuid control setgid users #------------------------------------------------------------------------------- # Start daemon # exec $SCRIPTS_DIR/$SCRIPT_NAME $PARAMETERS
Start the device and check it is up and running:
su root service xpl-clock start service xpl-clock status initctl list | grep xpl
Mac OS
On Mac OS, the xPL clock device starts-up later than the hub.
Edit /Library/LaunchDaemons/xpl-clock.plist
:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>xPL clock</string> <key>OnDemand</key> <false/> <key>UserName</key> <string>control</string> <key>ProgramArguments</key> <array> <string>/Users/control/Documents/Controls/xpl-clock.pl</string> <string>-n</string> <string>home</string> <string>-w</string> <string>25</string> </array> </dict> </plist>
Start the device and check it is up and running:
su root launchctl load /Library/LaunchDaemons/xpl-clock.plist launchctl list | grep -i xpl