Launch And Forget

LAF, Launch And Forget, is a software under WTFPL Licence

LAF allows to execute predefined command with predefined user id and group id. It is intended to be run with inetd (or any super internet server) to remotely execute commands without identification. When commands are executed its output (stdout or stderr) is discarded as its return value. So you just launch and forget the command (whatever it went wrong or not, you don't mind).

Checkout from svn (trunk) : http://www.tchetch.net/svn/laf/trunk/, websvn : http://www.tchetch.net/websvn/listing.php?repname=laf&path=%2Ftrunk%2F&rev=0&sc=0

Release 0.3 : http://www.tchetch.net/svn/laf/tags/0.3/, websvn : http://www.tchetch.net/websvn/listing.php?repname=laf&path=%2Ftags%2F0.3%2F&rev=0&sc=0

Configuration

LAF looks for configuration files in three places and take the first one found. The order is the following :

  1. /etc/laf/laf.conf
  2. path set in environment variable LAF_CONFIGURATION
  3. ./laf.conf

It can be changed at compilation time by editing “laf-constants.h” :

#define LAF_ENV_VAR                 "LAF_CONFIGURATION"
#define LAF_FULL_CONF_FILE_PATH     "/etc/laf/laf.conf"
#define LAF_CONF_FILE_PATH          "./laf.conf"

Configuration is parsed by libconfig, use the syntax describe here http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files.

Options in configuration :

  • path : [global], path where scripts to be executed are found.
  • kill-after : [global,script group], time to wait before killing the script (if it's not terminated).
  • actions : [global], list of action (scripts) that laf may run
  • type : [script group], name of the script when calling it from laf
  • script : [script group], filename of the script relative to path
  • user : [script group], user name under which the script is run
  • group : [script group], group name under which the script is run

There's also three named action in the global configuration :

  • unknown-action, when a client call a non-existent action (not defined in the configuration).
  • pre-action, action that will be run *each* time before any action (for each action)
  • post-action, action that will be run *each* time after any action (for each action)

Those actions don't need a type (and don't care if it is set).

Example

# Path to predefined script
path="/etc/laf/script.d/";
# Script will be killed after X seconds (not implemented yet)
kill-after=5;

actions = (
    {
        type="FRIDGE";
        script="fridge.sh";
        user="nobody";
        group="nogroup";
        kill-after=5;
    },
    {
        type="PRINTER";
        script="printer.sh";
        user="ebagnoud";
        group="Domain Users";
    },
    {
        type="BACKUP";
        script="backup.sh";
        user="root";
        group="root";
    }
);

unknown-action = {
    script="unknown.sh";
    user="nobody";
    group="nogroup";
};
pre-action = {
    script="pre.sh";
    user="nobody";
    group="nogroup";
};
post-action = {
    script="post.sh";
    user="nobody";
    group="nogroup";
};

Usage

Typical usage would be with inetd.

To call an action, you need to send a line starting by LAF with parameters quoted with ^ and parameters name separated with : from value. A parameters type must be set and match a type defined in configuration file.

If you set a single character argument in a command, laf will call the script with a single hypen, if it's multi-characters arguments two hyphens will be used

Example 1

This will run the action identified as “FRIDGE” :

LAF ^h:fridge00^ ^s:s_fridge_temp^ ^t:1272360630^ ^p:Status=EABC^ ^type:FRIDGE^

LAF will call the following command (arguments are shell-escaped) :

/etc/laf/script.d/fridge.sh -h fridge00 -s s_fridge_temp -t 1272360630 -p Status=EABC

Example 2

LAF ^h:printer232^ ^asdf:asdflasdfjkl^ ^type:PRINTER^

It will run :

/etc/laf/script.d/printer.sh -h printer232 --asdf asdflasdfjkl

laf-constants.h

This file contains almost all constants used by laf. If you want to change time before an action get killed, change LAF_KILL_AFTER. If you want to use ^ for something, you can change LAF_FIELD_SEP, …

 
projects/laf.txt · Last modified: 2010/08/11 17:35 by tchetch
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Debian Driven by DokuWiki