Project

General

Profile

« Previous | Next » 

Revision 73531eb1

Added by Scott Ullrich almost 15 years ago

Progress bar now works, installer looks pretty slick!

View differences:

usr/local/www/installer.php
120 120
	// Ensure status files exist
121 121
	if(!file_exists("/tmp/installer_installer_running"))
122 122
		touch("/tmp/installer_installer_running");
123
	if(!file_exists("/tmp/installer_last_progress"))
124
		touch("/tmp/installer_last_progress");
125 123
	$status = `tail -n20 /tmp/.pc-sysinstall/pc-sysinstall.log`;
124
	$status = str_replace("\n", "\\n", $status);
125
	$status = str_replace("\n", "\\r", $status);
126 126
	echo "this.document.forms[0].installeroutput.value='$status';\n";
127
	$installer_running = trim(file_get_contents("/tmp/installer_installer_running"));
128
	if($installer_running <> "running") {
129
		$ps_running = exec("ps awwwux | grep -v grep | grep 'sh /tmp/installer.sh'");
130
		if($ps_running)	
131
			echo "\$('installerrunning').innerHTML='<img src=\"/themes/{$g['theme']}/images/misc/loader.gif\"> Installer running...';\n";
132
		file_put_contents("/tmp/installer_installer_running", "running");
133
	}
134 127
	// Find out installer progress
135 128
	if(strstr($status, "/boot /mnt/boot")) 
136
		$progress = "1";
129
		$progress = "10";
137 130
	if(strstr($status, "/COPYRIGHT /mnt/COPYRIGHT"))
138
		$progress = "2";
131
		$progress = "20";
139 132
	if(strstr($status, "/bin /mnt/bin"))
140
		$progress = "5";
133
		$progress = "25";
141 134
	if(strstr($status, "/conf /mnt/conf"))
142
		$progress = "10";
135
		$progress = "30";
143 136
	if(strstr($status, "/conf.default /mnt/conf.default"))
144
		$progress = "15";
137
		$progress = "35";
145 138
	if(strstr($status, "/dev /mnt/dev"))
146
		$progress = "20";
139
		$progress = "40";
147 140
	if(strstr($status, "/etc /mnt/etc"))
148
		$progress = "25";
141
		$progress = "45";
149 142
	if(strstr($status, "/home /mnt/home"))
150
		$progress = "30";
143
		$progress = "50";
151 144
	if(strstr($status, "/kernels /mnt/kernels"))
152
		$progress = "35";
145
		$progress = "55";
153 146
	if(strstr($status, "/libexec /mnt/libexec"))
154
		$progress = "40";
147
		$progress = "60";
155 148
	if(strstr($status, "/lib /mnt/lib"))
156
		$progress = "45";
149
		$progress = "65";
157 150
	if(strstr($status, "/root /mnt/root"))
158
		$progress = "50";
151
		$progress = "70";
159 152
	if(strstr($status, "/sbin /mnt/sbin"))
160
		$progress = "55";
153
		$progress = "75";
161 154
	if(strstr($status, "/sys /mnt/sys"))
162
		$progress = "60";
155
		$progress = "80";
163 156
	if(strstr($status, "/usr /mnt/usr"))
164
		$progress = "70";
157
		$progress = "95";
165 158
	if(strstr($status, "/usr /mnt/usr"))
166
		$progress = "80";
167
	if(strstr($status, "/var /mnt/var"))
168 159
		$progress = "90";
160
	if(strstr($status, "/var /mnt/var"))
161
		$progress = "95";
169 162
	if(strstr($status, "Installation finished"))
170 163
		$progress = "100";
171
	$last_progress = trim(file_get_contents("/tmp/installer_last_progress"));
172
	if($last_progress <> $progress) 
173
		echo "\ndocument.progressbar.style.width='{$progress}%';\n";
174
	file_put_contents("/tmp/installer_last_progress", trim($progress));
