VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/Installer/x11restore.pl@ 96854

Last change on this file since 96854 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Revision Id
File size: 2.4 KB
Line 
1#!/usr/bin/perl -w
2# $Id: x11restore.pl 96407 2022-08-22 17:43:14Z vboxsync $
3## @file
4# Restore xorg.conf while removing Guest Additions.
5#
6
7#
8# Copyright (C) 2008-2022 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
30my $os_type=`uname -s`;
31my @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");
36my $CFG;
37my $BAK;
38
39my $config_count = 0;
40my $vboxpresent = "vboxvideo";
41
42foreach $cfg (@cfg_files)
43{
44 if (open(CFG, $cfg))
45 {
46 @array=<CFG>;
47 close(CFG);
48
49 foreach $line (@array)
50 {
51 if ($line =~ /$vboxpresent/)
52 {
53 if (open(BAK, $cfg.".bak"))
54 {
55 close(BAK);
56 rename $cfg.".bak", $cfg;
57 }
58 else
59 {
60 # On Solaris just delete existing conf if backup is not found (Possible on distros like Indiana)
61 if ($os_type =~ 'SunOS')
62 {
63 unlink $cfg
64 }
65 else
66 {
67 die "Failed to restore xorg.conf! Your existing config. still uses VirtualBox drivers!!";
68 }
69 }
70 }
71 }
72 $config_count++;
73 }
74}
75
76$config_count != 0 or die "Could not find backed-up xorg.conf to restore it.";
77
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette