xbps-triggers: system-accounts: simplify creation.
This commit is contained in:
parent
53655c45e8
commit
09007e019d
|
@ -85,30 +85,28 @@ run)
|
||||||
for acct in ${system_accounts}; do
|
for acct in ${system_accounts}; do
|
||||||
_uname="${acct%:*}"
|
_uname="${acct%:*}"
|
||||||
_uid="${acct#*:}"
|
_uid="${acct#*:}"
|
||||||
[ "${_uid}" != "${_uname}" ] && use_id="-r ${_uid}"
|
[ "${_uid}" != "${_uname}" ] && use_id="-u ${_uid} -g ${_uid}"
|
||||||
|
|
||||||
if [ ! -x "$USERADD" ]; then
|
if [ ! -x "$USERADD" ]; then
|
||||||
echo "WARNING: cannot create ${acct} system user/group (missing useradd)"
|
echo "WARNING: cannot create ${acct} system user/group (missing useradd)"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
eval homedir="\$${acct}_homedir"
|
eval homedir="\$${_uname}_homedir"
|
||||||
eval shell="\$${acct}_shell"
|
eval shell="\$${_uname}_shell"
|
||||||
eval descr="\$${acct}_descr"
|
eval descr="\$${_uname}_descr"
|
||||||
eval groups="\$${acct}_groups"
|
eval groups="\$${_uname}_groups"
|
||||||
[ -z "$homedir" ] && homedir="/"
|
[ -z "$homedir" ] && homedir="/"
|
||||||
[ -z "$shell" ] && shell="/sbin/nologin"
|
[ -z "$shell" ] && shell="/sbin/nologin"
|
||||||
[ -z "$descr" ] && descr="$acct unpriviledged user"
|
[ -z "$descr" ] && descr="${_uname} unpriviledged user"
|
||||||
[ -n "$groups" ] && user_groups="-G $groups"
|
[ -n "$groups" ] && user_groups="-G $groups"
|
||||||
|
|
||||||
group_add $acct
|
group_add ${acct}
|
||||||
|
|
||||||
if ! $GETENT passwd ${acct} >/dev/null; then
|
if ! $GETENT passwd ${_uname} >/dev/null; then
|
||||||
$USERADD -c "$descr" -d "$homedir" ${use_id} \
|
$USERADD -c "$descr" -d "$homedir" -s "$shell" ${user_groups} ${use_id:=-g ${_uname}} -r ${_uname} && \
|
||||||
-s "$shell" -g ${_uname} $user_groups \
|
$PASSWD -l ${_uname} >/dev/null 2>&1
|
||||||
-r ${_uname} && \
|
|
||||||
$PASSWD -l ${acct} >/dev/null 2>&1
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Created ${acct} system user."
|
echo "Created ${_uname} (${_uid}) system user."
|
||||||
else
|
else
|
||||||
echo "Failed to create ${acct} system user!"
|
echo "Failed to create ${acct} system user!"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -130,17 +128,19 @@ run)
|
||||||
fi
|
fi
|
||||||
$USERDEL ${_uname} >/dev/null 2>&1
|
$USERDEL ${_uname} >/dev/null 2>&1
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Removed ${acct} system user/group."
|
echo "Removed ${_uname} (${_uid}) system user/group."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
for grp in ${system_groups}; do
|
for grp in ${system_groups}; do
|
||||||
|
_uname="${acct%:*}"
|
||||||
|
_uid="${acct#*:}"
|
||||||
if [ ! -x "$GROUPDEL" ]; then
|
if [ ! -x "$GROUPDEL" ]; then
|
||||||
echo "WARNING: cannot remove ${acct} system group (missing groupdel)"
|
echo "WARNING: cannot remove ${acct} system group (missing groupdel)"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
$GROUPDEL ${grp} >/dev/null 2>&1
|
$GROUPDEL ${_uname} >/dev/null 2>&1
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Removed ${grp} system group."
|
echo "Removed ${_uname} (${_uid}) system group."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Template file for 'xbps-triggers'
|
# Template file for 'xbps-triggers'
|
||||||
pkgname=xbps-triggers
|
pkgname=xbps-triggers
|
||||||
version=0.81
|
version=0.83
|
||||||
revision=1
|
revision=1
|
||||||
noarch=yes
|
noarch=yes
|
||||||
bootstrap=yes
|
bootstrap=yes
|
||||||
|
|
Loading…
Reference in New Issue