46 lines
668 B
Bash
46 lines
668 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
file=$1
|
||
|
group=$2
|
||
|
|
||
|
# 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
|
||
|
USERNAME=$(echo $p | cut -d ";" -f 1)
|
||
|
|
||
|
# Check if $USERNAME is empty
|
||
|
if [ -z "$USERNAME" ]; then
|
||
|
echo "Username is empty"
|
||
|
continue
|
||
|
fi
|
||
|
|
||
|
echo "---"# Add user to group alunos
|
||
|
echo "Adding user $USERNAME to group $group"
|
||
|
samba-tool group addmembers $group $USERNAME
|
||
|
done <$file
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|