#!/bin/bash
#
# This file is part of vbackup.
#
# vbackup 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 3 of the License, or
# (at your option) any later version.
#
# vbackup 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 vbackup  If not, see <http://www.gnu.org/licenses/>.
#
# $Id$
#
# Description
#
#	Delete a directory recursively
#

NAME="rm"
VERSION="$PACKAGE_VERSION"
DESC="Remove a directory recursively"
LICENSE="$PACKAGE_LICENSE"
COPYRIGHT="$PACKAGE_COPYRIGHT"
CONTACT="$PACKAGE_BUGREPORT"

# Display help
do_help()
{
	cat << _END
A script to remove a directory. It can be used after copying a backup
to a remote host.

Configuration options:
	DIR		The directory to remove. Relative to DESTDIR0
_END
}

# Check configuration
# return: 0: ok, 1: error
do_check_conf()
{
	[ -z "$DIR" ] && h_error "Missing DIR" && return 1

	return 0
}

# Do backup
do_run()
{
	if [ "x$ABORT" = "x1" ] ; then
		return 0
	fi

	# Transform this and construct $DST
	h_transform "$DIR"
	DST="$DESTDIR0/$R"

	if [ -e "$DST" ] ; then
		h_msg 7 "Removing $DST"
		rm -rf "$DST"
	else
		h_msg 6 "Not found: $DST. Nothing to delete"
	fi

	return 0
}

