1 | #!/bin/sh
|
---|
2 | # $Id: preremove.sh 98103 2023-01-17 14:15:46Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # VirtualBox preremove script for Solaris Guest Additions.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2008-2023 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 | # The contents of this file may alternatively be used under the terms
|
---|
27 | # of the Common Development and Distribution License Version 1.0
|
---|
28 | # (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
29 | # in the VirtualBox distribution, in which case the provisions of the
|
---|
30 | # CDDL are applicable instead of those of the GPL.
|
---|
31 | #
|
---|
32 | # You may elect to license modified versions of this file under the
|
---|
33 | # terms and conditions of either the GPL or the CDDL or both.
|
---|
34 | #
|
---|
35 | # SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
36 | #
|
---|
37 |
|
---|
38 | LC_ALL=C
|
---|
39 | export LC_ALL
|
---|
40 |
|
---|
41 | LANG=C
|
---|
42 | export LANG
|
---|
43 |
|
---|
44 | echo "Removing VirtualBox service..."
|
---|
45 |
|
---|
46 | # stop and unregister VBoxService
|
---|
47 | /usr/sbin/svcadm disable -s virtualbox/vboxservice
|
---|
48 | # Don't need to delete, taken care of by the manifest action
|
---|
49 | # /usr/sbin/svccfg delete svc:/application/virtualbox/vboxservice:default
|
---|
50 | /usr/sbin/svcadm restart svc:/system/manifest-import:default
|
---|
51 |
|
---|
52 | # stop VBoxClient
|
---|
53 | pkill -INT VBoxClient
|
---|
54 |
|
---|
55 | echo "Removing VirtualBox kernel modules..."
|
---|
56 |
|
---|
57 | # vboxguest.sh would've been installed, we just need to call it.
|
---|
58 | /opt/VirtualBoxAdditions/vboxguest.sh stopall silentunload
|
---|
59 |
|
---|
60 | # Figure out group to use for /etc/devlink.tab (before Solaris 11 SRU6
|
---|
61 | # it was always using group sys)
|
---|
62 | group=sys
|
---|
63 | if [ -f /etc/dev/reserved_devnames ]; then
|
---|
64 | # Solaris 11 SRU6 and later use group root (check a file which isn't
|
---|
65 | # tainted by VirtualBox install scripts and allow no other group)
|
---|
66 | refgroup=`LC_ALL=C /usr/bin/ls -lL /etc/dev/reserved_devnames | awk '{ print $4 }' 2>/dev/null`
|
---|
67 | if [ $? -eq 0 -a "x$refgroup" = "xroot" ]; then
|
---|
68 | group=root
|
---|
69 | fi
|
---|
70 | unset refgroup
|
---|
71 | fi
|
---|
72 |
|
---|
73 | # remove devlink.tab entry for vboxguest
|
---|
74 | sed -e '/name=vboxguest/d' /etc/devlink.tab > /etc/devlink.vbox
|
---|
75 | chmod 0644 /etc/devlink.vbox
|
---|
76 | chown root:$group /etc/devlink.vbox
|
---|
77 | mv -f /etc/devlink.vbox /etc/devlink.tab
|
---|
78 |
|
---|
79 | # remove the link
|
---|
80 | if test -h "/dev/vboxguest" || test -f "/dev/vboxguest"; then
|
---|
81 | rm -f /dev/vboxdrv
|
---|
82 | fi
|
---|
83 | if test -h "/dev/vboxms" || test -f "/dev/vboxms"; then
|
---|
84 | rm -f /dev/vboxms
|
---|
85 | fi
|
---|
86 |
|
---|
87 | # Try and restore xorg.conf!
|
---|
88 | echo "Restoring X.Org..."
|
---|
89 | /opt/VirtualBoxAdditions/x11restore.pl
|
---|
90 |
|
---|
91 |
|
---|
92 | echo "Done."
|
---|
93 |
|
---|