Migrate commandlauncher plugin documentation
parent
a5949ca574
commit
a6e9622f70
|
|
@ -0,0 +1,59 @@
|
||||||
|
# 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](http://linux.die.net/man/1/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
|
||||||
|
|
||||||
|
|
@ -21,81 +21,6 @@
|
||||||
* *
|
* *
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
/*!
|
|
||||||
\page commandlauncher.html
|
|
||||||
\title Application and script launcher
|
|
||||||
\brief Plugin for system commands.
|
|
||||||
|
|
||||||
\ingroup plugins
|
|
||||||
\ingroup nymea-plugins-maker
|
|
||||||
|
|
||||||
The application and script launcher plugin allows you to execute bash commands and start bash scripts.
|
|
||||||
|
|
||||||
\chapter Application launcher
|
|
||||||
|
|
||||||
The application launcher \l{DeviceClass} allows you to call bash applications or commands (with parameters)
|
|
||||||
from nymea. Once, the application started, the \tt running \l{State} will change to \tt true, if the application
|
|
||||||
is finished, the \tt running \l{State} will change to \tt false.
|
|
||||||
|
|
||||||
\section3 Example
|
|
||||||
An example command could be \l{http://linux.die.net/man/1/espeak}{espeak}. (\tt{apt-get install espeak})
|
|
||||||
\code
|
|
||||||
espeak -v en "Chuck Norris is using nymea"
|
|
||||||
\endcode
|
|
||||||
|
|
||||||
|
|
||||||
\chapter Bashscript launcher
|
|
||||||
|
|
||||||
The bashscript launcher \l{DeviceClass} allows you to call bash script (with parameters)
|
|
||||||
from nymea. Once, the script is running, the \tt running \l{State} will change to \tt true, if the script
|
|
||||||
is finished, the \tt running \l{State} will change to \tt false.
|
|
||||||
|
|
||||||
\section3 Example
|
|
||||||
An example for a very useful script could be a backup scrip like following \tt backup.sh script.
|
|
||||||
\code
|
|
||||||
#!/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 "==========================="
|
|
||||||
\endcode
|
|
||||||
|
|
||||||
To make the script executable use following command:
|
|
||||||
|
|
||||||
\code
|
|
||||||
chmod +x backup.sh
|
|
||||||
\endcode
|
|
||||||
|
|
||||||
\chapter Plugin properties
|
|
||||||
Following JSON file contains the definition and the description of all available \l{DeviceClass}{DeviceClasses}
|
|
||||||
and \l{Vendor}{Vendors} of this \l{DevicePlugin}.
|
|
||||||
|
|
||||||
For more details how to read this JSON file please check out the documentation for \l{The plugin JSON File}.
|
|
||||||
|
|
||||||
\quotefile plugins/deviceplugins/commandlauncher/deviceplugincommandlauncher.json
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "deviceplugincommandlauncher.h"
|
#include "deviceplugincommandlauncher.h"
|
||||||
|
|
||||||
#include "plugin/device.h"
|
#include "plugin/device.h"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue