Created
August 3, 2016 13:13
-
-
Save RogerCreasy/fb55ad1c6b8994990c1b9043581ec33e to your computer and use it in GitHub Desktop.
Add Samba User
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Ensure that root is running the script. | |
## | |
WHOAMI=`/usr/bin/whoami` | |
if [ $WHOAMI != "root" ]; then | |
echo "You must be root to add news users!" | |
exit 1 | |
fi | |
# | |
clear | |
NEW_USERS="/home/names.txt" | |
cat ${NEW_USERS} | \ | |
while read USER GROUP SMBPASS ; do | |
groupadd ${GROUP} 2> /dev/null | |
adduser ${USER} -g ${GROUP} | |
(echo $SMBPASS; echo $SMBPASS) | passwd --stdin ${USER} > /dev/null | |
echo Added user ${USER} | |
smbpasswd -e ${USER} -w ${SMBPASS} > /dev/null | |
(echo $SMBPASS; echo $SMBPASS) | smbpasswd -as ${USER} | |
echo -e "${USER} = ${USER}" >> /etc/samba/smbusers | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment