VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/installer/autorun.sh@ 58837

Last change on this file since 58837 was 58351, checked in by vboxsync, 9 years ago

Installer/linux (guest): get rid of more auto-generation.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1#!/bin/sh
2# $Id: autorun.sh 58351 2015-10-21 08:59:00Z vboxsync $
3#
4# VirtualBox Guest Additions installation script for *nix guests
5#
6
7#
8# Copyright (C) 2009-2011 Oracle Corporation
9#
10# This file is part of VirtualBox Open Source Edition (OSE), as
11# available from http://www.virtualbox.org. This file is free software;
12# you can redistribute it and/or modify it under the terms of the GNU
13# General Public License (GPL) as published by the Free Software
14# Foundation, in version 2 as it comes in the "COPYING" file of the
15# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17#
18
19PATH=$PATH:/bin:/sbin:/usr/sbin
20
21# Deal with differing "which" semantics
22mywhich() {
23 which "$1" 2>/dev/null | grep -v "no $1"
24}
25
26# Get the name and execute switch for a useful terminal emulator
27#
28# Sets $gxtpath to the emulator path or empty
29# Sets $gxttitle to the "title" switch for that emulator
30# Sets $gxtexec to the "execute" switch for that emulator
31# May clobber $gtx*
32# Calls mywhich
33getxterm() {
34 # gnome-terminal uses -e differently to other emulators
35 for gxti in "konsole --title -e" "gnome-terminal --title -x" "xterm -T -e"; do
36 set $gxti
37 gxtpath="`mywhich $1`"
38 case "$gxtpath" in ?*)
39 gxttitle=$2
40 gxtexec=$3
41 return
42 ;;
43 esac
44 done
45}
46
47# Quotes its argument by inserting '\' in front of every character save
48# for 'A-Za-z0-9/'. Prints the result to stdout.
49quotify() {
50 echo "$1" | sed -e 's/\([^a-zA-Z0-9/]\)/\\\1/g'
51}
52
53ostype=`uname -s`
54if test "$ostype" != "Linux" && test "$ostype" != "SunOS" ; then
55 echo "Linux/Solaris not detected."
56 exit 1
57fi
58
59# The below is GNU-specific. See VBox.sh for the longer Solaris/OS X version.
60TARGET=`readlink -e -- "${0}"` || exit 1
61path="${TARGET%/[!/]*}"
62# 32-bit or 64-bit?
63case `uname -m` in
64 i[3456789]86|x86|i86pc)
65 arch='x86'
66 ;;
67 x86_64|amd64|AMD64)
68 arch='amd64'
69 ;;
70 *)
71 echo "Unknown architecture `uname -m`."
72 exit 1
73 ;;
74esac
75
76# execute the installer
77if test "$ostype" = "Linux"; then
78 for i in "$path/VBoxLinuxAdditions.run" \
79 "$path/VBoxLinuxAdditions-$arch.run"; do
80 if test -f "$i"; then
81 getxterm
82 case "$gxtpath" in ?*)
83 TITLE="VirtualBox Guest Additions installation"
84 BINARY="`quotify "$i"`"
85 exec "$gxtpath" "$gxttitle" "$TITLE" "$gxtexec" /bin/sh "$path/runasroot.sh" --has-terminal "$TITLE" "/bin/sh $BINARY --xwin" "Please try running "\""$i"\"" manually."
86 exit
87 ;;
88 esac
89 fi
90 done
91
92 # else: unknown failure
93 echo "Linux guest additions installer not found -- try to start them manually."
94 exit 1
95
96elif test "$ostype" = "SunOS"; then
97
98 # check for combined package
99 installfile="$path/VBoxSolarisAdditions.pkg"
100 if test -f "$installfile"; then
101
102 # check for pkgadd bin
103 pkgaddbin=pkgadd
104 found=`which pkgadd | grep "no pkgadd"`
105 if test ! -z "$found"; then
106 if test -f "/usr/sbin/pkgadd"; then
107 pkgaddbin=/usr/sbin/pkgadd
108 else
109 echo "Could not find pkgadd."
110 exit 1
111 fi
112 fi
113
114 # check for pfexec
115 pfexecbin=pfexec
116 found=`which pfexec | grep "no pfexec"`
117 if test ! -z "$found"; then
118 # Use su and prompt for password
119 echo "Could not find pfexec."
120 subin=`which su`
121 else
122 idbin=/usr/xpg4/bin/id
123 if test ! -x "$idbin"; then
124 found=`which id 2> /dev/null`
125 if test ! -x "$found"; then
126 echo "Failed to find a suitable user id executable."
127 exit 1
128 else
129 idbin=$found
130 fi
131 fi
132
133 # check if pfexec can get the job done
134 if test "$idbin" = "/usr/xpg4/bin/id"; then
135 userid=`$pfexecbin $idbin -u`
136 else
137 userid=`$pfexecbin $idbin | cut -f1 -d'(' | cut -f2 -d'='`
138 fi
139 if test $userid != "0"; then
140 # pfexec exists but user has no pfexec privileges, switch to using su and prompting password
141 subin=`which su`
142 fi
143 fi
144
145 # create temporary admin file for autoinstall
146 echo "basedir=default
147runlevel=nocheck
148conflict=quit
149setuid=nocheck
150action=nocheck
151partial=quit
152instance=unique
153idepend=quit
154rdepend=quit
155space=quit
156mail=
157" > /tmp/vbox.autoinstall
158
159 # check gnome-terminal, use it if it exists.
160 if test -f "/usr/bin/gnome-terminal"; then
161 # use su/pfexec
162 if test -z "$subin"; then
163 /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'"
164 else
165 /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'"
166 fi
167 elif test -f "/usr/X11/bin/xterm"; then
168 # use xterm
169 if test -z "$subin"; then
170 /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"
171 else
172 /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"
173 fi
174 else
175 echo "No suitable terminal not found. -- install additions using pkgadd -d."
176 rm -f /tmp/vbox.autoinstall
177 fi
178
179 exit 0
180 fi
181
182 echo "Solaris guest additions installer not found -- try to start them manually."
183 exit 1
184fi
185
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette