unelvin.pl 2.99 KB
Newer Older
1 2 3
#!/usr/bin/perl -w
#
# Copyright (c) 2007 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file 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 Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
23 24 25 26 27 28 29
#

use English;

#
# Remove all traces of elvin from a client
#
30 31 32 33 34
my @BSDPKGS = (
    'elvind-4.0.3',
    'libelvin-4.0.3_2'
);

35 36 37
my @BSDFILES = (
    '/usr/local/etc/rc.d/elvind.sh',
    '/usr/local/bin/elvin-config',
38 39
    '/usr/local/bin/ep',
    '/usr/local/bin/ec',
40 41 42 43 44 45
    '/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*',
46 47 48
    '/usr/local/man/man1/ec.1',
    '/usr/local/man/man1/ep.1',
    '/usr/local/man/man8/epf.8',
49
    '/usr/local/libexec/elvind',
50
    '/usr/local/libexec/epf',
51 52 53 54 55 56
    '/var/log/elvind.log'
);

my @LINUXFILES = (
    '/etc/rc.d/*/*elvin',
    '/usr/local/bin/elvin-config',
57 58
    '/usr/local/bin/ep',
    '/usr/local/bin/ec',
59 60 61 62 63 64
    '/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*',
65 66 67 68 69
    '/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'
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
);

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?
88 89 90 91 92 93
    foreach my $pkg (@BSDPKGS) {
	if (!system("pkg_info -e $pkg")) {
	    print "removing $pkg package...\n";
	    system("pkg_delete -f $pkg");
	}
    }
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116

    # 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;