2 # AD-Bench utility functions
4 # Copyright (C) 2009 Kai Blin <kai@samba.org>
6 # This file is part of AD-Bench, an Active Directory benchmark tool
8 # AD-Bench is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # AD-Bench is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with AD-Bench. If not, see <http://www.gnu.org/licenses/>.
21 source `dirname $0`/settings.sh
24 START_TIME
=$
( ${DATE} ${DATE_FORMATSTR} )
29 STOP_TIME
=$
( ${DATE} ${DATE_FORMATSTR} )
36 TOTAL_TIME
=$
( echo "scale=9;$STOP_TIME - $START_TIME" |
${BC} )
40 iterations_per_minute
() {
45 TOTAL_TIME
=$
( total_time
$START_TIME $STOP_TIME )
47 ITER_PER_MIN
=$
( echo "scale=2; 60 * $TOTAL_RUNS / $TOTAL_TIME" |
${BC} )
52 PRINCIPAL
=$
( echo $1 |
${SED} -e "s/\(.*\)%.*/\1/" )
57 PASSWORD
=$
( echo $1 |
${SED} -e "s/.*%\(.*\)/\1/" )
62 REALM
=$
( echo $1 |
${SED} -e "s/.*@\(.*\)%.*/\1/" )
67 NT_DOM
=$
( echo $1 |
${SED} -e "s/.*@\([A-Z1-9-]*\)\..*/\1/" )
72 OLD_KRB5CCNAME
="${KRB5CCNAME}"
73 KRB5CCNAME
="${NEW_KRB5CCNAME}"
78 KRB5CCNAME
="${OLD_KRB5CCNAME}"
83 ${KINIT} --invalid 2>&1 |
grep -q "password-file"
85 KINIT
="${KINIT} ${KINIT_PARAM_OLD}"
87 KINIT
="${KINIT} ${KINIT_PARAM_NEW}"
94 echo -e "[global]" > $CONFIG_FILE
95 echo -e "\trealm = $REALM" >> $CONFIG_FILE
96 echo -e "\tworkgroup = $NT_DOM" >> $CONFIG_FILE
97 echo -e "\tsecurity = ADS" >> $CONFIG_FILE
103 echo "${PASSWORD}" | ${KINIT} ${PRINCIPAL} > /dev/null
105 if [ $RET -ne 0 ]; then
106 echo "kinit returned an error
: $RET"
114 PADDED_NO=$(printf "%0${DIGITS}d
" $NUMBER)