-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathremove-aegis
More file actions
executable file
·55 lines (47 loc) · 1.06 KB
/
remove-aegis
File metadata and controls
executable file
·55 lines (47 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl
use strict;
use warnings;
sub main(@){
my @files = qw(
/home/user/.aegis
/home/user/.accounts
/home/user/.activesync
/etc/aegisfs.d/*.*
);
my $certsBak = "/root/certs.bak." . time;
print "backing up ssl certs and destroying aegis\n";
system "n9", "-s", "
set -x
rm -rf $certsBak
cp -ar /etc/ssl/certs $certsBak;
rm -rf @files
";
die "failed!\n" unless $? == 0;
print "rebooting..\n";
system "n9", "-s", "/sbin/reboot";
print "waiting for n9\n";
print "sleeping for 20\n";
sleep 20;
print "attempting ssh: ";
my $old_fh = select(STDOUT); $| = 1; select($old_fh);
my $hostname = `n9`;
chomp $hostname;
my $ok = 0;
while(not $ok){
print ".";
my $cmd = "ssh user\@$hostname"
. " -o ConnectTimeout=2"
. " echo -n hello 2>/dev/null"
;
$ok = 1 if `$cmd` eq "hello";
sleep 1 unless $ok;
}
print "\nok!\n";
print "restoring ssl certs\n";
system "n9", "-s", "
set -x
rm -rf /etc/ssl/certs
cp -ar $certsBak /etc/ssl/certs
";
}
&main(@ARGV);