xbps-triggers: system-accounts: simplify creation.

This commit is contained in:
Juan RP 2014-07-30 12:08:01 +02:00
parent 53655c45e8
commit 09007e019d
2 changed files with 17 additions and 17 deletions

View File

@ -85,30 +85,28 @@ run)
for acct in ${system_accounts}; do
_uname="${acct%:*}"
_uid="${acct#*:}"
[ "${_uid}" != "${_uname}" ] && use_id="-r ${_uid}"
[ "${_uid}" != "${_uname}" ] && use_id="-u ${_uid} -g ${_uid}"
if [ ! -x "$USERADD" ]; then
echo "WARNING: cannot create ${acct} system user/group (missing useradd)"
continue
fi
eval homedir="\$${acct}_homedir"
eval shell="\$${acct}_shell"
eval descr="\$${acct}_descr"
eval groups="\$${acct}_groups"
eval homedir="\$${_uname}_homedir"
eval shell="\$${_uname}_shell"
eval descr="\$${_uname}_descr"
eval groups="\$${_uname}_groups"
[ -z "$homedir" ] && homedir="/"
[ -z "$shell" ] && shell="/sbin/nologin"
[ -z "$descr" ] && descr="$acct unpriviledged user"
[ -z "$descr" ] && descr="${_uname} unpriviledged user"
[ -n "$groups" ] && user_groups="-G $groups"
group_add $acct
group_add ${acct}
if ! $GETENT passwd ${acct} >/dev/null; then
$USERADD -c "$descr" -d "$homedir" ${use_id} \
-s "$shell" -g ${_uname} $user_groups \
-r ${_uname} && \
$PASSWD -l ${acct} >/dev/null 2>&1
if ! $GETENT passwd ${_uname} >/dev/null; then
$USERADD -c "$descr" -d "$homedir" -s "$shell" ${user_groups} ${use_id:=-g ${_uname}} -r ${_uname} && \
$PASSWD -l ${_uname} >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Created ${acct} system user."
echo "Created ${_uname} (${_uid}) system user."
else
echo "Failed to create ${acct} system user!"
exit 1
@ -130,17 +128,19 @@ run)
fi
$USERDEL ${_uname} >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Removed ${acct} system user/group."
echo "Removed ${_uname} (${_uid}) system user/group."
fi
done
for grp in ${system_groups}; do
_uname="${acct%:*}"
_uid="${acct#*:}"
if [ ! -x "$GROUPDEL" ]; then
echo "WARNING: cannot remove ${acct} system group (missing groupdel)"
continue
fi
$GROUPDEL ${grp} >/dev/null 2>&1
$GROUPDEL ${_uname} >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Removed ${grp} system group."
echo "Removed ${_uname} (${_uid}) system group."
fi
done
fi

View File

@ -1,6 +1,6 @@
# Template file for 'xbps-triggers'
pkgname=xbps-triggers
version=0.81
version=0.83
revision=1
noarch=yes
bootstrap=yes