175
	if(file_exists("/tmp/install_complete")) {
164
	$running_old = trim(file_get_contents("/tmp/installer_installer_running"));
165
	if($installer_running <> "running") {
166
		$ps_running = exec("ps awwwux | grep -v grep | grep 'sh /tmp/installer.sh'");
167
		if($ps_running)	{
168
			$running = "\$('installerrunning').innerHTML='<table><tr><td valign=\"middle\"><img src=\"/themes/{$g['theme']}/images/misc/loader.gif\"></td><td valign=\"middle\">&nbsp;<font size=\"2\"><b>Installer running ({$progress}% completed)...</td></tr></table>'; ";
169
			if($running_old <> $running) {
170
				echo $running;
171
				file_put_contents("/tmp/installer_installer_running", "$running");			
172
			}
173
		}
174
	}
175
	if($progress) 
176
		echo "\$('progressbar').style.width='{$progress}%';\n";
177
	if($progress == "100") {
176 178
		echo "\$('installerrunning').innerHTML='Installation completed.  Please <a href=\"reboot.php\">reboot</a> to continue';\n";
177 179
		unlink_if_exists("/tmp/installer.sh");
178 180
		file_put_contents("/tmp/installer_installer_running", "finished");
......
182 184
function update_installer_status_win($status) {
183 185
	global $g;
184 186
	echo "<script type=\"text/javascript\">\n";
185
	echo "\$('installeroutput').value = '" . str_replace(htmlentities($status), "\n", "") . "';\n";
186
	echo "installeroutput.scroll = installeroutput.maxScroll;\n";
187
	echo "	\$('installeroutput').value = '" . str_replace(htmlentities($status), "\n", "") . "';\n";
187 188
	echo "</script>";
188 189
}
189 190

  
......
212 213
	echo <<<EOF
213 214
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
214 215
	<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
215
		<script type="text/javascript">
216
			function getinstallerprogress() {
217
				url = 'installer.php';
218
				pars = 'state=update_installer_status';
219
				callajax(url, pars, installcallback);
220
			}
221
			function callajax(url, pars, activitycallback) {
222
				var myAjax = new Ajax.Request(
223
					url,
224
					{
225
						method: 'post',
226
						parameters: pars,
227
						onComplete: activitycallback
228
					});
229
			}
230
			function installcallback(transport) {
231
				eval(transport.responseText);
232
				setTimeout('getinstallerprogress()', 1000);		
233
			}
216
	<script type="text/javascript">
217
		function getinstallerprogress() {
218
			url = 'installer.php';
219
			pars = 'state=update_installer_status';
220
			callajax(url, pars, installcallback);
221
		}
222
		function callajax(url, pars, activitycallback) {
223
			var myAjax = new Ajax.Request(
224
				url,
225
				{
226
					method: 'post',
227
					parameters: pars,
228
					onComplete: activitycallback
229
				});
230
		}
231
		function installcallback(transport) {
232
			setTimeout('getinstallerprogress()', 2000);
233
			eval(transport.responseText);
234
		}
234 235
	</script>
235 236
EOF;
236 237

  
......
279 280
function quickeasyinstall_gui() {
280 281
	global $g;
281 282
	body_html();
283
	echo "<form action=\"installer.php\" method=\"post\" state=\"step1_post\">";
282 284
	page_table_start();
283 285
	echo <<<EOF
284
	<form action="installer.php" method="post" state="step1_post">
285 286
	<center>
286 287
		<table width="100%">
287 288
		<tr><td>
......
294 295
									<tr>
295 296
			     						<td class="tabcont" >
296 297
											<div id="pfsenseinstaller" width="100%">
297
												<div id='installerrunning' width='100%' style="padding:2em; border:1px solid #000000">
298
													<img src="/themes/{$g['theme']}/images/misc/loader.gif"> Starting Installer...  Please wait...<p/>
298
												<div id='installerrunning' width='100%' style="padding:1em; border:1px dashed #000000">
299
													<table>
300
														<tr>
301
															<td valign="middle">
302
																<img src="/themes/{$g['theme']}/images/misc/loader.gif">
303
															</td>
304
															<td valign="middle">
305
																&nbsp;<font size="2"><b>Starting Installer...  Please wait...
306
															</td>
307
														</tr>
308
													</table>
299 309
												</div>
300 310
												<br/>
301
												<table width="100%" height="15" colspacing="0" cellpadding="0" cellspacing="0" border="0" align="top" nowrap>
311
												<table height='15' width='640' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
302 312
													<tr>
303
														<td width="5" height="15" background="./themes/{$g['theme']}/images/misc/bar_left.gif" align="top">
313
														<td background="./themes/the_wall/images/misc/bar_left.gif" height='15' width='5'>
304 314
														</td>
305 315
														<td>
306
															<table WIDTH="100%" height="15" colspacing="0" cellpadding="0" cellspacing="0" border="0" align="top" nowrap>
307
																<tr>
308
																	<td background="./themes/{$g['theme']}/images/misc/bar_gray.gif">
309
																		<img src='./themes/{$g['theme']}/images/misc/bar_blue.gif' height='15' WIDTH='1%'>
310
																	</td>
311
																</tr>
316
															<table id="progholder" name="progholder" height='15' width='630' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
317
																<td background="./themes/the_wall/images/misc/bar_gray.gif" valign="top" align="left">
318
																	<img src='./themes/the_wall/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
319
																</td>
312 320
															</table>
313 321
														</td>
314
														<td width="5" height="15" background="./themes/{$g['theme']}/images/misc/bar_right.gif" align="top">
322
														<td background="./themes/the_wall/images/misc/bar_right.gif" height='15' width='5'>
315 323
														</td>
316 324
													</tr>
317 325
												</table>

Also available in: Unified diff