blob: f0a2d92dd0137f15224ce69a796756c1b8144864 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#!/bin/bash
#
# $Header: /var/cvsroot/gentoo/src/installer/bin/installer,v 1.6 2006/07/31 17:01:53 wolf31o2 Exp $
#
# This is the installer script that we will use to determine whether or not
# we are running in X or as root. A good portion of this script was ripped
# from the loki_setup setup.sh script, as it already did most of what I was
# looking to do.
installer_root=/opt/installer
# Allow X
xhost +localhost 2>/dev/null
# Go to the proper setup directory
cd ${installer_root}/bin
# we call installer with -auth when ran through su/xsu/sudo
auth=0
if [ "${1}" == "-auth" ]
then
auth=1
shift
fi
# we see if we were called with a specific front-end
launch=
if [ "${1}" == "gtk" ]
then
launch=gtk
shift
elif [ "${1}" == "dialog" ]
then
launch=dialog
shift
fi
# Find the installation program
# try_run INSTALLER_NAME [PARAMETERS_PASSED]
# INSTALLER_NAME: installer-gtk or installer-dialog
# PARAMETERS_PASSED: additional arguments passed to the setup script
try_run() {
setup=${1}
shift
failed=0
"${setup}" "${@}" 2>/dev/null
failed="${?}"
return "${failed}"
}
if [ "${auth}" -eq 0 ]
then
GOT_ROOT=$(id -u)
if [ "${GOT_ROOT}" != "0" ]
then
# first we try sudo
try_run /usr/bin/sudo env DISPLAY=":0.0" ${installer_root}/bin/installer -auth ${launch} "$@"
status="${?}"
if [ "${status}" -eq 0 ]
then
exit 0
else
try_run /usr/bin/gnomesu -u root -c "sh ${installer_root}/bin/installer -auth ${launch}"
status="$?"
# If try_run successfully executed gnomesu, it will return
# gnomesu's exit code.
if [ "${status}" -eq 0 ]
then
exit 0
else
try_run /usr/bin/xsu -e -a -u root -c "sh ${installer_root}/bin/installer -auth ${launch}"
status="${?}"
# xsu returns 2 if ran and cancelled (i.e. the user 'doesn't
# want' to auth). it will return 0 if the command was executed
# correctly
# summing up, if we get 1, something failed
if [ "${status}" -eq 0 ]
then
exit 0
else
# xsu wasn't found, or failed to run
# if xsu actually ran and the auth was cancelled,
# $status is 2
echo "You need to run this installation as the super user."
exit 1
# echo "Please enter the root password."
# try_run /bin/su root -c "export DISPLAY=${DISPLAY};sh ${installer_root}/bin/installer -auth ${launch}"
# status="${?}"
# if [ "${status}" -eq 0 ]
# then
# # the auth command was properly executed
# exit 0
# else
# echo "Please run this installation as the super user"
# exit 1
# fi
fi
fi
fi
fi
fi
if [ -z "${launch}" ]
then
# Try to run the gtk installer
try_run /usr/bin/installer-gtk ${*}
status=${?}
if [ ${status} -ge 1 ]
then
try_run /usr/bin/installer-dialog ${*} || {
if [ ${status} -ne 2 ]
then
echo "The setup program seems to have failed"
fi
status=1
}
fi
else
# Try to run the installer script asked for when launched
try_run /usr/bin/installer-${launch} ${*} || {
echo "The setup program seems to have failed"
status=1
}
fi
exit ${status}
|