Skip to content

Commit

Permalink
examples: Reformat shell scripts
Browse files Browse the repository at this point in the history
shfmt -f examples/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>

Autobuild-User(master): Andreas Schneider <[email protected]>
Autobuild-Date(master): Tue Feb 22 16:20:58 UTC 2022 on sn-devel-184
  • Loading branch information
cryptomilk committed Feb 22, 2022
1 parent 1b8b6ac commit 3990c33
Show file tree
Hide file tree
Showing 15 changed files with 255 additions and 218 deletions.
12 changes: 6 additions & 6 deletions examples/LDAP/get_next_oid
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash

nextattrib=`cat samba.schema | grep -i attributetype.*\(.*1.3.6.1.4.1.7165. | grep -v '^#' | \
awk '{print $3}' | cut -d. -f 10 | sort -n | tail -1`
nextattrib=$(cat samba.schema | grep -i attributetype.*\(.*1.3.6.1.4.1.7165. | grep -v '^#' |
awk '{print $3}' | cut -d. -f 10 | sort -n | tail -1)

(( nextattrib += 1 ))
( (nextattrib += 1))

echo "attributetype ( 1.3.6.1.4.1.7165.2.1.$nextattrib NAME ...."

nextoc=`cat samba.schema | grep -i objectclass.*\(.*1.3.6.1.4.1.7165. | grep -v '^#' | \
awk '{print $3}' | cut -d. -f 10 | sort -n | tail -1`
nextoc=$(cat samba.schema | grep -i objectclass.*\(.*1.3.6.1.4.1.7165. | grep -v '^#' |
awk '{print $3}' | cut -d. -f 10 | sort -n | tail -1)

(( nextoc += 1 ))
( (nextoc += 1))

echo "objectclass ( 1.3.6.1.4.1.7165.2.2.$nextoc NAME ...."
14 changes: 7 additions & 7 deletions examples/ad-bench/ad-bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with AD-Bench. If not, see <http://www.gnu.org/licenses/>.

source `dirname $0`/utils.sh
source $(dirname $0)/utils.sh

if [ ! -f $RUNS ]; then
echo "Error: please fill in $RUNS"
Expand All @@ -27,12 +27,12 @@ if [ ! -f $RUNS ]; then
exit 1
fi

for run in `cat $RUNS`; do
for run in $(cat $RUNS); do
echo "START RUN"
bash `dirname $0`/time_kinit.sh `echo $run|cut -d ":" -f 1`
bash `dirname $0`/time_join.sh `echo $run|cut -d ":" -f 1` `echo $run|cut -d ":" -f 2`
bash `dirname $0`/time_user.sh `echo $run|cut -d ":" -f 1` `echo $run|cut -d ":" -f 2`
bash `dirname $0`/time_group.sh `echo $run|cut -d ":" -f 1` `echo $run|cut -d ":" -f 2`
bash `dirname $0`/time_ldap.sh `echo $run|cut -d ":" -f 1` `echo $run|cut -d ":" -f 2`
bash $(dirname $0)/time_kinit.sh $(echo $run | cut -d ":" -f 1)
bash $(dirname $0)/time_join.sh $(echo $run | cut -d ":" -f 1) $(echo $run | cut -d ":" -f 2)
bash $(dirname $0)/time_user.sh $(echo $run | cut -d ":" -f 1) $(echo $run | cut -d ":" -f 2)
bash $(dirname $0)/time_group.sh $(echo $run | cut -d ":" -f 1) $(echo $run | cut -d ":" -f 2)
bash $(dirname $0)/time_ldap.sh $(echo $run | cut -d ":" -f 1) $(echo $run | cut -d ":" -f 2)
echo "END RUN"
done
5 changes: 2 additions & 3 deletions examples/ad-bench/settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with AD-Bench. If not, see <http://www.gnu.org/licenses/>.


DATE=date
BC=bc
SED=sed
Expand All @@ -36,6 +35,6 @@ SEQ=seq
NEW_KRB5CCNAME=/tmp/ad_test_ccname

NET="${HOME}/samba/bin/net"
CONFIG_FILE=`dirname $0`/smb.conf
CONFIG_FILE=$(dirname $0)/smb.conf

RUNS=`dirname $0`/runs.txt
RUNS=$(dirname $0)/runs.txt
14 changes: 6 additions & 8 deletions examples/ad-bench/test_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
# You should have received a copy of the GNU General Public License
# along with AD-Bench. If not, see <http://www.gnu.org/licenses/>.


source `dirname $0`/utils.sh
source $(dirname $0)/utils.sh

INPUT="[email protected]%secret"
echo "Principal for $INPUT is " $( get_principal $INPUT )
echo "Password for $INPUT is " $( get_password $INPUT )
echo "Realm for $INPUT is " $( get_realm $INPUT )
echo "NT_DOM for $INPUT is " $( get_nt_dom $INPUT )

echo "Principal for $INPUT is " $(get_principal $INPUT)
echo "Password for $INPUT is " $(get_password $INPUT)
echo "Realm for $INPUT is " $(get_realm $INPUT)
echo "NT_DOM for $INPUT is " $(get_nt_dom $INPUT)

echo "Padding 2: " $( pad_number 1 2 ) " 4: " $(pad_number 23 4)
echo "Padding 2: " $(pad_number 1 2) " 4: " $(pad_number 23 4)
38 changes: 22 additions & 16 deletions examples/ad-bench/time_group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,61 +20,67 @@

ITERATIONS=100

source `dirname $0`/utils.sh
source $(dirname $0)/utils.sh

PRINCIPAL=$(get_principal $1)
PASSWORD=$(get_password $1)
REALM=$(get_realm $1)
NT_DOM=$(get_nt_dom $1)
SERVER=$2

add_group () {
add_group()
{
GROUP=$1
${NET} ads group add "${GROUP}" -k --configfile=$CONFIG_FILE -S ${SERVER} > /dev/null
${NET} ads group add "${GROUP}" -k --configfile=$CONFIG_FILE -S ${SERVER} >/dev/null
RET=$?
if [ $RET -ne 0 ]; then
echo "${NET} ads group add returned error: $RET"
exit 1
fi
}

del_group () {
del_group()
{
GROUP=$1
${NET} ads group delete "${GROUP}" -k --configfile=$CONFIG_FILE -S ${SERVER} > /dev/null
${NET} ads group delete "${GROUP}" -k --configfile=$CONFIG_FILE -S ${SERVER} >/dev/null
RET=$?
if [ $RET -ne 0 ]; then
echo "${NET} returned error: $RET"
exit 1
fi
}

enum_group () {
${NET} ads group -k --configfile=$CONFIG_FILE -S $SERVER > /dev/null
enum_group()
{
${NET} ads group -k --configfile=$CONFIG_FILE -S $SERVER >/dev/null
RET=$?
if [ $RET -ne 0 ]; then
echo "${NET} returned error: $RET"
exit 1
fi
}

info_group () {
info_group()
{
GROUP=$1
${NET} ads group info "${GROUP}" -k --configfile=$CONFIG_FILE -S ${SERVER} > /dev/null
${NET} ads group info "${GROUP}" -k --configfile=$CONFIG_FILE -S ${SERVER} >/dev/null
RET=$?
if [ $RET -ne 0 ]; then
echo "${NET} returned error: $RET"
exit 1
fi
}

set_up () {
set_up()
{
set_krb_env
setup_kinit
call_kinit "${PRINCIPAL}" "${PASSWORD}"
write_configfile "${REALM}" "${NT_DOM}"
}

tear_down () {
tear_down()
{
${KDESTROY}
restore_krb_env
}
Expand All @@ -86,8 +92,8 @@ echo -e "\tGROUP $SERVER"
START_TIME=$(start_timer)

echo -en "\t"
for i in $( ${SEQ} 1 $ITERATIONS ); do
GROUP=$( echo "ad_test_$(pad_number $i 3)" )
for i in $(${SEQ} 1 $ITERATIONS); do
GROUP=$(echo "ad_test_$(pad_number $i 3)")
add_group $GROUP
echo -n "."
done
Expand All @@ -105,16 +111,16 @@ enum_group
#echo "done"

echo -en "\t"
for i in $( ${SEQ} 1 $ITERATIONS ); do
GROUP=$( echo "ad_test_$(pad_number $i 3)" )
for i in $(${SEQ} 1 $ITERATIONS); do
GROUP=$(echo "ad_test_$(pad_number $i 3)")
del_group $GROUP
echo -n "."
done
echo "done"

STOP_TIME=$(stop_timer)

TOTAL_TIME=$( total_time $START_TIME $STOP_TIME )
TOTAL_TIME=$(total_time $START_TIME $STOP_TIME)

echo -e "\t\ttotal time:\t\t${TOTAL_TIME}s"

Expand Down
22 changes: 13 additions & 9 deletions examples/ad-bench/time_join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,44 @@

ITERATIONS=100

source `dirname $0`/utils.sh
source $(dirname $0)/utils.sh

PRINCIPAL=$(get_principal $1)
PASSWORD=$(get_password $1)
REALM=$(get_realm $1)
NT_DOM=$(get_nt_dom $1)

join_domain () {
join_domain()
{
SERVER=$1
${NET} ads join -k --configfile=$CONFIG_FILE -S ${SERVER} > /dev/null
${NET} ads join -k --configfile=$CONFIG_FILE -S ${SERVER} >/dev/null
RET=$?
if [ $RET -ne 0 ]; then
echo "${NET} returned error: $RET"
exit 1
fi
}

leave_domain () {
leave_domain()
{
SERVER=$1
${NET} ads leave -k --configfile=$CONFIG_FILE -S ${SERVER} > /dev/null
${NET} ads leave -k --configfile=$CONFIG_FILE -S ${SERVER} >/dev/null
if [ $RET -ne 0 ]; then
echo "${NET} returned error: $RET"
exit 1
fi
}

set_up () {
set_up()
{
set_krb_env
setup_kinit
call_kinit "${PRINCIPAL}" "${PASSWORD}"
write_configfile "${REALM}" "${NT_DOM}"
}

tear_down () {
tear_down()
{
${KDESTROY}
restore_krb_env
}
Expand All @@ -65,7 +69,7 @@ echo -e "\tJOIN $2"
START_TIME=$(start_timer)

echo -en "\t"
for i in $( ${SEQ} 1 $ITERATIONS ); do
for i in $(${SEQ} 1 $ITERATIONS); do
join_domain $2
leave_domain $2
echo -n "."
Expand All @@ -74,7 +78,7 @@ echo "done"

STOP_TIME=$(stop_timer)

TOTAL_TIME=$( total_time $START_TIME $STOP_TIME )
TOTAL_TIME=$(total_time $START_TIME $STOP_TIME)

echo -e "\t\ttotal time:\t\t${TOTAL_TIME}s"

Expand Down
18 changes: 10 additions & 8 deletions examples/ad-bench/time_kinit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,27 @@
# often
ITERATIONS=100

source `dirname $0`/utils.sh
source $(dirname $0)/utils.sh

set_up () {
set_up()
{
set_krb_env
setup_kinit
}

tear_down () {
tear_down()
{
restore_krb_env
}

set_up

PRINCIPAL=$( get_principal $1)
PASSWORD=$( get_password $1)
PRINCIPAL=$(get_principal $1)
PASSWORD=$(get_password $1)

echo -e "\tKINIT ${PRINCIPAL}"

START_TIME=$( start_timer )
START_TIME=$(start_timer)

echo -en "\t"
for i in $(${SEQ} 1 $ITERATIONS); do
Expand All @@ -50,9 +52,9 @@ for i in $(${SEQ} 1 $ITERATIONS); do
done
echo "done"

STOP_TIME=$( stop_timer )
STOP_TIME=$(stop_timer)

TOTAL_TIME=$( total_time $START_TIME $STOP_TIME )
TOTAL_TIME=$(total_time $START_TIME $STOP_TIME)

echo -e "\t\ttotal time:\t\t${TOTAL_TIME}s"

Expand Down
Loading

0 comments on commit 3990c33

Please sign in to comment.