delete existing user/groups by name vs id
This commit is contained in:
parent
20d90c684b
commit
c80a7dc018
|
@ -8,8 +8,10 @@ export HOME="/home/${user}"
|
||||||
|
|
||||||
# If running user is not root, pivot to custom user/group
|
# If running user is not root, pivot to custom user/group
|
||||||
[ "$uid" != "0" ] && {
|
[ "$uid" != "0" ] && {
|
||||||
getent group "$gid" && groupdel "$gid"
|
getent group "$gid" \
|
||||||
getent passwd "$uid" && userdel "$uid"
|
&& groupdel "$(awk -v i="$gid" -F: '$3 == i' /etc/group | cut -d: -f1)"
|
||||||
|
getent passwd "$uid" \
|
||||||
|
&& userdel "$(awk -v i="$uid" -F: '$3 == i' /etc/passwd | cut -d: -f1)"
|
||||||
groupadd -g "$gid" "${user}"
|
groupadd -g "$gid" "${user}"
|
||||||
useradd \
|
useradd \
|
||||||
-g "$gid" \
|
-g "$gid" \
|
||||||
|
|
Loading…
Reference in New Issue