Skip to content

Commit

Permalink
update useradd.sh with better error correction
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmayer2 committed Dec 16, 2023
1 parent 454dc38 commit 39eef60
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions pulumi/server-side-files/config/useradd.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
#!/bin/bash

N=20
N=40

for i in \`seq 1 \$1\`
do
(
(
username=posit\`printf %04i \$i\`
if ( ! id \$username >& /dev/null ); then
while true
do
username=posit\`printf %04i \$i\`
if ( ! id \$username >& /dev/null ); then
echo "creating user \$username"
expect create-users.exp \$username {{user_password}} >& /dev/null
#echo {{user_password}} | pamtester login \$username authenticate
else
echo "user \$username already exists"
fi
if [ \$? -eq 0 ]; then
do
sleep \`echo 2*\$(( \$i % \$N ))/\$N | bc -l\`
echo creating user \$username
if ( ! id \$username >& /dev/null ); then
expect create-users.exp \$username {{user_password}} >& /dev/null
fi
sleep 5
if ( echo {{user_password}} | pamtester login \$username authenticate ); then
break
fi
done
fi
) &
if [[ \$(jobs -r -p | wc -l) -ge \$N ]]; then
wait -n
Expand Down

0 comments on commit 39eef60

Please sign in to comment.