VirtualBox

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

Last change on this file since 36658 was 36658, checked in by vboxsync, 14 years ago

Additions/linux/installer: shell script refactoring

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1#!/bin/sh
2# $Id: autorun.sh 36658 2011-04-12 15:40:51Z 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#include sh-utils.sh
22
23ostype=`uname -s`
24if test "$ostype" != "Linux" && test "$ostype" != "SunOS" ; then
25 echo "Linux/Solaris not detected."
26 exit 1
27fi
28
29# 32-bit or 64-bit?
30path=`dirname $0`
31case `uname -m` in
32 i[3456789]86|x86|i86pc)
33 arch='x86'
34 ;;
35 x86_64|amd64|AMD64)
36 arch='amd64'
37 ;;
38 *)
39 echo "Unknown architecture `uname -m`."
40 exit 1
41 ;;
42esac
43
44# execute the installer
45if test "$ostype" = "Linux"; then
46 for i in "$path/VBoxLinuxAdditions.run" \
47 "$path/VBoxLinuxAdditions-$arch.run"; do
48 if test -f "$i"; then
49 getxterm
50 case "$gxtpath" in ?*)
51 TITLE="VirtualBox Guest Additions installation"
52 TITLE_QUOTED=`quotify "$TITLE"`
53 BINARY=`quotify $i`
54 exec /bin/sh "$path/runasroot.sh" \
55 "$TITLE" \
56 "$gxtpath $gxttitle $TITLE_QUOTED $gxtexec $BINARY --xwin" \
57 "Please try running $i manually."
58 exit
59 ;;
60 esac
61 fi
62 done
63
64 # else: unknown failure
65 echo "Linux guest additions installer not found -- try to start them manually."
66 exit 1
67
68elif test "$ostype" = "SunOS"; then
69
70 # check for combined package
71 installfile="$path/VBoxSolarisAdditions.pkg"
72 if test -f "$installfile"; then
73
74 # check for pkgadd bin
75 pkgaddbin=pkgadd
76 found=`which pkgadd | grep "no pkgadd"`
77 if test ! -z "$found"; then
78 if test -f "/usr/sbin/pkgadd"; then
79 pkgaddbin=/usr/sbin/pkgadd
80 else
81 echo "Could not find pkgadd."
82 exit 1
83 fi
84 fi
85
86 # check for pfexec
87 pfexecbin=pfexec
88 found=`which pfexec | grep "no pfexec"`
89 if test ! -z "$found"; then
90 # Use su and prompt for password
91 echo "Could not find pfexec."
92 subin=`which su`
93 else
94 idbin=/usr/xpg4/bin/id
95 if test ! -x "$idbin"; then
96 found=`which id 2> /dev/null`
97 if test ! -x "$found"; then
98 echo "Failed to find a suitable user id executable."
99 exit 1
100 else
101 idbin=$found
102 fi
103 fi
104
105 # check if pfexec can get the job done
106 if test "$idbin" = "/usr/xpg4/bin/id"; then
107 userid=`$pfexecbin $idbin -u`
108 else
109 userid=`$pfexecbin $idbin | cut -f1 -d'(' | cut -f2 -d'='`
110 fi
111 if test $userid != "0"; then
112 # pfexec exists but user has no pfexec privileges, switch to using su and prompting password
113 subin=`which su`
114 fi
115 fi
116
117 # create temporary admin file for autoinstall
118 echo "basedir=default
119runlevel=nocheck
120conflict=quit
121setuid=nocheck
122action=nocheck
123partial=quit
124instance=unique
125idepend=quit
126rdepend=quit
127space=quit
128mail=
129" > /tmp/vbox.autoinstall
130
131 # check gnome-terminal, use it if it exists.
132 if test -f "/usr/bin/gnome-terminal"; then
133 # use su/pfexec
134 if test -z "$subin"; then
135 /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'"
136 else
137 /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'"
138 fi
139 elif test -f "/usr/X11/bin/xterm"; then
140 # use xterm
141 if test -z "$subin"; then
142 /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"
143 else
144 /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"
145 fi
146 else
147 echo "No suitable terminal not found. -- install additions using pkgadd -d."
148 rm -f /tmp/vbox.autoinstall
149 fi
150
151 exit 0
152 fi
153
154 echo "Solaris guest additions installer not found -- try to start them manually."
155 exit 1
156fi
157
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