Oily Rag 1: Dedicated drive USB

Oily Rag: Be prepared to get your hands dirty.

Dedicated drive

Running Uniform Server on a dedicated drive is extremely easy. No need to run as a service, removes the need for a virtual drive. This gives it a slight speed advantage when run on a USB stick or separate partition on a hard drive or even a separate hard drive.

Operating Modes

I like to think in terms of operating modes the current download of Uniform Server 3.5-Apollo by default provides standard and service modes with a little tweaking CD and dedicated drive modes are possible.

The following table list the main differences.

Mode Comment

Standard

The servers can be run on any read/write device (Hard disk, USB stick) from any folder.
Creates a Virtual drive to make this possible.
Reference: Installing server

Service

The servers can be run as a service on any hard disk, from any folder.
Absolute paths eliminates the need for a Virtual drive.
Reference: See installing as a service

CD

The servers and sites can be run from a CD
Creates a Virtual drive and temporary folder on C drive to make this possible.
Reference: CD series

Dedicated Drive

The servers can be run on any read/write device (Hard disk, USB stick) from it’s top level (root).
Eliminates the need for a Virtual drive.
Reference: This write-up

Top

Root relative paths

With the exception of service mode (absolute paths), all paths within Uniform Server are root relative meaning they are referenced from the top of the drive. It’s this in association with a virtual drive that gives Uniform Server its portability.

If Uniform Server is forced to run at root level there is no need to create a virtual drive so long as the drive letter it is running on is passed down to its scripts.

Sounds complicated! All that is required are minor modifications to both the start and stop batch files as follows:

Note 1: This assumes you have applied the complete bug fix! (See summary)

Note 2: These new batch files are independent of the main batch files allowing them to be included as enhancements.

Top

New batch files

The new batch files hdusb_server_start.bat and hdusb_server_stop.bat are based on originals only minor modification are required. These two new batch files are placed in folder *\Uniform Server\udrive this makes installing the servers extremely easy.

Top

hdusb_server_start.bat

Set the current drive letter

rem set current drive letter
set Disk=%~d0
set Disk=%Disk:~0,1%

No need to check drive letter in use or create a drive or provide an hint remove these lines:

rem ### Apache not running. Check for drive letter if not set (%1) use default.
set Disk=%1
if "%Disk%"=="" set Disk=w

rem ### Create the virtual disk, if it fails go to Hint
subst %Disk%: "udrive"
if errorlevel 1 goto :HINT

:HINT
CLS
echo The disk %Disk% is busy. Use start.bat [disk letter]
goto :PAUSE

There is a single line now with an incorrect path remove this udrive\ from the path.

The modified batch file as follows:

@echo off
rem working directory current folder 
pushd %~dp0

rem set current drive letter
set Disk=%~d0
set Disk=%Disk:~0,1%

rem  Command line parameters:
rem  Server_Start.bat %1 %2 %3
rem  %1 = Drive letter to use - Use a dummy drive letter
rem  %2 = mysql (run MySql server) or nomysql (do not run MySql server)
rem  %3 = console (Open a command prompt at folder MySQL Bin)
rem Note: If using %2 you must set a value for %1
rem Note: If using %3 you must set values for %1 and %2
rem Note: Default, uses drive W, runs the MySQL server and does not a command prompt.

rem ### Is Apache running if it is jump to STARTED 
rem ### First check for system error jump to Pause allows error message to be displayed.
home\admin\program\pskill.exe Apache.exe
if errorlevel 2 goto :PAUSE
if not errorlevel 1 goto :STARTED

rem ### Create variables for paths and programs 
set apachepath=\usr\local\apache2\
set apacheit=%Disk%:%apachepath%bin\Apache.exe -f %apachepath%conf\httpd.conf -d %apachepath%.
set programit=%Disk%:\home\admin\program\
set closeit=%programit%close.bat %Disk%

rem ### Change path to PHP - Required for running scripts
%Disk%:
cd \usr\local\php

rem ### Provide feedback to user
CLS
echo The server is working on the disk %Disk%:\ [http/127.0.0.1/apanel/]

rem ### Start Apache server
start %programit%uniserv.exe "%apacheit%" "%closeit%"

rem ### Start Apanel
start \home\admin\www\redirect.html

rem ### Start MySQL server - skip if requested not to start (%2)
if "%2"=="nomysql" goto :NOMYSQL
start \usr\local\mysql\bin\mysqld-opt.exe --defaults-file=/usr/local/mysql/bin/my-small.cnf
:NOMYSQL

rem ### Does user want to run a command prompt, if not END 
if "%3"=="console" goto :CONSOLE
goto :END

:CONSOLE
rem ### User wants to run a command prompt. Opens in MySQL bin
rem ### Allows command clients to be used (musql.exe and mysqladmin.exe ) 
%Disk%:
cd \usr\local\mysql\bin
start cmd.exe
goto :END

:STARTED
CLS
echo ERROR!!! 
echo One of the instances of Apache server is started. Use hdusb_server_stop.bat

:PAUSE
echo .
pause

:END

rem restore original working directory
popd

Top

hdusb_server_stop.bat

This batch file requires only a path change as follows:

pushd %~dp0

rem Stop Apache indirectly stops MySQL
:udrive\home\admin\program\pskill.exe Apache.exe c

rem Stop Apache indirectly stops MySQL changed path
home\admin\program\pskill.exe Apache.exe c

rem ### Check for system error jump to Pause allows error message to be displayed.
if errorlevel 2 goto :PAUSE
goto :END
:PAUSE
echo .
pause

:END
rem restore original working directory
popd

Top

Summary

I have included these two batch files in the combined bug fix they make a niece enhancement to Uniform Server.

Top

How to install

  1. Extract Uniform Server 3.5-Apollo to a folder of your choice
  2. Download a copy of the combined bug fix save it to folder Uniform Server
  3. Run the file downloaded.
  4. Copy contents of folder udrive to top level of your dedicated drive or USB stick.

Conclusion

Any batch files that are normally placed in folder Uniform Server need to be moved, either to udrive before copying to root alternatively copied directly to root. If these batch files contain udrive in any path remove it the same applies to plugins.

Top


  Ric