Compare commits
No commits in common. "8d12d96bb3a24b3726fce5fac7d6dd341d23875e" and "0fbfb7fb829ac8312b219bbac14d7cba8a99328c" have entirely different histories.
8d12d96bb3
...
0fbfb7fb82
|
@ -10,9 +10,6 @@ USERNAME=$1
|
||||||
NAME=$2
|
NAME=$2
|
||||||
DEFAULT_QUOTA=256000 # 256MB
|
DEFAULT_QUOTA=256000 # 256MB
|
||||||
|
|
||||||
# Extract surname
|
|
||||||
LAST_NAME=$(echo $NAME | awk '{print $NF}')
|
|
||||||
|
|
||||||
# Check if arguments are not empty
|
# Check if arguments are not empty
|
||||||
if [ -z "$USERNAME" ] || [ -z "$NAME" ]; then
|
if [ -z "$USERNAME" ] || [ -z "$NAME" ]; then
|
||||||
echo "Usage: $0 <username> <name>"
|
echo "Usage: $0 <username> <name>"
|
||||||
|
@ -25,12 +22,6 @@ if [[ $USERNAME =~ " " ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if $USERNAME starts with a number
|
|
||||||
if [[ $USERNAME =~ ^[0-9] ]]; then
|
|
||||||
echo "Username cannot start with a number. Appending 'u' to the beginning of the username..."
|
|
||||||
USERNAME="u$USERNAME"
|
|
||||||
fi
|
|
||||||
|
|
||||||
NAME=$(echo $NAME | tr "[A-Z]" "[a-z]" | sed -e "s/\b\(.\)/\u\1/g")
|
NAME=$(echo $NAME | tr "[A-Z]" "[a-z]" | sed -e "s/\b\(.\)/\u\1/g")
|
||||||
|
|
||||||
# Check if $USERNAME is already in use
|
# Check if $USERNAME is already in use
|
||||||
|
@ -39,9 +30,11 @@ if samba-tool user show $USERNAME >/dev/null 2>&1; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Capitalize every first letter of $NAME
|
||||||
|
|
||||||
# Create user
|
# Create user
|
||||||
echo "Creating user $USERNAME with display name $NAME, last name $LAST_NAME and password $USERNAME"
|
echo "Creating user $USERNAME with name $NAME and password $USERNAME"
|
||||||
samba-tool user create $USERNAME $USERNAME --userou='OU=Alunos,OU=IFMS-PP' --given-name="$NAME" --surname="$LAST_NAME" --home-drive='H:' --home-directory="\\\\acadsrv.ACAD.PP.IFMS.EDU.BR\\$USERNAME" --use-username-as-cn --must-change-at-next-login
|
samba-tool user create $USERNAME $USERNAME --userou='OU=Alunos,OU=IFMS-PP' --given-name="$NAME" --home-drive='H:' --home-directory="\\\\acadsrv.ACAD.PP.IFMS.EDU.BR\\$USERNAME" --use-username-as-cn --must-change-at-next-login
|
||||||
|
|
||||||
# Add user to group alunos
|
# Add user to group alunos
|
||||||
echo "Adding user $USERNAME to group alunos"
|
echo "Adding user $USERNAME to group alunos"
|
||||||
|
@ -51,7 +44,7 @@ samba-tool group addmembers alunos $USERNAME
|
||||||
echo "Creating home directory for user $USERNAME"
|
echo "Creating home directory for user $USERNAME"
|
||||||
mkdir /home/$USERNAME
|
mkdir /home/$USERNAME
|
||||||
echo "Setting permissions for home directory"
|
echo "Setting permissions for home directory"
|
||||||
chmod 711 /home/$USERNAME/ -R
|
chmod 700 /home/$USERNAME/ -R
|
||||||
chown $USERNAME:'domain users' /home/$USERNAME/ -R
|
chown $USERNAME:'domain users' /home/$USERNAME/ -R
|
||||||
|
|
||||||
# Set user quota
|
# Set user quota
|
||||||
|
|
|
@ -10,9 +10,6 @@ USERNAME=$1
|
||||||
NAME=$2
|
NAME=$2
|
||||||
DEFAULT_QUOTA=256000 # 256MB
|
DEFAULT_QUOTA=256000 # 256MB
|
||||||
|
|
||||||
# Extract surname
|
|
||||||
LAST_NAME=$(echo $NAME | awk '{print $NF}')
|
|
||||||
|
|
||||||
# Check if arguments are not empty
|
# Check if arguments are not empty
|
||||||
if [ -z "$USERNAME" ] || [ -z "$NAME" ]; then
|
if [ -z "$USERNAME" ] || [ -z "$NAME" ]; then
|
||||||
echo "Usage: $0 <username> <name>"
|
echo "Usage: $0 <username> <name>"
|
||||||
|
@ -25,12 +22,6 @@ if [[ $USERNAME =~ " " ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if $USERNAME starts with a number
|
|
||||||
if [[ $USERNAME =~ ^[0-9] ]]; then
|
|
||||||
echo "Username cannot start with a number. Appending 'u' to the beginning of the username..."
|
|
||||||
USERNAME="u$USERNAME"
|
|
||||||
fi
|
|
||||||
|
|
||||||
NAME=$(echo $NAME | tr "[A-Z]" "[a-z]" | sed -e "s/\b\(.\)/\u\1/g")
|
NAME=$(echo $NAME | tr "[A-Z]" "[a-z]" | sed -e "s/\b\(.\)/\u\1/g")
|
||||||
|
|
||||||
# Check if $USERNAME is already in use
|
# Check if $USERNAME is already in use
|
||||||
|
@ -39,9 +30,11 @@ if samba-tool user show $USERNAME >/dev/null 2>&1; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Capitalize every first letter of $NAME
|
||||||
|
|
||||||
# Create user
|
# Create user
|
||||||
echo "Creating user $USERNAME with name $NAME and password $USERNAME"
|
echo "Creating user $USERNAME with name $NAME and password $USERNAME"
|
||||||
samba-tool user create $USERNAME $USERNAME --userou='OU=Professores,OU=IFMS-PP' --given-name="$NAME" --surname="$LAST_NAME" --home-drive='H:' --home-directory="\\\\acadsrv.ACAD.PP.IFMS.EDU.BR\\$USERNAME" --use-username-as-cn --must-change-at-next-login
|
samba-tool user create $USERNAME $USERNAME --userou='OU=Professores,OU=IFMS-PP' --given-name="$NAME" --home-drive='H:' --home-directory="\\\\acadsrv.ACAD.PP.IFMS.EDU.BR\\$USERNAME" --use-username-as-cn --must-change-at-next-login
|
||||||
|
|
||||||
# Add user to group alunos
|
# Add user to group alunos
|
||||||
echo "Adding user $USERNAME to group professores"
|
echo "Adding user $USERNAME to group professores"
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
###############################
|
|
||||||
# Script to add a student #
|
|
||||||
# Must be run as root #
|
|
||||||
# For use with Zential Server #
|
|
||||||
###############################
|
|
||||||
|
|
||||||
USERNAME=$1
|
|
||||||
NAME=$2
|
|
||||||
DEFAULT_QUOTA=256000 # 256MB
|
|
||||||
|
|
||||||
# Extract surname
|
|
||||||
LAST_NAME=$(echo $NAME | awk '{print $NF}')
|
|
||||||
|
|
||||||
# Check if arguments are not empty
|
|
||||||
if [ -z "$USERNAME" ] || [ -z "$NAME" ]; then
|
|
||||||
echo "Usage: $0 <username> <name>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if $USERNAME has spaces
|
|
||||||
if [[ $USERNAME =~ " " ]]; then
|
|
||||||
echo "Username cannot have spaces"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if $USERNAME starts with a number
|
|
||||||
if [[ $USERNAME =~ ^[0-9] ]]; then
|
|
||||||
echo "Username cannot start with a number. Appending 'u' to the beginning of the username..."
|
|
||||||
USERNAME="u$USERNAME"
|
|
||||||
fi
|
|
||||||
|
|
||||||
NAME=$(echo $NAME | tr "[A-Z]" "[a-z]" | sed -e "s/\b\(.\)/\u\1/g")
|
|
||||||
|
|
||||||
# Check if $USERNAME is already in use
|
|
||||||
if samba-tool user show $USERNAME >/dev/null 2>&1; then
|
|
||||||
echo "User $USERNAME already exists"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create user
|
|
||||||
echo "Creating user $USERNAME with name $NAME and password $USERNAME"
|
|
||||||
samba-tool user create $USERNAME $USERNAME --userou='OU=Servidores,OU=IFMS-PP' --given-name="$NAME" --surname="$LAST_NAME" --home-drive='H:' --home-directory="\\\\acadsrv.ACAD.PP.IFMS.EDU.BR\\$USERNAME" --use-username-as-cn --must-change-at-next-login
|
|
||||||
|
|
||||||
# Add user to group alunos
|
|
||||||
echo "Adding user $USERNAME to group servidores"
|
|
||||||
samba-tool group addmembers servidores $USERNAME
|
|
||||||
|
|
||||||
# Create home directory
|
|
||||||
echo "Creating home directory for user $USERNAME"
|
|
||||||
mkdir /home/$USERNAME
|
|
||||||
echo "Setting permissions for home directory"
|
|
||||||
chmod 700 /home/$USERNAME/ -R
|
|
||||||
chown $USERNAME:'domain users' /home/$USERNAME/ -R
|
|
||||||
|
|
||||||
# Set user quota
|
|
||||||
./pdc-setquota.sh $USERNAME $DEFAULT_QUOTA
|
|
||||||
|
|
||||||
echo "User $USERNAME ($NAME) created. Password must be changed at next login."
|
|
|
@ -1,36 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
file=$1
|
|
||||||
|
|
||||||
# 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)
|
|
||||||
NAME=$(echo $p | cut -d ";" -f 2)
|
|
||||||
|
|
||||||
# Check if $USERNAME is empty
|
|
||||||
if [ -z "$USERNAME" ]; then
|
|
||||||
echo "Username is empty"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "---"
|
|
||||||
./pdc-add-user-servidor.sh $USERNAME "$NAME"
|
|
||||||
|
|
||||||
done <$file
|
|
|
@ -1,45 +0,0 @@
|
||||||
#!/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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
0
pdc-bulk-del-user.sh
Executable file → Normal file
0
pdc-bulk-del-user.sh
Executable file → Normal file
|
@ -1,50 +0,0 @@
|
||||||
#!/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 $USERNAME starts with a number
|
|
||||||
if [[ $USERNAME =~ ^[0-9] ]]; then
|
|
||||||
echo "Username cannot start with a number. Appending 'u' to the beginning of the username..."
|
|
||||||
USERNAME="u$USERNAME"
|
|
||||||
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
|
|
|
@ -8,12 +8,6 @@ if [ -z "$USERNAME" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if $USERNAME starts with a number
|
|
||||||
if [[ $USERNAME =~ ^[0-9] ]]; then
|
|
||||||
echo "Username cannot start with a number. Appending 'u' to the beginning of the username..."
|
|
||||||
USERNAME="u$USERNAME"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if user exists
|
# Check if user exists
|
||||||
if ! samba-tool user show $USERNAME >/dev/null 2>&1; then
|
if ! samba-tool user show $USERNAME >/dev/null 2>&1; then
|
||||||
echo "User $USERNAME does not exist"
|
echo "User $USERNAME does not exist"
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
USERNAME=$1
|
|
||||||
DEFAULT_PASSWORD=123456789
|
|
||||||
PASSWORD=${2:-$DEFAULT_PASSWORD}
|
|
||||||
|
|
||||||
# Check if arguments are not empty
|
|
||||||
if [ -z "$USERNAME" ]; then
|
|
||||||
echo "Usage: $0 <username>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if $USERNAME starts with a number
|
|
||||||
if [[ $USERNAME =~ ^[0-9] ]]; then
|
|
||||||
echo "Username cannot start with a number. Appending 'u' to the beginning of the username..."
|
|
||||||
USERNAME="u$USERNAME"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if $USERNAME exists
|
|
||||||
if ! samba-tool user show $USERNAME >/dev/null 2>&1; then
|
|
||||||
echo "User $USERNAME do not exists"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set user password
|
|
||||||
echo "Setting user password $PASSWORD for user $USERNAME"
|
|
||||||
|
|
||||||
# Set user password with smbpasswd, inject password and password confirmation into stdin
|
|
||||||
echo -e "$PASSWORD\n$PASSWORD" | smbpasswd -s -a $USERNAME >>/var/log/samba/smbpasswd.log 2>&1
|
|
||||||
|
|
||||||
# Force password change on next login
|
|
||||||
echo "Forcing password change on next login for user $USERNAME"
|
|
||||||
net sam set pwdmustchangenow $USERNAME yes >>/var/log/samba/smbpasswd.log 2>&1
|
|
|
@ -1,3 +0,0 @@
|
||||||
aluno1;aluno minusculo;
|
|
||||||
aluno2;ALUNO MAIUSCULO;
|
|
||||||
aluno3;ALUNO misturado;
|
|
|
Loading…
Reference in New Issue
Block a user