NAME

Csistck::Test::Script - Csistck script check

DESCRIPTION

METHODS

script($script, \@args, :\&on_repair)

Call script with extra arguments, if supplied. The first argument passed to the script is the run mode, MODE_CHECK or MODE_RUN.

role 'test' => script('apache2/mod-check', 'rewrite');

When processed, the code above, in check mode for example, the process spawned would be:

/path/to/script/apache2/mod-check check rewrite

If a repair operation is run, the on_repair function is called.

CONSTANTS

MODE_CHECK

The string passed to scripts when in check mode

MODE_RUN

The string passed to scripts when in repair mode

EXAMPLE

#!/bin/bash

PKGINFO=`which pkg_info`
MODE=$1
PKG=$2

# We can't automate pkgsrc
[ "$MODE" == "run" ] &&
  { echo "Error: do it yourself, asshole."; exit 1; }

# Test for pkgsrc
[ -d /usr/pkg ] ||
  { echo "Error: pkgsrc does not exist."; exit 1; }

# Check we have pkg_info and test for package
[ "$PKGINFO" == "" ] &&
  { echo "Error: pkg_info not found."; exit 1; }

$PKGINFO $PKG >& /dev/null ||
  { echo "Error: package $PKG not found."; exit 1; }

exit 0

The above script is an example of using the script test to test for pkgsrc packages. This script reports an error in repair mode, as pkgsrc can't really be automated.

AUTHOR

Anthony Johnson, <anthony@ohess.org>

COPYRIGHT AND LICENSE

Copyright (c) 2011 Anthony Johnson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,