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 | # check if pfexec can get the job done
|
---|
73 | userid=`$pfexecbin id -u`
|
---|
74 | if test $userid != "0"; then
|
---|
75 | # pfexec exists but user has no pfexec privileges, switch to using su and prompting password
|
---|
76 | subin=`which su`
|
---|
77 | fi
|
---|
78 | fi
|
---|
79 |
|
---|
80 | # create temporary admin file for autoinstall
|
---|
81 | echo "basedir=default
|
---|
82 | runlevel=nocheck
|
---|
83 | conflict=quit
|
---|
84 | setuid=nocheck
|
---|
85 | action=nocheck
|
---|
86 | partial=quit
|
---|
87 | instance=unique
|
---|
88 | idepend=quit
|
---|
89 | rdepend=quit
|
---|
90 | space=quit
|
---|
91 | mail=
|
---|
92 | " > /tmp/vbox.autoinstall
|
---|
93 |
|
---|
94 | # check gnome-terminal, use it if it exists.
|
---|
95 | if test -f "/usr/bin/gnome-terminal"; then
|
---|
96 | # use su/pfexec
|
---|
97 | if test -z "$subin"; then
|
---|
98 | /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'"
|
---|
99 | else
|
---|
100 | /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'"
|
---|
101 | fi
|
---|
102 | elif test -f "/usr/X11/bin/xterm"; then
|
---|
103 | # use xterm
|
---|
104 | if test -z "$subin"; then
|
---|
105 | /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"
|
---|
106 | else
|
---|
107 | /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"
|
---|
108 | fi
|
---|
109 | else
|
---|
110 | echo "No suitable terminal not found. -- install additions using pkgadd -d."
|
---|
111 | rm -f /tmp/vbox.autoinstall
|
---|
112 | fi
|
---|
113 |
|
---|
114 | exit 0
|
---|
115 | fi
|
---|
116 |
|
---|
117 | echo "Solaris guest additions installer not found -- try to start them manually."
|
---|
118 | exit 1
|
---|
119 | fi
|
---|
120 |
|
---|