1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # VirtualBox Guest Additions installation script for Linux
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2009-2010 Oracle Corporation
|
---|
8 | #
|
---|
9 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | # available from http://www.virtualbox.org. This file is free software;
|
---|
11 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | # General Public License (GPL) as published by the Free Software
|
---|
13 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | #
|
---|
17 |
|
---|
18 | PATH=$PATH:/bin:/sbin:/usr/sbin
|
---|
19 |
|
---|
20 | ostype=`uname -s`
|
---|
21 | if test "$ostype" != "Linux" && test "$ostype" != "SunOS" ; then
|
---|
22 | echo "Linux/Solaris not detected."
|
---|
23 | exit 1
|
---|
24 | fi
|
---|
25 |
|
---|
26 | # 32-bit or 64-bit?
|
---|
27 | path=`dirname $0`
|
---|
28 | case `uname -m` in
|
---|
29 | i[3456789]86|x86|i86pc)
|
---|
30 | arch='x86'
|
---|
31 | ;;
|
---|
32 | x86_64|amd64|AMD64)
|
---|
33 | arch='amd64'
|
---|
34 | ;;
|
---|
35 | *)
|
---|
36 | echo "Unknown architecture `uname -m`."
|
---|
37 | exit 1
|
---|
38 | ;;
|
---|
39 | esac
|
---|
40 |
|
---|
41 | # execute the installer
|
---|
42 | if test "$ostype" = "Linux"; then
|
---|
43 | for i in "$path/VBoxLinuxAdditions.run" \
|
---|
44 | "$path/VBoxLinuxAdditions-$arch.run"; do
|
---|
45 | if test -f "$i"; then
|
---|
46 | exec /bin/sh "$path/runasroot.sh" \
|
---|
47 | "VirtualBox Guest Additions installation" "$i" \
|
---|
48 | "Please try running $i manually."
|
---|
49 | fi
|
---|
50 | done
|
---|
51 |
|
---|
52 | # else: unknown failure
|
---|
53 | echo "Linux guest additions installer not found -- try to start them manually."
|
---|
54 | exit 1
|
---|
55 |
|
---|
56 | elif test "$ostype" = "SunOS"; then
|
---|
57 |
|
---|
58 | # check for combined package
|
---|
59 | installfile="$path/VBoxSolarisAdditions.pkg"
|
---|
60 | if test -f "$installfile"; then
|
---|
61 |
|
---|
62 | # check for pkgadd bin
|
---|
63 | pkgaddbin=pkgadd
|
---|
64 | found=`which pkgadd | grep "no pkgadd"`
|
---|
65 | if test ! -z "$found"; then
|
---|
66 | if test -f "/usr/sbin/pkgadd"; then
|
---|
67 | pkgaddbin=/usr/sbin/pkgadd
|
---|
68 | else
|
---|
69 | echo "Could not find pkgadd."
|
---|
70 | exit 1
|
---|
71 | fi
|
---|
72 | fi
|
---|
73 |
|
---|
74 | # check for pfexec
|
---|
75 | pfexecbin=pfexec
|
---|
76 | found=`which pfexec | grep "no pfexec"`
|
---|
77 | if test ! -z "$found"; then
|
---|
78 | # Use su and prompt for password
|
---|
79 | echo "Could not find pfexec."
|
---|
80 | subin=`which su`
|
---|
81 | else
|
---|
82 | idbin=/usr/xpg4/bin/id
|
---|
83 | if test ! -x "$idbin"; then
|
---|
84 | found=`which id 2> /dev/null`
|
---|
85 | if test ! -x "$found"; then
|
---|
86 | echo "Failed to find a suitable user id executable."
|
---|
87 | exit 1
|
---|
88 | else
|
---|
89 | idbin=$found
|
---|
90 | fi
|
---|
91 | fi
|
---|
92 |
|
---|
93 | # check if pfexec can get the job done
|
---|
94 | if test "$idbin" = "/usr/xpg4/bin/id"; then
|
---|
95 | userid=`$pfexecbin $idbin -u`
|
---|
96 | else
|
---|
97 | userid=`$pfexecbin $idbin | cut -f1 -d'(' | cut -f2 -d'='`
|
---|
98 | fi
|
---|
99 | if test $userid != "0"; then
|
---|
100 | # pfexec exists but user has no pfexec privileges, switch to using su and prompting password
|
---|
101 | subin=`which su`
|
---|
102 | fi
|
---|
103 | fi
|
---|
104 |
|
---|
105 | # create temporary admin file for autoinstall
|
---|
106 | echo "basedir=default
|
---|
107 | runlevel=nocheck
|
---|
108 | conflict=quit
|
---|
109 | setuid=nocheck
|
---|
110 | action=nocheck
|
---|
111 | partial=quit
|
---|
112 | instance=unique
|
---|
113 | idepend=quit
|
---|
114 | rdepend=quit
|
---|
115 | space=quit
|
---|
116 | mail=
|
---|
117 | " > /tmp/vbox.autoinstall
|
---|
118 |
|
---|
119 | # check gnome-terminal, use it if it exists.
|
---|
120 | if test -f "/usr/bin/gnome-terminal"; then
|
---|
121 | # use su/pfexec
|
---|
122 | if test -z "$subin"; then
|
---|
123 | /usr/bin/gnome-terminal --title "Installing VirtualBox Additions" --command "/bin/sh -c '$pfexecbin $pkgaddbin -G -d $installfile -n -a /tmp/vbox.autoinstall SUNWvboxguest; /bin/echo press ENTER to close this window; /bin/read; /bin/rm -f /tmp/vbox.autoinstall'"
|
---|
124 | else
|
---|
125 | /usr/bin/gnome-terminal --title "Installing VirtualBox Additions: Root password required." --command "/bin/sh -c '$subin - root -c \"$pkgaddbin -G -d $installfile -n -a /tmp/vbox.autoinstall SUNWvboxguest\"; /bin/echo press ENTER to close this window; /bin/read; /bin/rm -f /tmp/vbox.autoinstall'"
|
---|
126 | fi
|
---|
127 | elif test -f "/usr/X11/bin/xterm"; then
|
---|
128 | # use xterm
|
---|
129 | if test -z "$subin"; then
|
---|
130 | /usr/X11/bin/xterm -title "Installing VirtualBox Additions" -e "$pfexecbin $pkgaddbin -G -d $installfile -n -a /tmp/vbox.autoinstall SUNWvboxguest; /bin/echo press ENTER to close this window; /bin/read; /bin/rm -f /tmp/vbox.autoinstall"
|
---|
131 | else
|
---|
132 | /usr/X11/bin/xterm -title "Installing VirtualBox Additions: Root password required." -e "$subin - root -c \"$pkgaddbin -G -d $installfile -n -a /tmp/vbox.autoinstall SUNWvboxguest\"; /bin/echo press ENTER to close this window; /bin/read; /bin/rm -f /tmp/vbox.autoinstall"
|
---|
133 | fi
|
---|
134 | else
|
---|
135 | echo "No suitable terminal not found. -- install additions using pkgadd -d."
|
---|
136 | rm -f /tmp/vbox.autoinstall
|
---|
137 | fi
|
---|
138 |
|
---|
139 | exit 0
|
---|
140 | fi
|
---|
141 |
|
---|
142 | echo "Solaris guest additions installer not found -- try to start them manually."
|
---|
143 | exit 1
|
---|
144 | fi
|
---|
145 |
|
---|