Home

Peter Fichtner

GENERAL

LAWS is the linux automatic wakeup system which is a completely configurable distribution of sh scripts.
It can be used e.g. to wakeup remote computers using self-defined rules to check if has been booted succesfully and is reachable.

Each task (e.g. wakeup host A, wakeup host B, do something other) should be defined in a subdir of "scenarios".
You than call call "laws" passing the name of the scenario to execute checks/action/execs of it.

ARGUMENT PASSING

To all commands inside subdirectories like checks/actions/... arguments can be passed (see tree below). Let's assume we have a script called foo.
If you want to to pass values read from a configfile just create symlinks to this config file using the pattern <pos>:<varname>
The configfile also can be a sh-script that sets <varname>. In the example below a sh script named read_bbackup_conf is used and values like DATADIR etc. are passed to the command called.

If you have execs-available that are useable not just for yourself please send them to me. Also ideas/patches are welcome!

filesystem tree (the doBackup-example resists inside scenarios/doBackup-example.tar.bz2, please extract it to explore it or delete it otherwise):
├── laws # the main script, takes scenario name as argument
├── laws.config # laws's base config
├── execs-available # predefined execs, use them using links inside the actions directories
│   └── bbackup_sync
├── checks-available * predefined checks, use them using links inside the "checks" or "prechecks" directories
│   ├── areUsersLoggedIn
│   ├── isDefaultRoute
│   ├── netcat
├── functions # predefined helper functions that can be sourced by scripts
│   └── read_bbackup_conf
└── scenarios # the directroy where you can create different scenarios in. The name of the scenario is than passed to the "laws" script
   └── doBackup-example # an example scenario I use to wakeup my remote backupsrv when needed
   ├── prechecks # (optional) if one script returns rc > 0 "laws" script will break immediately, if one rc is 99 actions will be called immediately before exiting if checks are ok
├── 000-isDefaultRoute -> ../../../checks-available/isDefaultRoute
├── 000-isDefaultRoute.args
│   └── 1:IP -> ../000-isDefaultRoute.config
├── 000-isDefaultRoute.config
├── 005-bbackup_running
├── 005-bbackup_running.args
│   └── 1:DATADIR -> ../../../../functions/read_bbackup_conf
├── 010-limitreached # check if time limits are reaced (pass DATADIR and SOFT-/HARDLIMIT as arguments)
├── 010-limitreached.args
│   ├── 1:DATADIR -> ../../../../functions/read_bbackup_conf
│   ├── 2:SOFT_LIMIT -> ../010-limitreached.config
│   └── 3:HARD_LIMIT -> ../010-limitreached.config
└── 010-limitreached.config
   ├── checks # while one of the script inside checks returns != 0 "laws" will keep looping
   │   ├── netcat -> ../../../checks-available/netcat # call ../../checks-available/netcat with two args: STOREHOSTNAME from ../../../functions/read_bbackup_conf (which itself reads bbackup-config) and PORT as read from netcat.config
   │   ├── netcat.args
   │   │   ├── 1:STOREHOSTNAME -> ../../../../functions/read_bbackup_conf
   │   │   └── 2:PORT -> ../netcat.config
   │   └── netcat.config
   ├── actions # will be executed while looping (looping ends if checks returned ok or on timeout)
   │   ├── wakeonlan -> /usr/bin/wakeonlan # call /usr/bin/wakeonlan with one argument (MAC_ADDRESS read from wakeonlan.config)
   │   ├── wakeonlan.args
   │   │   └── 1:MAC_ADDRESS -> ../wakeonlan.config
   │   └── wakeonlan.config
   └── execs # will be executed after loop has been left succesfully
   └── bbackup_sync -> ../../../execs-available/bbackup_sync