| 1 | check_requires() { # Check required files, monitors and reactors |
| 2 | for i in "$@" ; do |
| 3 | p=${i%:program} |
| 4 | m=${i%:monitor} |
| 5 | r=${i%:reactor} |
| 6 | if [ $p != $i ]; then |
| 7 | if ! which $p ; then |
| 8 | echo "Required program $p is not found." |
| 9 | exit_unresolved |
| 10 | fi |
| 11 | elif [ $m != $i ]; then |
| 12 | if ! grep -wq $m available_monitors ; then |
| 13 | echo "Required monitor $m is not configured." |
| 14 | exit_unsupported |
| 15 | fi |
| 16 | elif [ $r != $i ]; then |
| 17 | if ! grep -wq $r available_reactors ; then |
| 18 | echo "Required reactor $r is not configured." |
| 19 | exit_unsupported |
| 20 | fi |
| 21 | elif [ ! -e $i ]; then |
| 22 | echo "Required feature interface $i doesn't exist." |
| 23 | exit_unsupported |
| 24 | fi |
| 25 | done |
| 26 | } |
| 27 | |
| 28 | initialize_system() { # Reset RV to initial-state |
| 29 | echo > enabled_monitors |
| 30 | for m in monitors/*; do |
| 31 | echo nop > $m/reactors || true |
| 32 | done |
| 33 | echo 1 > monitoring_on |
| 34 | echo 1 > reacting_on || true |
| 35 | } |
| 36 | |
| 37 | finish_system() { |
| 38 | initialize_system |
| 39 | } |