powersync-plugins/commandlauncher
Jenkins 1d694351ab Merge PR #125: Use the new nymea-plugininfocompiler for building 2019-07-22 12:17:14 +02:00
..
translations Automatic translations update by Jenkins 2019-05-02 15:00:37 +02:00
README.md Migrate commandlauncher plugin documentation 2019-06-21 17:39:11 +02:00
commandlauncher.pro
deviceplugincommandlauncher.cpp Merge PR #118: Philips Hue: Add support for the hue indoor motion sensor 2019-07-22 12:17:13 +02:00
deviceplugincommandlauncher.h Update according to new API 2019-07-04 13:42:09 +02:00
deviceplugincommandlauncher.json ake IDs unique 2019-07-10 00:35:22 +02:00

README.md

Application and script launcher

This plugin allows you to execute system commands and start bash scripts.

Application launcher

The application launcher allows you to call bash applications or commands with parameters from nymea. Once, the application started, the running state will change to true, if the application is finished, the running state will change to false.

Example

An example command could be espeak. (apt-get install espeak)

espeak -v en "Chuck Norris is using nymea"

Bash script launcher

The bashscript launcher allows you to start a bash script (with parameters) from nymea. Once, the script is running, the running state will change to true, if the application is finished, the running state will change to false.

Example

An example for a very useful script could be a backup scrip like following backup.sh script.

#!/bin/sh
# Directories to backup...
backup_files="/home /etc /root /opt /var/www /var/lib/jenkins"

# Destination of the backup...
dest="/mnt/backup"

# Create archive filename...
day=$(date +%Y%m%d)
hostname="nymea.io"
archive_file="$day-$hostname.tgz"

# Print start status message...
echo "Backing up $backup_files to $dest/$archive_file"
date
echo

# Backup the files using tar.
tar czf $dest/$archive_file $backup_files

echo
echo "Backup finished"
date
echo "==========================="
echo "  DONE, have a nice day!   "
echo "==========================="

To make the script executable use following command:

chmod +x backup.sh