1 | #!/usr/bin/perl -w
|
---|
2 | #
|
---|
3 | # innotek VirtualBox
|
---|
4 | # Start the Guest Additions X11 Client
|
---|
5 | #
|
---|
6 | # Restore xorg.conf while removing Guest Additions.
|
---|
7 | #
|
---|
8 | # Copyright (C) 2008 innotek GmbH
|
---|
9 | #
|
---|
10 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | # available from http://www.virtualbox.org. This file is free software;
|
---|
12 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | # General Public License (GPL) as published by the Free Software
|
---|
14 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | #
|
---|
18 |
|
---|
19 |
|
---|
20 | my $os_type=`uname -s`;
|
---|
21 | my @cfg_files = ("/etc/X11/xorg.conf-4", "/etc/X11/xorg.conf", "/etc/X11/.xorg.conf", "/etc/xorg.conf",
|
---|
22 | "/usr/etc/X11/xorg.conf-4", "/usr/etc/X11/xorg.conf", "/usr/lib/X11/xorg.conf-4",
|
---|
23 | "/usr/lib/X11/xorg.conf", "/etc/X11/XF86Config-4", "/etc/X11/XF86Config",
|
---|
24 | "/etc/XF86Config", "/usr/X11R6/etc/X11/XF86Config-4", "/usr/X11R6/etc/X11/XF86Config",
|
---|
25 | "/usr/X11R6/lib/X11/XF86Config-4", "/usr/X11R6/lib/X11/XF86Config");
|
---|
26 | my $CFG;
|
---|
27 | my $BAK;
|
---|
28 |
|
---|
29 | my $config_count = 0;
|
---|
30 | my $vboxpresent = "vboxmouse";
|
---|
31 |
|
---|
32 | foreach $cfg (@cfg_files)
|
---|
33 | {
|
---|
34 | if (open(CFG, $cfg))
|
---|
35 | {
|
---|
36 | @array=<CFG>;
|
---|
37 | close(CFG);
|
---|
38 |
|
---|
39 | foreach $line (@array)
|
---|
40 | {
|
---|
41 | if ($line =~ /$vboxpresent/)
|
---|
42 | {
|
---|
43 | if (open(BAK, $cfg.".bak"))
|
---|
44 | {
|
---|
45 | close(BAK);
|
---|
46 | rename $cfg.".bak", $cfg;
|
---|
47 | }
|
---|
48 | else
|
---|
49 | {
|
---|
50 | # On Solaris just delete existing conf if backup is not found (Possible on distros like Indiana)
|
---|
51 | if ($os_type =~ 'SunOS')
|
---|
52 | {
|
---|
53 | rename $cfg, $cfg.".delete_this";
|
---|
54 | }
|
---|
55 | else
|
---|
56 | {
|
---|
57 | die "Failed to restore xorg.conf! Your existing config. still uses VirtualBox drivers!!";
|
---|
58 | }
|
---|
59 | }
|
---|
60 | }
|
---|
61 | }
|
---|
62 | $config_count++;
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | $config_count != 0 or die "Could not find backed-up xorg.conf to restore it.";
|
---|
67 |
|
---|