Bash – How to check whether the pptpd package is installed and remove it

bashshell

I need to check whether the RPM package pptpd is installed, ignoring the version.
If it is I want to remove it. If not then check whether /etc/pptpd.conf and /etc/ppp/ exist. If yes for any or both then rm -rf.

Best Answer

rpm -q pptpd
if [ $? = 0 ]
then
echo "pptpd installed.. removing"
rpm -e pptp
elif [ -e "/etc/pptpd.conf" ]
then 
rm -rf /etc/pptpd.conf
fi

But I wonder if you need it removed checking for the existence package/file is needed ?