c35174b874
- Put helper script into own subpackage - Convert sysusers config file to shadow arguments and use shadow suite to create user and groups. Fixes [bsc#1041497] and serveral dependency loops. OBS-URL: https://build.opensuse.org/request/show/504523 OBS-URL: https://build.opensuse.org/package/show/Base:System/sysuser-tools?expand=0&rev=7
49 lines
1.3 KiB
Bash
49 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
while read LINE
|
|
do
|
|
case "$LINE" in
|
|
\#*|"")
|
|
;;
|
|
g*)
|
|
eval arr=( $LINE )
|
|
ARGUMENTS="${arr[1]}"
|
|
if [ ! -z "${arr[2]}" -a "${arr[2]}" != "-" ]; then
|
|
ARGUMENTS="-g ${arr[2]} $ARGUMENTS"
|
|
fi
|
|
echo "groupadd -r $ARGUMENTS"
|
|
/usr/bin/getent group "${arr[1]}" >> /dev/null || /usr/sbin/groupadd -r $ARGUMENTS
|
|
;;
|
|
u*)
|
|
eval arr=( $LINE )
|
|
ARGUMENTS="${arr[1]}"
|
|
if [ ! -z "${arr[2]}" -a "${arr[2]}" != "-" ]; then
|
|
ARGUMENTS="-u ${arr[2]} $ARGUMENTS"
|
|
fi
|
|
if [ ! -z "${arr[4]}" -a "${arr[4]}" != "-" ]; then
|
|
ARGUMENTS="-d ${arr[4]} $ARGUMENTS"
|
|
fi
|
|
/usr/bin/getent group ${arr[1]} >> /dev/null
|
|
if [ $? -eq 0 ]; then
|
|
ARGUMENTS="-g ${arr[1]} $ARGUMENTS"
|
|
else
|
|
ARGUMENTS="-U $ARGUMENTS"
|
|
fi
|
|
echo "useradd -r -s /sbin/nologin -c \"${arr[3]}\" $ARGUMENTS"
|
|
/usr/bin/getent passwd ${arr[1]} >> /dev/null || /usr/sbin/useradd -r -s /sbin/nologin -c "${arr[3]}" $ARGUMENTS
|
|
;;
|
|
m*)
|
|
eval arr=( $LINE )
|
|
echo "usermod -a -G ${arr[2]} ${arr[1]}"
|
|
/usr/sbin/usermod -a -G ${arr[2]} ${arr[1]}
|
|
;;
|
|
r*)
|
|
echo "range option ignored: \"$LINE\""
|
|
;;
|
|
*)
|
|
echo "Syntax Error: \"$LINE\""
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|