VirtualBox

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

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

Additions/linux/Installer: use only pkexec, sudo and su for the autorun function

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1#!/bin/sh
2# $Id: autorun.sh 36759 2011-04-20 16:40:13Z 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 BINARY="`quotify "$i"`"
53 exec "$gxtpath" "$gxttitle" "$TITLE" "$gxtexec" /bin/sh "$path/runasroot.sh" --has-terminal "$TITLE" "/bin/sh $BINARY --xwin" "Please try running "\""$i"\"" manually."
54 exit
55 ;;
56 esac
57 fi
58 done
59
60 # else: unknown failure
61 echo "Linux guest additions installer not found -- try to start them manually."
62 exit 1
63
64elif test "$ostype" = "SunOS"; then
65
66 # check for combined package
67 installfile="$path/VBoxSolarisAdditions.pkg"
68 if test -f "$installfile"; then
69
70 # check for pkgadd bin
71 pkgaddbin=pkgadd
72 found=`which pkgadd | grep "no pkgadd"`
73 if test ! -z "$found"; then
74 if test -f "/usr/sbin/pkgadd"; then
75 pkgaddbin=/usr/sbin/pkgadd
76 else
77 echo "Could not find pkgadd."
78 exit 1
79 fi
80 fi
81
82 # check for pfexec
83 pfexecbin=pfexec
84 found=`which pfexec | grep "no pfexec"`
85 if test ! -z "$found"; then
86 # Use su and prompt for password
87 echo "Could not find pfexec."
88 subin=`which su`
89 else
90 idbin=/usr/xpg4/bin/id
91 if test ! -x "$idbin"; then
92 found=`which id 2> /dev/null`
93 if test ! -x "$found"; then
94 echo "Failed to find a suitable user id executable."
95 exit 1
96 else
97 idbin=$found
98 fi
99 fi
100
101 # check if pfexec can get the job done
102 if test "$idbin" = "/usr/xpg4/bin/id"; then
103 userid=`$pfexecbin $idbin -u`
104 else
105 userid=`$pfexecbin $idbin | cut -f1 -d'(' | cut -f2 -d'='`
106 fi
107 if test $userid != "0"; then
108 # pfexec exists but user has no pfexec privileges, switch to using su and prompting password
109 subin=`which su`
110 fi
111 fi
112
113 # create temporary admin file for autoinstall
114 echo "basedir=default
115runlevel=nocheck
116conflict=quit
117setuid=nocheck
118action=nocheck
119partial=quit
120instance=unique
121idepend=quit
122rdepend=quit
123space=quit
124mail=
125" > /tmp/vbox.autoinstall
126
127 # check gnome-terminal, use it if it exists.
128 if test -f "/usr/bin/gnome-terminal"; then
129 # use su/pfexec
130 if test -z "$subin"; then
131 /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'"
132 else
133 /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'"
134 fi
135 elif test -f "/usr/X11/bin/xterm"; then
136 # use xterm
137 if test -z "$subin"; then
138 /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"
139 else
140 /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"
141 fi
142 else
143 echo "No suitable terminal not found. -- install additions using pkgadd -d."
144 rm -f /tmp/vbox.autoinstall
145 fi
146
147 exit 0
148 fi
149
150 echo "Solaris guest additions installer not found -- try to start them manually."
151 exit 1
152fi
153
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