https://wiki.uniformserver.com/index.php?title=Virtual_Hosting:_Portable_PAC_issues&feed=atom&action=historyVirtual Hosting: Portable PAC issues - Revision history2024-03-28T08:57:34ZRevision history for this page on the wikiMediaWiki 1.41.0https://wiki.uniformserver.com/index.php?title=Virtual_Hosting:_Portable_PAC_issues&diff=3249&oldid=prevRic: New page: <span id="top"></span> <div style="padding:0;margin:0; border-bottom:3px inset #000000"> {| | MPG UniCenter || Virtual Hosting: [[Virtual Hosting: Home | Ho...2008-06-21T18:18:11Z<p>New page: <span id="top"></span> <div style="padding:0;margin:0; border-bottom:3px inset #000000"> {| | <a href="/File:Uc_small_logo.gif" title="File:Uc small logo.gif"> MPG UniCenter</a> || Virtual Hosting: [[Virtual Hosting: Home | Ho...</p>
<p><b>New page</b></p><div><span id="top"></span><br />
<div style="padding:0;margin:0; border-bottom:3px inset #000000"><br />
{| <br />
| [[Image:uc_small_logo.gif | MPG UniCenter]] ||<br />
Virtual Hosting: <br />
[[Virtual Hosting: Home | Home]] | <br />
[[Virtual Hosting: Name based | Name based]] |<br />
[[Virtual Hosting: PAC | PAC]] | <br />
[[Virtual Hosting: Browsers and PAC | Browsers and PAC]] | <br />
[[Virtual Hosting: Making it portable | Making it portable]] | <br />
[[Virtual Hosting: Portable PAC issues | Issues]] <br />
|}<br />
</div><br />
{| cellpadding="2"<br />
|<br />
__TOC__<br />
||<br />
'''PAC Portable Issues'''<br>'''Uniform Server 3.5-Apollo'''<br />
|}<br />
A few days after publishing a portable solution using PAC and Firefox I was a little surprised to be informed that my proposed solution does not work.<br />
<br />
These are a few examples of the problems reported:<br />
* An instance of so and so browser is running! The answer to this one is close all browsers down before running the portable one.<br />
* UniServer insists on running a PCs default browser when run, not a real problem close that browser down; start the portable one, type in appropriate URL and all will be OK.<br />
* Several users hacked UniServer’s start batch file to run both browser and UniServer with varying degrees of success, Fire fox cannot be found, Opera runs and does not find the redirect page.<br />
* One user even wanted to run the entire set-up when the USB is plugged in.<br />
<br />
The following attempts to address these issues.<br />
== What I Use ==<br />
I use XP-Home SP2 and as a matter of course just close internal browsers down. I have no problem with Uniform Server firing up the local browser just an irritation; close that down as well. With both browsers I had no problem with the DNS simulator.<br />
<br />
I do have a problem when both my favorite browsers come under the spotlight but try as I may I could not get Opera Portable to start-up with an external web page. Hence the following solution addresses the above problems using my preferred browser Firefox.<br />
<br />
'''''[[#top | Top]]'''''<br />
== Firefox the only portable solution ==<br />
<br />
=== Cannot find Firefox ===<br />
This is not a problem with Firefox but with batch files. In general most books state that a batch file will pick up its environment from the location from where it is run (i.e. drive letter and current folder). Now take a step back and read what I have written more importantly what is assumed.<br />
<br />
Take an extreme example I have a batch file named '''test.bat''' on G: drive this batch file contains the instruction '''set newdrive=%~dp0'''. I run test.bat, as expected will pick up the correct environment (i.e. drive letter and current folder).<br />
<br />
I have a second batch file '''test2.bat''' on drive Z: this contains a single instruction to run file test.bat. What will be the drive letter picked up by set newdrive=%~dp0 in test.batch? Confused!<br />
<br />
Good you are in keeping with XP, batch file test.bat is not run from drive G in reality its run from drive Z. Its all semantics but the bottom line it does not pick up drive G as expected but Z. Hence if you set a variable to the current drive expecting it to be set to G any reference to a file located on G will produce a not found error.<br />
<br />
OK! I lied XP is not confused, hidden is a very powerful concept; drive Z (or any other drive) can be located anywhere on a network. To run a program or batch file it is pulled into the current location hence an external file is referenced to this location. Knowing this you will understand why I call the following a magic bullet.<br />
<br />
==== Magic bullet ====<br />
To fix a reference points (where the file is physically located) for any batch file use the commands '''pushd''' and '''popd''' at the start and end of a batch respectively.<br />
<br />
'''''pushd'':''' Saves to memory where you have come from and then force the new location to be that of the current file.<br />
<br />
'''''popd'':''' This is the reverse of pushd, reads from memory where you came from and reinstates it.<br />
<br />
To pick up the current drive letter (where the batch file resides) use this:<br />
{| cellpadding="2" cellspacing="1" style="background:#000000;"<br />
|- style="background:#e8e8e8;"<br />
!How to obtain batch file drive letter<br />
|- style="background:#f5f5f5;"<br />
|<br />
<pre style="border:none"><br />
pushd %~dp0<br />
set current_drive=%~dp0<br />
....<br />
batch file code<br />
....<br />
popd<br />
</pre> <br />
|}<br />
<br />
'''''[[#top | Top]]'''''<br />
=== An instance of Firefox is already running ===<br />
Use pskill.exe in batch files to stop any currently running versions of Firefox. We want to use the portable version on our memory stick which uses the PAC file.<br />
<br />
== New batch files ==<br />
Create two new batch files (use existing ones as templates)to start and stop the servers, integrate the above two solutions.<br />
<br />
Files look like this additions are highlighted in bold:<br />
<br />
{| cellpadding="2" cellspacing="1" style="background:#000000;"<br />
|- style="background:#e8e8e8;"<br />
!Fire_fox_Server_Start.bat<br />
|- style="background:#f5f5f5;"<br />
|<br />
<pre style="border:none;padding:2px"><br />
: Name: Start Server File<br />
: Created By: The Uniform Server Development Team<br />
: Edited Last By: Olajide Olaolorun (empirex)<br />
: Comment: After start, go to apanel directly.<br />
: To Developers: Implemented %www%, and %apanel% :)<br />
: MPG Firefox portable mods 25-4-07<br />
@echo off<br />
<br />
rem use: start mysql console - to start mysql at server start and display console<br />
rem use: start mysql - to start mysql at server start<br />
rem use: start nomysql console - to display console<br />
</pre><br />
'''rem============ FIREFOX INFO ========================================='''<br><br />
'''rem Add these six lines. Change the paths as needed'''<br><br />
'''pushd %~dp0'''<br><br />
'''diskw\home\admin\program\pskill.exe firefox.exe c'''<br><br />
'''diskw\home\admin\program\pskill.exe FirefoxPortable.exe c'''<br><br />
'''set drive=%~d0'''<br><br />
'''set startfile=file:///%drive%\UniformServer\diskw\home\admin\www\redirect.html'''<br><br />
'''set browser=%drive%\portableapps\FirefoxPortable\FirefoxPortable.exe'''<br />
<pre style="border:none;padding:2px"><br />
diskw\home\admin\program\pskill.exe Apache.exe<br />
IF NOT ERRORLEVEL 1 goto started<br />
set Disk=%1<br />
IF "%Disk%"=="" set Disk=w<br />
rem create the disk<br />
subst %Disk%: "diskw"<br />
IF ERRORLEVEL 1 goto hint<br />
set apachepath=\usr\local\apache2\<br />
set apacheit=%Disk%:%apachepath%bin\Apache.exe -f %apachepath%conf\httpd.conf -d %apachepath%.<br />
set programit=%Disk%:\home\admin\program\<br />
set closeit=%programit%close.bat %Disk%<br />
<br />
%Disk%:<br />
cd \usr\local\php<br />
IF "%2"=="mysql" start \usr\local\mysql\bin\mysqld-opt.exe --defaults-file=/usr/local/mysql/bin/my-small.cnf<br />
CLS<br />
echo The server is working on the disk %Disk%:\ [http/127.0.0.1/apanel/]<br />
set www=\www\<br />
set apanel=\home\admin\www\<br />
</pre> <br />
'''rem======= FIREFOX INFO ================================='''<br><br />
'''rem 1) Comment out line add new line to start Firefox'''<br><br />
'''rem 2) Starts FF with file specified'''<br><br />
'''<nowiki>:</nowiki>start %apanel%\redirect.html'''<br><br />
'''start %browser% %startfile%'''<br />
<pre style="border:none;padding:2px"><br />
IF "%3"=="console" goto console<br />
start %programit%uniserv.exe "%apacheit%" "%closeit%"<br />
goto end<br />
:console<br />
%apacheit%<br />
%closeit%<br />
goto end<br />
:hint<br />
CLS<br />
echo The disk %Disk% is busy. Use 'Disk Start.vbs' [disk letter]<br />
goto pause<br />
:started<br />
CLS<br />
echo ERROR!!!<br />
echo One of the instances of Apache server is started. Use Stop.bat<br />
:pause<br />
echo .<br />
pause<br />
:end<br />
</pre> <br />
'''rem============ FIREFOX INFO =========================='''<br><br />
'''popd'''<br />
|}<br />
<br />
The first line in bold may not be required!<br />
<br />
{| cellpadding="2" cellspacing="1" style="background:#000000;"<br />
|- style="background:#e8e8e8;"<br />
!Fire_fox_Stop.bat<br />
|- style="background:#f5f5f5;"<br />
|<br />
<pre style="border:none;padding:2px"><br />
: Name: Stop Server File<br />
: Created By: The Uniform Server Development Team<br />
: Edited Last By: Olajide Olaolorun (empirex)<br />
: Comment: Tara's new syetm of shutting down the server<br />
: To Developers: Implemented a new system of server shutdown<br />
: MPG Firefox portable mods 25-4-07<br />
<br />
@echo off<br />
diskw\home\admin\program\pskill.exe Apache.exe c<br />
</pre> <br />
'''diskw\home\admin\program\pskill.exe firefox.exe c'''<br><br />
'''diskw\home\admin\program\pskill.exe FirefoxPortable.exe c'''<br />
<pre style="border:none;padding:2px"><br />
if errorlevel 2 goto :PAUSE<br />
<br />
:PAUSE<br />
echo .<br />
pause<br />
<br />
:END<br />
</pre> <br />
|}<br />
<br />
Save the fies in folder '''Uniform Server''' <br />
<br />
'''''[[#top | Top]]'''''<br />
== Auto Run ==<br />
Check you can start and stop the server using the above batch file. Auto run uses the start batch file. You need to create a file named '''autorun.inf''' in the root folder of you memory stick. The one I used for testing is shown below:<br />
<br />
{| cellpadding="2" cellspacing="1" style="background:#000000;"<br />
|- style="background:#e8e8e8;"<br />
!autorun.inf<br />
|- style="background:#f5f5f5;"<br />
|<br />
<pre style="border:none;padding:2px"><br />
[autorun]<br />
open=UniformServer\Fire_fox_Server_Start.bat<br />
action=Launch UniformServer\Fire_fox_Server_Start.bat<br />
label=MPG<br />
</pre> <br />
|}<br />
<br />
When your memory stick is plugged in you will receive the following message just click OK:<br />
<br />
''Launch '''UniformServer\Fire_fox_Server_Start.bat''' using the program provided on the device''<br />
<br />
== Conclusion ==<br />
The above is not a definitive guide however it will allow you to experiment. The paths will need changing to meet your file structure.<br />
<br />
'''''[[#top | Top]]'''''<br />
<br />
----<br />
<br />
{| <br />
| [[Image:uc_small_logo.gif]] || [[User:Ric|Ric]]<br />
|}<br />
<br />
<br />
[[Category: UniCenter]]<br />
[[Category: Support]]<br />
[[Category: New Users]]</div>Ric