Support user:group notation by sysusers.generate-pre.sh script

#Type Name       ID                  GECOS              Home directory Shell
u     user_name  uid:gid             "User Description" /home/dir      /path/to/shell

According to: https://www.freedesktop.org/software/systemd/man/sysusers.d.html
This commit is contained in:
Martin Osvald 2022-11-02 14:38:59 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent b3fa8789f9
commit 83301531c0

View File

@ -70,9 +70,12 @@ parse() {
eval "arr=( $line )"
case "${arr[0]}" in
('u')
group "${arr[1]}" "${arr[2]}"
user "${arr[1]}" "${arr[2]}" "${arr[3]}" "${arr[1]}" "${arr[4]}" "${arr[5]}"
# TODO: user:group support
if [[ "${arr[2]}" == *":"* ]]; then
user "${arr[1]}" "${arr[2]%:*}" "${arr[3]}" "${arr[2]#*:}" "${arr[4]}" "${arr[5]}"
else
group "${arr[1]}" "${arr[2]}"
user "${arr[1]}" "${arr[2]}" "${arr[3]}" "${arr[1]}" "${arr[4]}" "${arr[5]}"
fi
;;
('g')
group "${arr[1]}" "${arr[2]}"