]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-user_group.sh
- user/group deletion script
[packages/rpm.git] / rpm-user_group.sh
1 #!/bin/sh
2
3 [ -f /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm
4 [ -z "$RPM_SCRIPTVERBOSITY" ] && RPM_SCRIPTVERBOSITY=5
5
6 if [ "$1" = user -o "$1" = group ]; then
7         MODE=$1
8 else
9         echo ERROR
10         exit 2
11 fi
12 shift
13
14 testrm()
15 {
16         [ "$RPM_USERDEL" != yes ] && return 1
17         [ -z "$1" ] && return 2
18         rpm -q --whatprovides "${MODE}($1)" >/dev/null 2>&1
19         # no package Provides it (strange)
20         [ $? -ne 0 ] && return 0
21         # only current package Provides it
22         [ `rpm -q --whatprovides "${MODE}($1)" | wc -l` -lt 2 ] && return 0
23         return 1
24 }
25
26 if [ "$1" = "testrm" ]; then
27         testrm $2
28         exit $?
29 elif [ "$1" = del ]; then
30         if testrm $2; then
31                 [ "$RPM_SCRIPTVERBOSITY" -lt 2 ] || echo "Removing $MODE $2"
32                 /usr/sbin/${MODE}del $2 || :
33         fi
34 else
35         echo ERROR
36         exit 2
37 fi
This page took 0.03046 seconds and 4 git commands to generate.