VirtualBox

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

最後變更 在這個檔案從58324是 58324,由 vboxsync 提交於 9 年 前

Installers/linux: cleaner script for getting shell script location folders.

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

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