1 | #!/usr/bin/perl -w
|
---|
2 | # $Revision: 8178 $
|
---|
3 | #
|
---|
4 | # Sun xVM VirtualBox
|
---|
5 | #
|
---|
6 | # Restore xorg.conf while removing Guest Additions.
|
---|
7 | #
|
---|
8 | # Copyright (C) 2008 Sun Microsystems, Inc.
|
---|
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 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
19 | # Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
20 | # additional information or have any questions.
|
---|
21 | #
|
---|
22 |
|
---|
23 |
|
---|
24 | my $os_type=`uname -s`;
|
---|
25 | my @cfg_files = ("/etc/X11/xorg.conf-4", "/etc/X11/xorg.conf", "/etc/X11/.xorg.conf", "/etc/xorg.conf",
|
---|
26 | "/usr/etc/X11/xorg.conf-4", "/usr/etc/X11/xorg.conf", "/usr/lib/X11/xorg.conf-4",
|
---|
27 | "/usr/lib/X11/xorg.conf", "/etc/X11/XF86Config-4", "/etc/X11/XF86Config",
|
---|
28 | "/etc/XF86Config", "/usr/X11R6/etc/X11/XF86Config-4", "/usr/X11R6/etc/X11/XF86Config",
|
---|
29 | "/usr/X11R6/lib/X11/XF86Config-4", "/usr/X11R6/lib/X11/XF86Config");
|
---|
30 | my $CFG;
|
---|
31 | my $BAK;
|
---|
32 |
|
---|
33 | my $config_count = 0;
|
---|
34 | my $vboxpresent = "vboxmouse";
|
---|
35 |
|
---|
36 | foreach $cfg (@cfg_files)
|
---|
37 | {
|
---|
38 | if (open(CFG, $cfg))
|
---|
39 | {
|
---|
40 | @array=<CFG>;
|
---|
41 | close(CFG);
|
---|
42 |
|
---|
43 | foreach $line (@array)
|
---|
44 | {
|
---|
45 | if ($line =~ /$vboxpresent/)
|
---|
46 | {
|
---|
47 | if (open(BAK, $cfg.".bak"))
|
---|
48 | {
|
---|
49 | close(BAK);
|
---|
50 | rename $cfg.".bak", $cfg;
|
---|
51 | }
|
---|
52 | else
|
---|
53 | {
|
---|
54 | # On Solaris just delete existing conf if backup is not found (Possible on distros like Indiana)
|
---|
55 | if ($os_type =~ 'SunOS')
|
---|
56 | {
|
---|
57 | unlink $cfg
|
---|
58 | }
|
---|
59 | else
|
---|
60 | {
|
---|
61 | die "Failed to restore xorg.conf! Your existing config. still uses VirtualBox drivers!!";
|
---|
62 | }
|
---|
63 | }
|
---|
64 | }
|
---|
65 | }
|
---|
66 | $config_count++;
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | $config_count != 0 or die "Could not find backed-up xorg.conf to restore it.";
|
---|
71 |
|
---|