#!/bin/bash

#
# uninstall.sh
#
# This file is part of webCDwriter - Network CD Writing.
#
# Copyright (C) 2003 Jörg P. M. Haeger
#
# webCDwriter is free software. See CDWserver.cpp for details.
#

echo
echo "webCDwriter Uninstaller"
echo "Warning: Use it at your own risk!"
echo

if [ ! "`id -u`" = "0" ]; then
	echo "You need to be root to remove webCDwriter!"
	echo
	exit 1
fi

echo "Do you really want to remove webCDwriter? (yes or no)"
read input
if [ ! "$input" = "yes" ]; then
	echo "Installation cancelled!"
	exit 1
fi

rpm -e webCDwriter 2> /dev/null || :

# remove directory trees
rm -rfv \
	/etc/CDWserver/ \
	/home/CDWserver/ \
	/var/log/CDWserver/ \
	/var/spool/CDWserver/

# remove single files
rm -fv \
	/etc/init.d/CDWserver \
	/usr/bin/cdrdao-dummy \
	/usr/bin/cdrecord-dummy \
	/usr/bin/dvd+rw-format-dummy \
	/usr/bin/files2cd \
	/usr/bin/growisofs-dummy \
	/usr/bin/rcdrecord \
	/usr/bin/setScheduler \
	/usr/sbin/CDWserver

# reset user/group and access bits of cdrecord and mkisofs
rpm --setugids cdrecord mkisofs 2> /dev/null || :
rpm --setperms cdrecord mkisofs 2> /dev/null || :
