xbps-triggers: system-accounts: fail gracefully if required utils are not available.

This commit is contained in:
Juan RP 2013-04-06 14:54:21 +02:00
parent 7fef623e3b
commit 1cfc05cef3
2 changed files with 19 additions and 3 deletions

View file

@ -38,9 +38,9 @@ group_add() {
$GROUPADD -r ${_grname} >/dev/null 2>&1
fi
if [ $? -eq 0 ]; then
echo "Created ${grp} ($use_gid) system group."
echo "Created ${_grname} ($use_gid) system group."
else
echo "Failed to create ${grp} ($use_gid) system group!"
echo "Failed to create ${_grname} ($use_gid) system group!"
exit 1
fi
fi
@ -74,11 +74,19 @@ run)
post-install)
# System groups required by a package.
for grp in ${system_groups}; do
if [ ! -x "$GROUPADD" ]; then
echo "WARNING: cannot create ${grp} system group (missing groupadd)"
continue
fi
group_add $grp
done
# System user/group required by a package.
for acct in ${system_accounts}; do
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"
@ -110,12 +118,20 @@ run)
#
if [ "$UPDATE" = "no" ]; then
for acct in ${system_accounts}; do
if [ ! -x "$USERDEL" ]; then
echo "WARNING: cannot remove ${acct} system user/group (missing userdel)"
continue
fi
$USERDEL ${acct} >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Removed ${acct} system user/group."
fi
done
for grp in ${system_groups}; do
if [ ! -x "$GROUPDEL" ]; then
echo "WARNING: cannot remove ${acct} system group (missing groupdel)"
continue
fi
$GROUPDEL ${grp} >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Removed ${grp} system group."

View file

@ -1,6 +1,6 @@
# Template file for 'xbps-triggers'
pkgname=xbps-triggers
version=0.65
version=0.66
revision=1
short_desc="The XBPS triggers for Void Linux"
maintainer="Juan RP <xtraeme@gmail.com>"