#!/usr/bin/perl

# CLEANUP SCRIPT
# Copyright (c) 1998-2002, DiscusWare, LLC, all rights reserved.
# This script may not be redistributed or used except as provided
# in the Discus license agreement.

opendir(DIR, ".");
my @dir = grep { /^ftpdiag\./ } readdir(DIR);
closedir(DIR);

if (scalar @dir == 0 && ! -e "./discus.conf" && ! -e "./install.txt") {
	print "Nothing to clean\n";
} else {
	print "Do you want to clean this distribution by removing the following files?\n";
	print "  - $dir[0]\n" if scalar @dir;
	print "  - discus.conf\n" if -e "./discus.conf";
	print "  - install.txt\n" if -e "./install.txt";
	print "\n";
	print "Your answer (y/n): ";
	my $yn = <STDIN>;
	if ($yn =~ /^y/i) {
		unlink $dir[0];
		unlink "./discus.conf";
		unlink "./install.txt";
		print "\n";
		print "Distribution was cleaned\n\n";
	} else {
		print "\n";
		print "Cleanup canceled by user\n\n";
	}
	print "Type 'perl upgrade.pl' to upgrade an existing board\n";
	print "Type 'perl 1st_install.pl' to install a new board\n";
}

