Sophie

Sophie

distrib > Scientific%20Linux > 5x > i386 > by-pkgid > af2ee5e371f127eb8476490842fc3a32 > scriptlet

privoxy-3.0.3-9.3.el5.i386.rpm

PREIN

/bin/sh
# This is where we handle old usernames (junkbust and junkbuster)
# I'm not sure we should do that, but this is the way we have been
# doing it for some time now -- morcego
# We should do it for the group as well -- morcego
# Doing it by brute force. Much cleaner (no more Mr. Nice Guy) -- morcego

# Same for username
usermod -u 73 -g 73 -l privoxy -d /etc/privoxy -s "/sbin/nologin" junkbuster > /dev/null 2>&1 || :
usermod -u 73 -g 73 -l privoxy -d /etc/privoxy -s "/sbin/nologin" junkbust > /dev/null 2>&1 || :
userdel junkbuster > /dev/null 2>&1 ||:
userdel junkbust > /dev/null 2>&1 ||:

# Change the group name. Remove anything left behind.
groupmod -g 73 -n privoxy junkbuster > /dev/null 2>&1 ||:
groupmod -g 73 -n privoxy junkbust > /dev/null 2>&1 ||:
groupdel junkbuster > /dev/null 2>&1 ||:
groupdel junkbust > /dev/null 2>&1 ||:

# Doublecheck to see if the group exist, and that it has the correct gid
/bin/grep -E '^privoxy:' /etc/group > /dev/null 2>&1
if [ $? -eq 1 ]; then
	# Looks like it does not exist. Create it
	groupadd -g 73 privoxy > /dev/null 2>&1
else
	/bin/grep -E '^privoxy:[^:]*:73:' /etc/group > /dev/null 2>&1
	if [ $? -eq 1 ]; then
		# The group exists, but does not have the correct gid
		groupmod -g 73 privoxy > /dev/null 2>&1
	fi
fi

# Check to see if everything is okey. Create user if it still does not
# exist
id privoxy > /dev/null 2>&1
if [ $? -eq 1 ]; then
	/usr/sbin/useradd -u 73 -g 73 -d /etc/privoxy -r -s "/sbin/nologin" privoxy > /dev/null 2>&1 
fi

# Double check that the group has the correct uid
P_UID=`id -u privoxy 2>/dev/null`
if [ $P_UID -ne 73 ]; then
	/usr/sbin/usermod -u 73 privoxy
fi

# The same for the gid
P_GID=`id -g privoxy 2>/dev/null`
if [ $P_GID -ne 73 ]; then
	/usr/sbin/usermod -g 73 privoxy
fi

PREUN

/bin/sh
/sbin/service junkbust stop > /dev/null 2>&1 ||:
/sbin/service junkbuster stop > /dev/null 2>&1 ||:

if [ "$1" = "0" ]; then
	/sbin/service privoxy stop > /dev/null 2>&1 ||:
	/sbin/chkconfig --del privoxy
fi

POSTIN

/bin/sh
# for upgrade from 2.0.x
[ -f /var/log/junkbuster/logfile ] && {
  mv -f /var/log/junkbuster/logfile /var/log/privoxy/logfile ||: ;
  chown -R privoxy:privoxy /var/log/privoxy 2>/dev/null ||: ;
}
[ -f /var/log/privoxy/privoxy ] && {
  mv -f /var/log/privoxy/privoxy /var/log/privoxy/logfile ||: ;
  chown -R privoxy:privoxy /etc/privoxy 2>/dev/null ||: ;
}
/sbin/chkconfig --add privoxy
if [ "$1" = "1" ]; then
	/sbin/service privoxy condrestart > /dev/null 2>&1 ||:
fi

POSTUN

/bin/sh
#if [ "$1" -ge "1" ]; then
#	/sbin/service privoxy condrestart > /dev/null 2>&1
#fi
# We only remove it we this is not an upgrade
if [ "$1" = "0" ]; then
	id privoxy > /dev/null 2>&1 && /usr/sbin/userdel privoxy || /bin/true
	/bin/grep -E '^privoxy:' /etc/group > /dev/null && /usr/sbin/groupdel privoxy || /bin/true
fi