This file is indexed.

/usr/bin/fai-do-scripts is in fai-client 4.0.8~deb7u1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#! /bin/bash

#*********************************************************************
#
# fai-do-scripts - call configuration scripts for every defined class
#
# This script is part of FAI (Fully Automatic Installation)
# (c) 2003-2010 by Thomas Lange, lange@informatik.uni-koeln.de
# Universitaet zu Koeln
#
#*********************************************************************
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# A copy of the GNU General Public License is available as
# `/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
# or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You
# can also obtain it by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#*********************************************************************

# variables needed: $classes, $cfclasses, $LOGDIR
#
# And many other variables like:

# execute all scripts that match the name of a class.
# If class is a directory, execute all $class/[0-9][0-9]* scripts in
# it, but do not execute files ending in ~

maxstatus=0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
savemaxstatus() {

    exitcode=$1 # set global variable
    # save the highest exit status
    [ $1 -gt $maxstatus ] && maxstatus=$1
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fc_check_status() {

    local cmd st res
    cmd=$1
    st=$2

    if [ $st -eq 0 ]; then
        res="OK."
    else
        res="FAILED with exit code $st."
    fi
    # put result in the log file and write to stdout
    printf "%-20s $res\n\n" $cmd | tee -a $LOGDIR/status.log
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
call_conf() {

    local class f
    cd $1
    for class in $classes ; do
        [ -x $class -a -f $class ] && do_script $class
        if [ -d $class ]; then
           for f in $(echo $class/[0-9][0-9]* ) ; do
               [ -x $f -a -f $f ] && do_script $f
           done
        fi
    done
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
do_script() {

    # execute scripts and save their output in log files
    # cfengine, shell, perl and expect scripts are known types
    local shelldebug file filetype name

    file=$1

    # may be remove some day
    case $file in
        *~) [ X$debug = X1 ] && echo "Skipping backup file $file";   return ;;
        *.dpkg-old)  [ X$debug = X1 ] && echo "Skipping file $file"; return ;;
        *.dpkg-new)  [ X$debug = X1 ] && echo "Skipping file $file"; return ;;
        *.dpkg-inst) [ X$debug = X1 ] && echo "Skipping file $file"; return ;;
        *.dpkg-tmp)  [ X$debug = X1 ] && echo "Skipping file $file"; return ;;
        *.dpkg-dist) [ X$debug = X1 ] && echo "Skipping file $file"; return ;;
    esac

    name=${file##*/}  # basename function
    filetype=$(file -bL $file)

    if [ "$fake" ]; then
        echo "Executing $filetype"
        return
    fi

    shelldebug=
    case $filetype in
        *"POSIX shell script"*|*"Bourne shell script"*)
            [ X$debug = X1 ] && shelldebug="sh -x" ;;
        *"Bourne-Again shell script"*)
            [ X$debug = X1 ] && shelldebug="bash -x" ;;
        *"zsh script"*)
            [ X$debug = X1 ] && shelldebug="zsh -x" ;;
    esac

    case $filetype in

        *"POSIX shell script"*|*"executable shell script"*|*"/bash script"*|*"Bourne shell script"*|*"Bourne-Again shell script"*|*"zsh script"*)
            echo "Executing   $shelldebug shell: $file"
            echo "=====   shell: $file   =====" >> $LOGDIR/shell.log 2>&1
            $shelldebug ./$file >> $LOGDIR/shell.log 2>&1
            savemaxstatus $?
            fc_check_status $file $exitcode | tee -a $LOGDIR/shell.log
        ;;

        *"cf-agent"*)
            echo "Executing cf-agent: $file"
            echo "=====   cf-agent: $file   =====" >> $LOGDIR/cfagent.log 2>&1
            ./$file $cfagentdebug -KI -D${cfclasses} >> $LOGDIR/cfagent.log 2>&1
            savemaxstatus $?
            fc_check_status $file $exitcode | tee -a $LOGDIR/cfagent.log
        ;;

        *"cfagent"*)
            echo "Executing cfagent: $file"
            echo "=====   cfagent: $file   =====" >> $LOGDIR/cfagent.log 2>&1
            ./$file $cfagentdebug -qKI -D${cfclasses} >> $LOGDIR/cfagent.log 2>&1
            savemaxstatus $?
            fc_check_status $file $exitcode | tee -a $LOGDIR/cfagent.log
        ;;

        *"cfengine script"*)
            echo "Executing cfengine: $file"
            echo "=====   cfengine: $file   =====" >> $LOGDIR/cfengine.log 2>&1
            ./$file -K -v -f $file -D${cfclasses} >> $LOGDIR/cfengine.log 2>&1
            savemaxstatus $?
            fc_check_status $file $exitcode | tee -a $LOGDIR/cfengine.log
        ;;

        *[Pp]erl*script*)
            echo "Executing    perl: $file"
            echo "=====   perl: $file   =====" >> $LOGDIR/perl.log 2>&1
            ./$file >> $LOGDIR/perl.log 2>&1
            savemaxstatus $?
            fc_check_status $file $exitcode | tee -a $LOGDIR/perl.log
        ;;

        *"expect script"*)
            echo "Executing  expect: $file"
            echo "=====   expect: $file   =====" >> $LOGDIR/expect.log 2>&1
            ./$file >> $LOGDIR/expect.log 2>&1
            savemaxstatus $?
            fc_check_status $file $exitcode | tee -a $LOGDIR/expect.log
        ;;

        *[Pp]ython*script*)
            echo "Executing  python: $file"
            echo "=====   python: $file   =====" >> $LOGDIR/python.log 2>&1
            ./$file >> $LOGDIR/python.log 2>&1
            savemaxstatus $?
            fc_check_status $file $exitcode | tee -a $LOGDIR/python.log
        ;;

        *[Rr]uby*script*)
            echo "Executing ruby: $file"
            echo "=====   ruby: $file   =====" >> $LOGDIR/ruby.log 2>&1
            ./$file >> $LOGDIR/ruby.log 2>&1
            savemaxstatus $?
            fc_check_status $file $exitcode | tee -a $LOGDIR/ruby.log
        ;;

        *) echo "File $file has unsupported type $filetype." ;;
    esac
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
usage() {

    local ex
    ex=$1
    cat <<-EOF
        fai-do-scripts Copyright (C) 2003-2010 Thomas Lange
        Read the manual page fai-do-scripts(1) for more information.

        Usage: fai-do-scripts [OPTION] DIRECTORY

EOF
    exit $ex
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 # main program

while getopts "nhL:" opt ; do
    case "$opt" in
        h) usage 0 ;;
        L) LOGDIR=$OPTARG; export LOGDIR ;;
        n) fake=1 ;;
    esac
done
shift $(($OPTIND - 1))
[ -z "$1" ] || [ -n "$2" ] && usage 1

if [ "x$classes" = "x" ]; then
    echo "No classes are defined."
    exit 9
fi

[ X$debug = X1 ] && cfagentdebug=-v

call_conf $1
# move error number from child scripts to 100+x if any error happened
[ $maxstatus -gt 0 ] && maxstatus=$((100+$maxstatus))
exit $maxstatus