Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
55 lines (42 sloc) 1.21 KB
#!/bin/sh
#
# $Id: postuninstall,v 1.6 2009-03-09 13:59:40 ghantoos Exp $
#
# RPM build postuninstall script
# Check if rpm is being _removed_ (as opposed to _upgraded_)
# if deletion process, then proceed, else, exit 0
# source: http://www.ibm.com/developerworks/library/l-rpm3.html
if [ "$1" != "0" ] ; then
if [ -f "/etc/lshell.conf" ]; then
cp /etc/lshell.conf /etc/lshell.conf-preinstall
fi
exit 0
fi
#groupdel lshellg
rm -f /etc/lshell.conf-rpm
#####
# This part is taken from debian remove-shell(8) script
#####
lshell=/usr/bin/lshell
file=/etc/shells
# I want this to be GUARANTEED to be on the same filesystem as $file
tmpfile=${file}.tmp
otmpfile=${file}.tmp2
set -o noclobber
trap "rm -f ${tmpfile} ${otmpfile}" EXIT
if ! cat ${file} > ${tmpfile}
then
cat 1>&2 <<EOF
Either another instance of $0 is running, or it was previously interrupted.
Please examine ${tmpfile} to see if it should be moved onto ${file}.
EOF
exit 1
fi
# this is supposed to be reliable, not pretty
grep -v "^${lshell}$" ${tmpfile} > ${otmpfile} || true
mv ${otmpfile} ${tmpfile}
chmod --reference=${file} ${tmpfile}
chown --reference=${file} ${tmpfile}
mv ${tmpfile} ${file}
trap "" EXIT
exit 0
Jump to Line
Something went wrong with that request. Please try again.