samba.sh don't try to recreate users
This commit is contained in:
parent
877eb6c480
commit
eb6c282bac
3
samba.sh
3
samba.sh
@ -51,7 +51,7 @@ global() { local key="${1%%=*}" value="${1#*=}" file=/etc/samba/smb.conf
|
|||||||
# Return: user(s) added to container
|
# Return: user(s) added to container
|
||||||
import() { local name id file="$1"
|
import() { local name id file="$1"
|
||||||
while read name id; do
|
while read name id; do
|
||||||
adduser -D -H -u "$id" "$name"
|
grep -q "^$user:" /etc/passwd || adduser -D -H -u "$id" "$name"
|
||||||
done < <(cut -d: -f1,2 $file | sed 's/:/ /')
|
done < <(cut -d: -f1,2 $file | sed 's/:/ /')
|
||||||
pdbedit -i smbpasswd:$file
|
pdbedit -i smbpasswd:$file
|
||||||
}
|
}
|
||||||
@ -126,6 +126,7 @@ smb() { local file=/etc/samba/smb.conf
|
|||||||
# Return: user added to container
|
# Return: user added to container
|
||||||
user() { local name="${1}" passwd="${2}" id="${3:-""}" group="${4:-""}"
|
user() { local name="${1}" passwd="${2}" id="${3:-""}" group="${4:-""}"
|
||||||
[[ "$group" ]] && { grep -q "^$group:" /etc/group || addgroup "$group"; }
|
[[ "$group" ]] && { grep -q "^$group:" /etc/group || addgroup "$group"; }
|
||||||
|
grep -q "^$user:" /etc/passwd ||
|
||||||
adduser -D -H ${group:+-G $group} ${id:+-u $id} "$name"
|
adduser -D -H ${group:+-G $group} ${id:+-u $id} "$name"
|
||||||
echo -e "$passwd\n$passwd" | smbpasswd -s -a "$name"
|
echo -e "$passwd\n$passwd" | smbpasswd -s -a "$name"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user