#!/bin/bash
############################################################################
#                                                                          #
# This file is part of the IPFire Firewall.                                #
#                                                                          #
# IPFire is free software; you can redistribute it and/or modify           #
# it under the terms of the GNU General Public License as published by     #
# the Free Software Foundation; either version 2 of the License, or        #
# (at your option) any later version.                                      #
#                                                                          #
# IPFire is distributed in the hope that it will be useful,                #
# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
# GNU General Public License for more details.                             #
#                                                                          #
# You should have received a copy of the GNU General Public License        #
# along with IPFire; if not, write to the Free Software                    #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
#                                                                          #
# Copyright (C) 2007 IPFire-Team <info@ipfire.org>.                        #
#                                                                          #
############################################################################
#
. /opt/pakfire/lib/functions.sh

# Check group
/usr/bin/getent group privoxy >/dev/null
if [ $? -ne 0 ]; then
	echo "The group 'privoxy' does not exist, it will be created now."
	echo
		/usr/sbin/groupadd privoxy
else
	echo "The group 'privoxy' already exists."
	echo
fi

# Check user
/usr/bin/getent passwd privoxy >/dev/null
if [ $? -ne 0 ]; then
	echo "The user 'privoxy' does not exist, it will be created now."
	echo
		/usr/sbin/useradd privoxy -g privoxy -d /tmp -m -s /bin/false
else
	echo "The user 'privoxy' already exists."
	echo
fi

extract_files

# To be sure, adjust ownerships again
/bin/chown -R privoxy:privoxy /etc/privoxy
/bin/chown -R privoxy:privoxy /var/log/privoxy
/bin/chmod 0644 /var/log/privoxy/logfile
/bin/chown nobody:nobody /var/ipfire/menu.d/EX-privoxy-log.menu
/bin/chown nobody:nobody /var/ipfire/menu.d/EX-privoxy-services.menu

# Show 'privoxy' under STATUS / SERVICES
/usr/bin/touch /opt/pakfire/db/installed/meta-privoxy

# Update language-cache
/usr/local/bin/update-lang-cache

restore_backup ${NAME}
