1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # Sun VirtualBox
|
---|
4 | # VirtualBox Guest Additions installation script for Linux
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyrign Microsystems, Inc.
|
---|
8 | #
|
---|
9 | # Sun Microsystems, Inc.
|
---|
10 | # All rights reserved
|
---|
11 | #
|
---|
12 |
|
---|
13 | PATH=$PATH:/bin:/sbin:/usr/sbin
|
---|
14 |
|
---|
15 | ostype=`uname -s`
|
---|
16 | if test "$ostype" != "Linux" && test "$ostype" != "SunOS" ; then
|
---|
17 | echo "Linux/Solaris not detected."
|
---|
18 | exit 1
|
---|
19 | fi
|
---|
20 |
|
---|
21 | # 32-bit or 64-bit?
|
---|
22 | path=`dirname $0`
|
---|
23 | case `uname -m` in
|
---|
24 | i[3456789]86|x86|i86pc)
|
---|
25 | arch='x86'
|
---|
26 | ;;
|
---|
27 | x86_64|amd64|AMD64)
|
---|
28 | arch='amd64'
|
---|
29 | ;;
|
---|
30 | *)
|
---|
31 | echo "Unknown architecture `uname -m`."
|
---|
32 | exit 1
|
---|
33 | ;;
|
---|
34 | esac
|
---|
35 |
|
---|
36 | # execute the installer
|
---|
37 | if test "$ostype" = "Linux"; then
|
---|
38 | if test -f "$path/VBoxLinuxAdditions-$arch.run"; then
|
---|
39 | exec gksu /bin/sh "$path/VBoxLinuxAdditions-$arch.run"
|
---|
40 | fi
|
---|
41 |
|
---|
42 | # else: unknown failure
|
---|
43 | echo "Linux guest additions installer not found -- try to start them manually."
|
---|
44 | exit 1
|
---|
45 |
|
---|
46 | elif test "$ostype" = "SunOS"; then
|
---|
47 |
|
---|
48 | # check for combined package
|
---|
49 | installfile="$path/VBoxSolarisAdditions.pkg"
|
---|
50 | if test -f "$installfile"; then
|
---|
51 |
|
---|
52 | # check for pkgadd bin
|
---|
53 | pkgaddbin=pkgadd
|
---|
54 | found=`which pkgadd | grep "no pkgadd"`
|
---|
55 | if test ! -z "$found"; then
|
---|
56 | if test -f "/usr/sbin/pkgadd"; then
|
---|
57 | pkgaddbin=/usr/sbin/pkgadd
|
---|
58 | else
|
---|
59 | echo "Could not find pkgadd."
|
---|
60 | exit 1
|
---|
61 | fi
|
---|
62 | fi
|
---|
63 |
|
---|
64 | # check for pfexec
|
---|
65 | pfexecbin=pfexec
|
---|
66 | found=`which pfexec | grep "no pfexec"`
|
---|
67 | if test ! -z "$found"; then
|
---|
68 | # Use su and prompt for password
|
---|
69 | echo "Could not find pfexec."
|
---|
70 | subin=`which su`
|
---|
71 | else
|
---|
72 | idbin=/usr/xpg4/bin/id
|
---|
73 | if test ! -x "$idbin"; then
|
---|
74 | found=`which id 2> /dev/null`
|
---|
75 | if test ! -x "$found"; then
|
---|
76 | echo "Failed to find a suitable user id executable."
|
---|
77 | exit 1
|
---|
78 | else
|
---|
79 | idbin=$found
|
---|
80 | fi
|
---|
81 | fi
|
---|
82 |
|
---|
83 | # check if pfexec can get the job done
|
---|
84 | if test "$idbin" = "/usr/xpg4/bin/id"; then
|
---|
85 | userid=`$pfexecbin $idbin -u`
|
---|
86 | else
|
---|
87 | userid=`$pfexecbin $idbin | cut -f1 -d'(' | cut -f2 -d'='`
|
---|
88 | fi
|
---|
89 | if test $userid != "0"; then
|
---|
90 | # pfexec exists but user has no pfexec privileges, switch to using su and prompting password
|
---|
91 | subin=`which su`
|
---|
92 | fi
|
---|
93 | fi
|
---|
94 |
|
---|
95 | # create temporary admin file for autoinstall
|
---|
96 | echo "basedir=default
|
---|
97 | runlevel=nocheck
|
---|
98 | conflict=quit
|
---|
99 | setuid=nocheck
|
---|
100 | action=nocheck
|
---|
101 | partial=quit
|
---|
102 | instance=unique
|
---|
103 | idepend=quit
|
---|
104 | rdepend=quit
|
---|
105 | space=quit
|
---|
106 | mail=
|
---|
107 | " > /tmp/vbox.autoinstall
|
---|
108 |
|
---|
109 | # check gnome-terminal, use it if it exists.
|
---|
110 | if test -f "/usr/bin/gnome-terminal"; then
|
---|
111 | # use su/pfexec
|
---|
112 | if test -z "$subin"; then
|
---|
113 | /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'"
|
---|
114 | else
|
---|
115 | /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'"
|
---|
116 | fi
|
---|
117 | elif test -f "/usr/X11/bin/xterm"; then
|
---|
118 | # use xterm
|
---|
119 | if test -z "$subin"; then
|
---|
120 | /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"
|
---|
121 | else
|
---|
122 | /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"
|
---|
123 | fi
|
---|
124 | else
|
---|
125 | echo "No suitable terminal not found. -- install additions using pkgadd -d."
|
---|
126 | rm -f /tmp/vbox.autoinstall
|
---|
127 | fi
|
---|
128 |
|
---|
129 | exit 0
|
---|
130 | fi
|
---|
131 |
|
---|
132 | echo "Solaris guest additions installer not found -- try to start them manually."
|
---|
133 | exit 1
|
---|
134 | fi
|
---|
135 |
|
---|