1 | #!/usr/bin/perl -w
|
---|
2 | # $Id: x11restore.pl 106061 2024-09-16 14:03:52Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # Restore xorg.conf while removing Guest Additions.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2008-2024 Oracle and/or its affiliates.
|
---|
9 | #
|
---|
10 | # This file is part of VirtualBox base platform packages, as
|
---|
11 | # available from https://www.virtualbox.org.
|
---|
12 | #
|
---|
13 | # This program is free software; you can redistribute it and/or
|
---|
14 | # modify it under the terms of the GNU General Public License
|
---|
15 | # as published by the Free Software Foundation, in version 3 of the
|
---|
16 | # License.
|
---|
17 | #
|
---|
18 | # This program is distributed in the hope that it will be useful, but
|
---|
19 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
21 | # General Public License for more details.
|
---|
22 | #
|
---|
23 | # You should have received a copy of the GNU General Public License
|
---|
24 | # along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
25 | #
|
---|
26 | # SPDX-License-Identifier: GPL-3.0-only
|
---|
27 | #
|
---|
28 |
|
---|
29 |
|
---|
30 | my $os_type=`uname -s`;
|
---|
31 | my @cfg_files = ("/etc/X11/xorg.conf-4", "/etc/X11/xorg.conf", "/etc/X11/.xorg.conf", "/etc/xorg.conf",
|
---|
32 | "/usr/etc/X11/xorg.conf-4", "/usr/etc/X11/xorg.conf", "/usr/lib/X11/xorg.conf-4",
|
---|
33 | "/usr/lib/X11/xorg.conf", "/etc/X11/XF86Config-4", "/etc/X11/XF86Config",
|
---|
34 | "/etc/XF86Config", "/usr/X11R6/etc/X11/XF86Config-4", "/usr/X11R6/etc/X11/XF86Config",
|
---|
35 | "/usr/X11R6/lib/X11/XF86Config-4", "/usr/X11R6/lib/X11/XF86Config");
|
---|
36 | my $CFG;
|
---|
37 | my $BAK;
|
---|
38 |
|
---|
39 | my $config_count = 0;
|
---|
40 | my $vboxpresent = "vboxvideo";
|
---|
41 |
|
---|
42 | foreach $cfg (@cfg_files)
|
---|
43 | {
|
---|
44 | if (($os_type =~ 'SunOS') && (defined $ENV{PKG_INSTALL_ROOT}))
|
---|
45 | {
|
---|
46 | $cfg = $ENV{PKG_INSTALL_ROOT}.$cfg;
|
---|
47 | }
|
---|
48 | if (open(CFG, $cfg))
|
---|
49 | {
|
---|
50 | @array=<CFG>;
|
---|
51 | close(CFG);
|
---|
52 |
|
---|
53 | foreach $line (@array)
|
---|
54 | {
|
---|
55 | if ($line =~ /$vboxpresent/)
|
---|
56 | {
|
---|
57 | if (open(BAK, $cfg.".bak"))
|
---|
58 | {
|
---|
59 | close(BAK);
|
---|
60 | print("Restoring $cfg.back to $cfg.\n");
|
---|
61 | rename $cfg.".bak", $cfg;
|
---|
62 | }
|
---|
63 | else
|
---|
64 | {
|
---|
65 | # On Solaris just delete existing conf if backup is not found (Possible on distros like Indiana)
|
---|
66 | if ($os_type =~ 'SunOS')
|
---|
67 | {
|
---|
68 | unlink $cfg
|
---|
69 | }
|
---|
70 | else
|
---|
71 | {
|
---|
72 | die "Failed to restore xorg.conf! Your existing config. still uses VirtualBox drivers!!";
|
---|
73 | }
|
---|
74 | }
|
---|
75 | }
|
---|
76 | }
|
---|
77 | $config_count++;
|
---|
78 | }
|
---|
79 | }
|
---|