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 | if test -f "$path/VBoxLinuxAdditions-$arch.run"; then
|
---|
44 | exec gksu /bin/sh "$path/VBoxLinuxAdditions-$arch.run"
|
---|
45 | fi
|
---|
46 |
|
---|
47 | # else: unknown failure
|
---|
48 | echo "Linux guest additions installer not found -- try to start them manually."
|
---|
49 | exit 1
|
---|
50 |
|
---|
51 | elif test "$ostype" = "SunOS"; then
|
---|
52 |
|
---|
53 | # check for combined package
|
---|
54 | installfile="$path/VBoxSolarisAdditions.pkg"
|
---|
55 | if test -f "$installfile"; then
|
---|
56 |
|
---|
57 | # check for pkgadd bin
|
---|
58 | pkgaddbin=pkgadd
|
---|
59 | found=`which pkgadd | grep "no pkgadd"`
|
---|
60 | if test ! -z "$found"; then
|
---|
61 | if test -f "/usr/sbin/pkgadd"; then
|
---|
62 | pkgaddbin=/usr/sbin/pkgadd
|
---|
63 | else
|
---|
64 | echo "Could not find pkgadd."
|
---|
65 | exit 1
|
---|
66 | fi
|
---|
67 | fi
|
---|
68 |
|
---|
69 | # check for pfexec
|
---|
70 | pfexecbin=pfexec
|
---|
71 | found=`which pfexec | grep "no pfexec"`
|
---|
72 | if test ! -z "$found"; then
|
---|
73 | # Use su and prompt for password
|
---|
74 | echo "Could not find pfexec."
|
---|
75 | subin=`which su`
|
---|
76 | else
|
---|
77 | idbin=/usr/xpg4/bin/id
|
---|
78 | if test ! -x "$idbin"; then
|
---|
79 | found=`which id 2> /dev/null`
|
---|
80 | if test ! -x "$found"; then
|
---|
81 | echo "Failed to find a suitable user id executable."
|
---|
82 | exit 1
|
---|
83 | else
|
---|
84 | idbin=$found
|
---|
85 | fi
|
---|
86 | fi
|
---|
87 |
|
---|
88 | # check if pfexec can get the job done
|
---|
89 | if test "$idbin" = "/usr/xpg4/bin/id"; then
|
---|
90 | userid=`$pfexecbin $idbin -u`
|
---|
91 | else
|
---|
92 | userid=`$pfexecbin $idbin | cut -f1 -d'(' | cut -f2 -d'='`
|
---|
93 | fi
|
---|
94 | if test $userid != "0"; then
|
---|
95 | # pfexec exists but user has no pfexec privileges, switch to using su and prompting password
|
---|
96 | subin=`which su`
|
---|
97 | fi
|
---|
98 | fi
|
---|
99 |
|
---|
100 | # create temporary admin file for autoinstall
|
---|
101 | echo "basedir=default
|
---|
102 | runlevel=nocheck
|
---|
103 | conflict=quit
|
---|
104 | setuid=nocheck
|
---|
105 | action=nocheck
|
---|
106 | partial=quit
|
---|
107 | instance=unique
|
---|
108 | idepend=quit
|
---|
109 | rdepend=quit
|
---|
110 | space=quit
|
---|
111 | mail=
|
---|
112 | " > /tmp/vbox.autoinstall
|
---|
113 |
|
---|
114 | # check gnome-terminal, use it if it exists.
|
---|
115 | if test -f "/usr/bin/gnome-terminal"; then
|
---|
116 | # use su/pfexec
|
---|
117 | if test -z "$subin"; then
|
---|
118 | /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'"
|
---|
119 | else
|
---|
120 | /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'"
|
---|
121 | fi
|
---|
122 | elif test -f "/usr/X11/bin/xterm"; then
|
---|
123 | # use xterm
|
---|
124 | if test -z "$subin"; then
|
---|
125 | /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"
|
---|
126 | else
|
---|
127 | /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"
|
---|
128 | fi
|
---|
129 | else
|
---|
130 | echo "No suitable terminal not found. -- install additions using pkgadd -d."
|
---|
131 | rm -f /tmp/vbox.autoinstall
|
---|
132 | fi
|
---|
133 |
|
---|
134 | exit 0
|
---|
135 | fi
|
---|
136 |
|
---|
137 | echo "Solaris guest additions installer not found -- try to start them manually."
|
---|
138 | exit 1
|
---|
139 | fi
|
---|
140 |
|
---|