unelvin.pl 2.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2007 University of Utah and the Flux Group.
# All rights reserved.
#

use English;

#
# Remove all traces of elvin from a client
#
13 14 15 16 17
my @BSDPKGS = (
    'elvind-4.0.3',
    'libelvin-4.0.3_2'
);

18 19 20
my @BSDFILES = (
    '/usr/local/etc/rc.d/elvind.sh',
    '/usr/local/bin/elvin-config',
21 22
    '/usr/local/bin/ep',
    '/usr/local/bin/ec',
23 24 25 26 27 28
    '/usr/local/etc/elvind*',
    '/usr/local/include/elvin',
    '/usr/local/info/elvin*',
    '/usr/local/lib/libvin4*',
    '/usr/local/lib/nls/msg/elvin*',
    '/usr/local/man/man*/elvin*',
29 30 31
    '/usr/local/man/man1/ec.1',
    '/usr/local/man/man1/ep.1',
    '/usr/local/man/man8/epf.8',
32
    '/usr/local/libexec/elvind',
33
    '/usr/local/libexec/epf',
34 35 36 37 38 39
    '/var/log/elvind.log'
);

my @LINUXFILES = (
    '/etc/rc.d/*/*elvin',
    '/usr/local/bin/elvin-config',
40 41
    '/usr/local/bin/ep',
    '/usr/local/bin/ec',
42 43 44 45 46 47
    '/usr/local/etc/elvind*',
    '/usr/local/include/elvin',
    '/usr/local/info/elvin*',
    '/usr/local/lib/libvin4*',
    '/usr/local/lib/nls/msg/elvin*',
    '/usr/local/man/man*/elvin*',
48 49 50 51 52
    '/usr/local/man/man1/ec.1',
    '/usr/local/man/man1/ep.1',
    '/usr/local/man/man8/epf.8',
    '/usr/local/sbin/elvind',
    '/usr/local/sbin/epf'
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
);

if ($UID ne 0) {
    print STDERR "You will want to be doing this as root ya know!\n";
    exit(1);
}

my $isbsd = 0;
if (-e "/usr/sbin/pkg_delete") {
    $isbsd = 1;
}

print "Bye, bye elvin...\n";
if ($isbsd) {
    # disable elvind logging in syslog.conf
    system("sed -i '' -e '/elvind/d' /etc/syslog.conf");

    # remove any packages?
71 72 73 74 75 76
    foreach my $pkg (@BSDPKGS) {
	if (!system("pkg_info -e $pkg")) {
	    print "removing $pkg package...\n";
	    system("pkg_delete -f $pkg");
	}
    }
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

    # remove known files
    my @list = `ls -d @BSDFILES 2>/dev/null`;
    print "removing: @list\n";
    chomp(@list);
    my $lstr = join(' ', @list);
    system("rm -rf $lstr");
    @list = `ls -d @BSDFILES 2>/dev/null`;
    print "what's left: @list\n";
} else {
    # remove any rpms?

    my @list = `ls -d @LINUXFILES 2>/dev/null`;
    print "removing: @list\n";
    chomp(@list);
    my $lstr = join(' ', @list);
    system("rm -rf $lstr");
    @list = `ls -d @LINUXFILES 2>/dev/null`;
    print "what's left: @list\n";
}

print "Elvin has left the building (you KNEW that was coming!)\n";
exit 0;