Added bulk reset
This commit is contained in:
parent
cd2e06b74f
commit
2668559dbc
44
pdc-bulk-reset-password.sh
Executable file
44
pdc-bulk-reset-password.sh
Executable file
|
@ -0,0 +1,44 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
file=$1
|
||||||
|
|
||||||
|
DEFAULT_PASSWORD=123456789
|
||||||
|
PASSWORD=${2:-$DEFAULT_PASSWORD}
|
||||||
|
|
||||||
|
# Check if arguments are not empty
|
||||||
|
if [ -z "$file" ]; then
|
||||||
|
echo "Usage: $0 <file>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if file exists
|
||||||
|
if [ ! -f "$file" ]; then
|
||||||
|
echo "File $file does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if file is empty
|
||||||
|
if [ ! -s "$file" ]; then
|
||||||
|
echo "File $file is empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
while IFS="" read -r p || [ -n "$p" ]; do
|
||||||
|
echo "---"
|
||||||
|
USERNAME=$(echo $p | cut -d ";" -f 1)
|
||||||
|
|
||||||
|
# Check if $USERNAME is empty
|
||||||
|
if [ -z "$USERNAME" ]; then
|
||||||
|
echo "Username is empty"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if user exists
|
||||||
|
if ! samba-tool user show $USERNAME >/dev/null 2>&1; then
|
||||||
|
echo "User $USERNAME do not exists"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
./pdc-reset-password.sh $USERNAME $PASSWORD
|
||||||
|
|
||||||
|
done <$file
|
|
@ -1,7 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
USERNAME=$1
|
USERNAME=$1
|
||||||
PASSWORD=123456789
|
DEFAULT_PASSWORD=123456789
|
||||||
|
PASSWORD=${2:-$DEFAULT_PASSWORD}
|
||||||
|
|
||||||
# Check if arguments are not empty
|
# Check if arguments are not empty
|
||||||
if [ -z "$USERNAME" ]; then
|
if [ -z "$USERNAME" ]; then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user