Browse Source

Don't fallover if ${HOME}/.profile errors.

tags/0.6.3m2a1
Shane Mc Cormack 15 years ago
parent
commit
47da995c50
1 changed files with 50 additions and 17 deletions
  1. 50
    17
      installer/linux/setup.sh

+ 50
- 17
installer/linux/setup.sh View File

@@ -115,6 +115,51 @@ questiondialog() {
115 115
 
116 116
 UNAME=`uname -a`
117 117
 
118
+# Store params so that we can pass them back to ourself if needed.
119
+for param in "$@"; do
120
+	PSN=`echo "${param}" | grep "^-psn_"`
121
+	if [ "" = "${PSN}" ]; then
122
+		SPACE=`echo "${param}" | grep " "`
123
+		if [ "${SPACE}" != "" ]; then
124
+			niceParam=`echo "${param}" | sed 's/"/\\\\"/g'`
125
+			params=${params}" \"${niceParam}\""
126
+		else
127
+			params=${params}" ${param}"
128
+		fi;
129
+	fi;
130
+done;
131
+
132
+# Check for some CLI params
133
+isRelease=""
134
+USEPROFILE=1;
135
+while test -n "$1"; do
136
+	case "$1" in
137
+		--release|-r)
138
+			shift
139
+			isRelease=${1}
140
+			;;
141
+		--help|-h)
142
+			showHelp;
143
+			;;
144
+		--noprofile)
145
+			USEPROFILE=0;
146
+			;;
147
+	esac
148
+	shift;
149
+done
150
+
151
+relaunch() {
152
+	trap - INT TERM EXIT
153
+	echo ""
154
+	echo "============================================================="
155
+	echo "ERROR"
156
+	echo "============================================================="
157
+	echo "${HOME}/.profile has errors in it (or an 'exit' command)."
158
+	echo "Setup will now restart with the --noprofile option."
159
+	echo "============================================================="
160
+	sh ${0} ${params} --noprofile
161
+}
162
+
118 163
 echo ""
119 164
 echo "---------------------"
120 165
 echo "Setup.sh"
@@ -128,9 +173,12 @@ if [ ! -e "${JAVA}" ]; then
128 173
 	JAVA="/usr/local/diablo-jdk1.6.0/jre/bin/java"
129 174
 	if [ ! -e "${JAVA}" ]; then
130 175
 		# Look in path
131
-		if [ -e "${HOME}/.profile" ]; then
132
-				# Source the profile incase java can't be found otherwise
176
+		if [ -e "${HOME}/.profile" -a "${USEPROFILE}" = "1" ]; then
177
+			# Source the profile incase java can't be found otherwise
178
+			# First, lets add a nice handler for the script exiting because of this crap.
179
+			trap relaunch INT TERM EXIT
133 180
 			. ${HOME}/.profile
181
+			trap - INT TERM EXIT
134 182
 		fi;
135 183
 		JAVA=`which java`
136 184
 	fi
@@ -207,21 +255,6 @@ showHelp() {
207 255
 	exit 0;
208 256
 }
209 257
 
210
-# Check for some CLI params
211
-isRelease=""
212
-while test -n "$1"; do
213
-	case "$1" in
214
-		--release|-r)
215
-			shift
216
-			isRelease=${1}
217
-			shift
218
-			;;
219
-		--help|-h)
220
-			showHelp;
221
-			;;
222
-	esac
223
-done
224
-
225 258
 if [ "${isRelease}" != "" ]; then
226 259
 	isRelease=" --release "${isRelease}
227 260
 fi

Loading…
Cancel
Save