5 # Go to the proper setup directory (if not already there)
9 FATAL_ERROR="Fatal error, no tech support email configured in this setup"
10 # try to get root prior to running setup?
12 # 1: prompt, but run anyway if fails
13 # 2: require, abort if root fails
16 # You may want to set USE_XHOST to 1 if you want an X11 application to
17 # be launched with root privileges right after installation
19 # this is the message for su call, printf
20 SU_MESSAGE="You need to run this installation as the super user.\nPlease enter the root password."
23 # See if we have the XPG4 utilities (Solaris)
24 if test -d /usr/xpg4/bin; then
25 PATH=/usr/xpg4/bin:$PATH
28 # Return the appropriate architecture string
51 arch=`uname -p 2> /dev/null || uname -m`
52 if test "$arch" = powerpc; then
63 # Return the appropriate version string
67 if [ `uname -s` != Linux ]; then
71 if [ -f `echo /lib/libc.so.6* | tail -n 1` ]; then
72 # I'm not using glibc-specific binaries
73 # this step even fails on amd64 gentoo, only has GLIBC_2.2 2.3 in it's strings
76 # if [ fgrep GLIBC_2.1 /lib/libc.so.6* 2> $NULL >> $NULL ]; then
83 elif [ -f /lib/libc.so.5 ]; then
95 if test "$os" = "OpenUNIX"; then
103 # Detect the environment
110 # Import preferences from a secondary script
111 if [ -f setup.data/config.sh ]; then
112 . setup.data/config.sh
113 elif [ -f SETUP.DAT/CONFIG.SH\;1 ]; then
114 # HP-UX and other systems unable to get LFN correctly
115 . SETUP.DAT/CONFIG.SH\;1
118 # Add some standard paths for compatibility
121 # call setup with -auth when ran through su/xsu
123 if [ "$1" = "-auth" ]
129 # Find the installation program
130 # try_run [-absolute] [-fatal] INSTALLER_NAME [PARAMETERS_PASSED]
131 # -absolute option: if what you are trying to execute has an absolute path
132 # NOTE: maybe try_run_absolute would be easier
133 # -fatal option: if you want verbose messages in case
134 # - the script could not be found
135 # - it's execution would fail
136 # INSTALLER_NAME: setup.gtk or setup
137 # PARAMETERS_PASSED: additional arguments passed to the setup script
141 if [ "$1" = "-absolute" ]; then
147 # older bash < 2.* don't like == operator, using =
148 if [ "$1" = "-fatal" ]; then
157 # First find the binary we want to run
159 if [ "$absolute" -eq 0 ]
161 setup_bin="setup.data/bin/$os/$arch/$libc/$setup"
163 if [ ! -f "$setup_bin" ]; then
164 setup_bin="setup.data/bin/$os/$arch/$setup"
165 # libc dependant version failed, trying again
166 if [ ! -f "$setup_bin" ]; then
170 if [ "$failed" -eq 1 ]; then
171 if [ "$fatal" -eq 1 ]; then
173 This installation doesn't support $libc on $os / $arch
174 (tried to run $setup)
181 # Try to run the binary ($setup_bin)
182 # The executable is here but we can't execute it from CD
183 # NOTE TTimo: this is dangerous, we also use $setup to store the name of the try_run
184 setup="$HOME/.setup$$"
186 cp "$setup_bin" "$setup"
188 trap "rm -f $setup" 1 2 3 15
190 # echo Running "$setup" "$@"
191 if [ "$fatal" -eq 0 ]; then
195 "$setup" "$@" 2>> $NULL
198 if [ "$absolute" -eq 0 ]
200 # don't attempt removal when we are passed an absolute path
201 # no, I don't want to imagine a faulty try_run as root on /bin/su
207 if [ "$GET_ROOT" -eq 3 ]
210 if [ "$GOT_ROOT" != "0" ]
212 printf "$SU_MESSAGE\n"
213 echo "Press Enter to continue or Ctrl-C to abort"
219 # if we have not been through the auth yet, and if we need to get root, then prompt
220 if [ "$auth" -eq 0 ] && [ "$GET_ROOT" -ne 0 ]
223 if [ "$GOT_ROOT" != "0" ]
225 if [ "$USE_XHOST" -eq 1 ]; then
226 xhost +127.0.0.1 2> $NULL > $NULL
228 if [ "$GET_ROOT" -eq 1 ]
230 try_run xsu -e -a -u root -c "sh `pwd`/setup.sh -auth" $XSU_ICON -m "$XSU_MESSAGE"
232 try_run xsu -e -a -u root -c "sh `pwd`/setup.sh -auth" $XSU_ICON
236 # if try_run successfully executed xsu, it will return xsu's exit code
237 # xsu returns 2 if ran and cancelled (i.e. the user 'doesn't want' to auth)
238 # it will return 0 if the command was executed correctly
239 # summing up, if we get 1, something failed
240 if [ "$status" -eq 0 ]
242 # the auth command was properly executed
244 elif [ "$status" -eq 1 ]
246 # xsu wasn't found, or failed to run
247 # if xsu actually ran and the auth was cancelled, $status is > 1
249 # su will return 1 if auth failed
250 # we need to distinguish between su auth failed and su working, and still get setup.sh return code
251 printf "$SU_MESSAGE\n"
252 try_run -absolute /bin/su root -c "export DISPLAY=$DISPLAY;sh `pwd`/setup.sh -auth"
254 if [ "$status" -eq 1 ] && [ "$GET_ROOT" -eq 1 ]
256 echo "Running setup as user"
260 elif [ "$status" -eq 3 ]
262 if [ "$GET_ROOT" -eq 1 ]
264 echo "Running setup as user"
266 # the auth failed or was canceled
267 # we don't want to even start the setup if not root
268 echo "Please run this installation as the super user"
272 # continue running as is
276 # run the setup program (setup.gtk first, then setup)
277 # except when trying setup.gtk first then console setup, always exit with 0
278 # if the setup was cancelled, it is not our problem
279 try_run setup.gtk $args $*
281 if [ "$status" -ne 0 ] && [ "$status" -ne 3 ]; then # setup.gtk couldn't connect to X11 server - ignore
282 try_run setup $args $*
284 if [ "$auth" -eq 1 ] && [ "$status" -ne 0 ]
286 # distinguish between failed su and failed su'ed setup.sh