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
25 START_TIME
=$
(${DATE} ${DATE_FORMATSTR})
31 STOP_TIME
=$
(${DATE} ${DATE_FORMATSTR})
39 TOTAL_TIME
=$
(echo "scale=9;$STOP_TIME - $START_TIME" |
${BC})
43 iterations_per_minute
()
49 TOTAL_TIME
=$
(total_time
$START_TIME $STOP_TIME)
51 ITER_PER_MIN
=$
(echo "scale=2; 60 * $TOTAL_RUNS / $TOTAL_TIME" |
${BC})
57 PRINCIPAL
=$
(echo $1 |
${SED} -e "s/\(.*\)%.*/\1/")
63 PASSWORD
=$
(echo $1 |
${SED} -e "s/.*%\(.*\)/\1/")
69 REALM
=$
(echo $1 |
${SED} -e "s/.*@\(.*\)%.*/\1/")
75 NT_DOM
=$
(echo $1 |
${SED} -e "s/.*@\([A-Z1-9-]*\)\..*/\1/")
81 OLD_KRB5CCNAME
="${KRB5CCNAME}"
82 KRB5CCNAME
="${NEW_KRB5CCNAME}"
88 KRB5CCNAME
="${OLD_KRB5CCNAME}"
94 ${KINIT} --invalid 2>&1 |
grep -q "password-file"
96 KINIT
="${KINIT} ${KINIT_PARAM_OLD}"
98 KINIT
="${KINIT} ${KINIT_PARAM_NEW}"
106 echo -e "[global]" >$CONFIG_FILE
107 echo -e "\trealm = $REALM" >>$CONFIG_FILE
108 echo -e "\tworkgroup = $NT_DOM" >>$CONFIG_FILE
109 echo -e "\tsecurity = ADS" >>$CONFIG_FILE
116 echo "${PASSWORD}" | ${KINIT} ${PRINCIPAL} >/dev/null
118 if [ $RET -ne 0 ]; then
119 echo "kinit returned an error
: $RET"
128 PADDED_NO=$(printf "%0${DIGITS}d
" $NUMBER)