Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Issues with users.conf #34

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions samba.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ add_user() {
fi

# Check if the user is a samba user
if pdbedit -s "$cfg" -L | grep -q "^$username:"; then
pdb_output=$(pdbedit -s "$cfg" -L) #Do not combine the two commands into one, as this could lead to issues with the execution order and proper passing of variables.
if echo "$pdb_output" | grep -q "^$username:"; then
# If the user is a samba user, update its password in case it changed
echo -e "$password\n$password" | smbpasswd -c "$cfg" -s "$username" > /dev/null || { echo "Failed to update Samba password for $username"; return 1; }
else
Expand Down Expand Up @@ -126,7 +127,7 @@ if [ -f "$users" ] && [ -s "$users" ]; then
# Call the function with extracted values
add_user "$config" "$username" "$uid" "$groupname" "$gid" "$password" || { echo "Failed to add user $username"; exit 1; }

done < "$users"
done < <(tr -d '\r' < "$users")

else

Expand Down
Loading