Oily Rag 1: CD Part 2: Difference between revisions
(New page: {{Uc nav oily rag 1 CD}} '''USCD1 Plugin''' On the previous page I have shown how easy it is to modify Uniform Server 3.5-Apollo and have it running from a CD. You currently have a collec...) |
Upazixorys (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
=[http://uvetysudema.co.cc UNDER COSTRUCTION, PLEASE SEE THIS POST IN RESERVE COPY]= | |||
{{Uc nav oily rag 1 CD}} | {{Uc nav oily rag 1 CD}} | ||
'''USCD1 Plugin''' | '''USCD1 Plugin''' | ||
Line 11: | Line 12: | ||
Currently we have a collection of files in folder '''uscd''' these I have listed below. During switching these files are copied to the location shown. While copying each file its name is changed back to the original. To perform this copying we use two batch files '''cd_mode_switch.bat''' copies only the new files and '''us_mode_switch.bat''' copies original (old) files, thus switching between CD and normal Uniform Server mode respectively. | Currently we have a collection of files in folder '''uscd''' these I have listed below. During switching these files are copied to the location shown. While copying each file its name is changed back to the original. To perform this copying we use two batch files '''cd_mode_switch.bat''' copies only the new files and '''us_mode_switch.bat''' copies original (old) files, thus switching between CD and normal Uniform Server mode respectively. | ||
{|cellpadding= | {|cellpadding="4" cellspacing="1" style="background:#eeeeee" | ||
|- | |- | ||
!style= | !style="background:#d7d7d7"|File | ||
!style= | !style="background:#d7d7d7"|Location | ||
! | !  | ||
|-valign= | |-valign="top" | ||
|style= | |style="background:#e6e6e6"|new_httpd.conf<br> | ||
old_httpd.conf | old_httpd.conf | ||
|style= | |style="background:#e6e6e6"|*\Uniform Server\udrive\usr\local\apache2\conf | ||
|valign= | |valign="middle"|Apache | ||
|-valign= | |-valign="top" | ||
|style= | |style="background:#f5f5f5"|new_my-small.cnf<br> | ||
old_my-small.cnf | old_my-small.cnf | ||
|style= | |style="background:#f5f5f5"|*\Uniform Server\udrive\usr\local\mysql\bin | ||
|valign= | |valign="middle"|MySQL | ||
|-valign= | |-valign="top" | ||
|style= | |style="background:#e6e6e6"|new_php.ini<br> | ||
old_php.ini | old_php.ini | ||
|style= | |style="background:#e6e6e6"|*\Uniform Serve\udrive\usr\local\php | ||
|valign= | |valign="middle"|PHP | ||
|-valign= | |-valign="top" | ||
|style= | |style="background:#f5f5f5"|new_config.inc.php<br> | ||
old_config.inc.php | old_config.inc.php | ||
|style= | |style="background:#f5f5f5"|*\Uniform Serve\udrive\home\admin\www\phpMyAdmin | ||
|valign= | |valign="middle"|phpMyAdmin | ||
|-valign= | |-valign="top" | ||
|style= | |style="background:#e6e6e6"|new_Server_Start.bat<br> | ||
old_Server_Start.bat | old_Server_Start.bat | ||
|style= | |style="background:#e6e6e6"|*\Uniform Server | ||
|valign= | |valign="middle"|UniServer Control | ||
|-valign= | |-valign="top" | ||
|style= | |style="background:#f5f5f5"|new_Stop.bat<br> | ||
old_Stop.bat | old_Stop.bat | ||
|style= | |style="background:#f5f5f5"|*\Uniform Server | ||
|valign= | |valign="middle"|UniServer Cont | ||
|} | |} | ||
Line 62: | Line 63: | ||
Before looking at the batch files an understanding of the commands used will make the whole process easier to understand. | Before looking at the batch files an understanding of the commands used will make the whole process easier to understand. | ||
{| cellpadding= | {| cellpadding="4" cellspacing="1" style="background:#000000;" | ||
|- style= | |- style="background:#e8e8e8;" | ||
!Batch Command | !Batch Command | ||
!Explanation | !Explanation | ||
|- style= | |- style="background:#f5f5f5;" | ||
| | | | ||
<pre style="border:none"> | |||
pushd %~dp0 | pushd %~dp0 | ||
.... | .... | ||
Line 74: | Line 75: | ||
.... | .... | ||
popd | popd | ||
</pre> | |||
| | | | ||
* '''pushd''' Pushes the Current Directory onto a memory stack (Where you came from). | * '''pushd''' Pushes the Current Directory onto a memory stack (Where you came from). | ||
* '''%~dp0''' This forces the current working directory to the current location of the batch file you are running. It includes the full path not just the drive letter (if its remote that’s included). | * '''%~dp0''' This forces the current working directory to the current location of the batch file you are running. It includes the full path not just the drive letter (if its remote that’s included). | ||
* '''popd''' Restores the previously pushed directory (effectively returns control back to whatever call the batch file). | * '''popd''' Restores the previously pushed directory (effectively returns control back to whatever call the batch file). | ||
|-style= | |-style="background:#f5f5f5;" | ||
| | | | ||
<pre style="border:none"> | |||
COPY switches source destination | COPY switches source destination | ||
</pre> | |||
| | | | ||
'''COPY switches source destination''' Copies one or more files to another location. | '''COPY switches source destination''' Copies one or more files to another location. | ||
Line 92: | Line 93: | ||
'''''Switches'':''' '''/Y''' Suppresses prompting to confirm you want to overwrite an existing destination file. | '''''Switches'':''' '''/Y''' Suppresses prompting to confirm you want to overwrite an existing destination file. | ||
|-style= | |-style="background:#f5f5f5;" | ||
| | | | ||
<pre style="border:none"> | |||
..\folder\file_name | ..\folder\file_name | ||
..\..\folder\file_name | ..\..\folder\file_name | ||
</pre> | |||
| | | | ||
'''..\ not a DOS command''' Its a relative path name '''..\''' means move up one folder level '''..\..\''' move up two folder levels. | '''..\ not a DOS command''' Its a relative path name '''..\''' means move up one folder level '''..\..\''' move up two folder levels. | ||
Line 111: | Line 112: | ||
Double click on this file and you are back to a default installation of Uniform Server (Well the files we have been using). The above comments also apply to this file. | Double click on this file and you are back to a default installation of Uniform Server (Well the files we have been using). The above comments also apply to this file. | ||
{| cellpadding= | {| cellpadding="4" cellspacing="1" style="background:#000000;" | ||
|- style= | |- style="background:#e8e8e8;" | ||
!us_mode_switch.bat | !us_mode_switch.bat | ||
|- style= | |- style="background:#f5f5f5;" | ||
| | | | ||
<pre style="border:none"> | |||
rem File Name: us_mode_switch.bat | rem File Name: us_mode_switch.bat | ||
rem Location: Uniform Server\udrive\plugins\uscd1\uscd | rem Location: Uniform Server\udrive\plugins\uscd1\uscd | ||
Line 136: | Line 137: | ||
copy /Y old_Stop.bat ..\..\..\..\Stop.bat | copy /Y old_Stop.bat ..\..\..\..\Stop.bat | ||
rem == Apache | rem == Apache | ||
copy /Y old_httpd.conf ..\..\..\usr\local\apache2\conf\httpd.conf | copy /Y old_httpd.conf ..\..\..\usr\local\apache2\conf\httpd.conf" | ||
rem == MySQL | rem == MySQL | ||
copy /Y old_my-small.cnf ..\..\..\usr\local\mysql\bin\my-small.cnf | copy /Y old_my-small.cnf ..\..\..\usr\local\mysql\bin\my-small.cnf" | ||
rem == php | rem == php | ||
copy /Y old_php.ini ..\..\..\usr\local\php\php.ini | copy /Y old_php.ini ..\..\..\usr\local\php\php.ini" | ||
rem == phpMyAdmin | rem == phpMyAdmin | ||
copy /Y old_config.inc.php ..\..\..\home\admin\www\phpMyAdmin\config.inc.php | copy /Y old_config.inc.php ..\..\..\home\admin\www\phpMyAdmin\config.inc.php" | ||
echo. | echo. | ||
echo Switched to US Mode | echo Switched to US Mode | ||
Line 148: | Line 149: | ||
pause | pause | ||
popd | popd | ||
</pre> | |||
|} | |} | ||
Line 156: | Line 157: | ||
Double click on this file and you are ready to make a few beer coasters. It really does not require an explanation; you are copying new files and overwriting the old ones. | Double click on this file and you are ready to make a few beer coasters. It really does not require an explanation; you are copying new files and overwriting the old ones. | ||
{| cellpadding= | {| cellpadding="4" cellspacing="1" style="background:#000000;" | ||
|- style= | |- style="background:#e8e8e8;" | ||
!cd_mode_switch.bat | !cd_mode_switch.bat | ||
|- style= | |- style="background:#f5f5f5;" | ||
| | | | ||
<pre style="border:none"> | |||
rem File Name: cd_mode_switch.bat | rem File Name: cd_mode_switch.bat | ||
rem Location: Uniform Server\udrive\plugins\uscd1\uscd | rem Location: Uniform Server\udrive\plugins\uscd1\uscd | ||
Line 181: | Line 182: | ||
copy /Y new_Stop.bat ..\..\..\..\Stop.bat | copy /Y new_Stop.bat ..\..\..\..\Stop.bat | ||
rem == Apache | rem == Apache | ||
copy /Y new_httpd.conf ..\..\..\usr\local\apache2\conf\httpd.conf | copy /Y new_httpd.conf ..\..\..\usr\local\apache2\conf\httpd.conf" | ||
rem == MySQL | rem == MySQL | ||
copy /Y new_my-small.cnf ..\..\..\usr\local\mysql\bin\my-small.cnf | copy /Y new_my-small.cnf ..\..\..\usr\local\mysql\bin\my-small.cnf" | ||
rem == php | rem == php | ||
copy /Y new_php.ini ..\..\..\usr\local\php\php.ini | copy /Y new_php.ini ..\..\..\usr\local\php\php.ini" | ||
rem == phpMyAdmin | rem == phpMyAdmin | ||
copy /Y new_config.inc.php ..\..\..\home\admin\www\phpMyAdmin\config.inc.php | copy /Y new_config.inc.php ..\..\..\home\admin\www\phpMyAdmin\config.inc.php" | ||
echo. | echo. | ||
echo Switched to CD Mode | echo Switched to CD Mode | ||
Line 193: | Line 194: | ||
pause | pause | ||
popd | popd | ||
</pre> | |||
|} | |} | ||
Line 200: | Line 201: | ||
== us_mode.bat == | == us_mode.bat == | ||
An alternative method of running the above two files. | An alternative method of running the above two files. | ||
{| cellpadding= | {| cellpadding="4" cellspacing="1" style="background:#000000;" | ||
|- style= | |- style="background:#e8e8e8;" | ||
!us_mode.bat | !us_mode.bat | ||
|- style= | |- style="background:#f5f5f5;" | ||
| | | | ||
<pre style="margin:0;border:none"> | |||
rem Location: *\Uniform Server\udrive\plugins\uscd1 | rem Location: *\Uniform Server\udrive\plugins\uscd1 | ||
uscd\us_mode_switch.bat | uscd\us_mode_switch.bat | ||
</pre> | |||
|} | |} | ||
<br> | |||
{| cellpadding= | {| cellpadding="4" cellspacing="1" style="background:#000000;" | ||
|- style= | |- style="background:#e8e8e8;" | ||
!us_mode.bat | !us_mode.bat | ||
|- style= | |- style="background:#f5f5f5;" | ||
| | | | ||
<pre style="margin:0;border:none"> | |||
rem Location: Uniform Server | rem Location: Uniform Server | ||
udrive\plugins\uscd1\uscd\us_mode_switch.bat | udrive\plugins\uscd1\uscd\us_mode_switch.bat | ||
</pre> | |||
|} | |} | ||
Line 229: | Line 230: | ||
Another alternative method of running the above two main files. | Another alternative method of running the above two main files. | ||
{| cellpadding= | {| cellpadding="4" cellspacing="1" style="background:#000000;" | ||
|- style= | |- style="background:#e8e8e8;" | ||
!cd_mode.bat | !cd_mode.bat | ||
|- style= | |- style="background:#f5f5f5;" | ||
| | | | ||
<pre style="margin:0;border:none"> | |||
rem Location: *\Uniform Server\udrive\plugins\uscd1 | rem Location: *\Uniform Server\udrive\plugins\uscd1 | ||
uscd\cd_mode_switch.bat | uscd\cd_mode_switch.bat | ||
</pre> | |||
|} | |} | ||
<br> | |||
{| cellpadding= | {| cellpadding="4" cellspacing="1" style="background:#000000;" | ||
|- style= | |- style="background:#e8e8e8;" | ||
!cd_mode.bat | !cd_mode.bat | ||
|- style= | |- style="background:#f5f5f5;" | ||
| | | | ||
<pre style="margin:0;border:none"> | |||
rem Location: Uniform Server | rem Location: Uniform Server | ||
udrive\plugins\uscd1\uscd\cd_mode_switch.bat | udrive\plugins\uscd1\uscd\cd_mode_switch.bat | ||
</pre> | |||
|} | |} | ||
== File Overview == | == File Overview == | ||
This shows where to place all the files. | This shows where to place all the files. | ||
{| cellpadding= | {| cellpadding="4" cellspacing="1" style="background:#000000;" | ||
|- style= | |- style="background:#e8e8e8;" | ||
!File Overview | !File Overview | ||
|- style= | |- style="background:#f5f5f5;" | ||
| | | | ||
<pre style="border:none"> | |||
Uniform Server | Uniform Server | ||
Line 276: | Line 277: | ||
old_config.inc.php us_mode_switch.bat new_httpd.conf old_httpd.conf | old_config.inc.php us_mode_switch.bat new_httpd.conf old_httpd.conf | ||
new_my-small.cnf old_my-small.cnf | new_my-small.cnf old_my-small.cnf | ||
</pre> | |||
|} | |} | ||
Revision as of 10:27, 24 November 2010
UNDER COSTRUCTION, PLEASE SEE THIS POST IN RESERVE COPY
Oily Rag 1: Introduction | CD Part 1 | CD Part 2 | CD Part 3 | CD Part 4 | CD Part 4 Scripts | CD Part 5 | CD Part 6 | Downloads |
Oily Rag: Be prepared to get your hands dirty. |
USCD1 Plugin
On the previous page I have shown how easy it is to modify Uniform Server 3.5-Apollo and have it running from a CD. You currently have a collection of old and new files neatly saved in folder uscd, we now put these to good use by creating a test plugin for UniServer.
Plugin
This plugin is not overly complex it allows you to switch Uniform Server to CD mode where you can burn your design and then switch back to standard mode. To achieve switching two batches files are required one for each mode. Our design needs a reference point allowing relative paths to be used. Uniform Server already provides a plugins folder which meets our requirements.
Files and location
Currently we have a collection of files in folder uscd these I have listed below. During switching these files are copied to the location shown. While copying each file its name is changed back to the original. To perform this copying we use two batch files cd_mode_switch.bat copies only the new files and us_mode_switch.bat copies original (old) files, thus switching between CD and normal Uniform Server mode respectively.
File | Location | |
---|---|---|
new_httpd.conf<br>
old_httpd.conf |
*\Uniform Server\udrive\usr\local\apache2\conf | Apache |
new_my-small.cnf<br>
old_my-small.cnf |
*\Uniform Server\udrive\usr\local\mysql\bin | MySQL |
new_php.ini<br>
old_php.ini |
*\Uniform Serve\udrive\usr\local\php | PHP |
new_config.inc.php<br>
old_config.inc.php |
*\Uniform Serve\udrive\home\admin\www\phpMyAdmin | phpMyAdmin |
new_Server_Start.bat<br>
old_Server_Start.bat |
*\Uniform Server | UniServer Control |
new_Stop.bat<br>
old_Stop.bat |
*\Uniform Server | UniServer Cont |
Preperation
Create a new folder uscd1 in folder *\Uniform Server\udrive\plugins now copy the folder uscd to uscd1.
- Folder uscd1: Will contain two new batch files cd_mode.bat and us_mode.bat these call batch files us_mode_switch.bat and cd_mode_switch.bat respectively. They can be moved to the top level folder (Uniform Server) each file contains a single line of code hence are easily modified to run the main switching batch files.
- Folder uscd: Will contain two new batch files cd_mode_switch.bat and us_mode_switch.bat these perform file copying and renaming. Strictly speaking these are the only two files required for switching.
Note: Using four files provides a flexible architecture I prefer to have all my control files located in the top level folder you can choose whatever suits your need better.
Batch file commands
Before looking at the batch files an understanding of the commands used will make the whole process easier to understand.
Batch Command | Explanation |
---|---|
<pre style="border:none"> pushd %~dp0 .... batch file code .... popd </pre> |
|
<pre style="border:none"> COPY switches source destination </pre> |
COPY switches source destination Copies one or more files to another location. Source: Complete path and name of the file to copy. Destination: Complete path and file name to where we wish to copy the above file. The file name can be different to that of the source file. (We use this to change names back to their originals) Switches: /Y Suppresses prompting to confirm you want to overwrite an existing destination file. |
<pre style="border:none"> ..\folder\file_name ..\..\folder\file_name </pre> |
..\ not a DOS command Its a relative path name ..\ means move up one folder level ..\..\ move up two folder levels. ..\folder_name\folder_name\file_name Move up one folder level and then start moving down following the folder names to the file name. Note: Relative to the current working directory (folder) as established above using pushd. |
us_mode_switch.bat
Double click on this file and you are back to a default installation of Uniform Server (Well the files we have been using). The above comments also apply to this file.
us_mode_switch.bat |
---|
<pre style="border:none"> rem File Name: us_mode_switch.bat rem Location: Uniform Server\udrive\plugins\uscd1\uscd rem Created By: UniCenter rem Comment: Run either directly or from folder Uniform Server using us_mode.bat rem Example plugin USCD1 3.5-Apollo rem Edited Last By: Mike Gleaves (Ric) rem 30-6-08 V1.0 rem Tutorial Oily Rag 1: CD Part 2
echo off cls rem === Set current working directory pushd %~dp0 rem === Copy original files back to server rem == Uniserver control copy /Y old_Server_Start.bat ..\..\..\..\Server_Start.bat copy /Y old_Stop.bat ..\..\..\..\Stop.bat rem == Apache copy /Y old_httpd.conf ..\..\..\usr\local\apache2\conf\httpd.conf" rem == MySQL copy /Y old_my-small.cnf ..\..\..\usr\local\mysql\bin\my-small.cnf" rem == php copy /Y old_php.ini ..\..\..\usr\local\php\php.ini" rem == phpMyAdmin copy /Y old_config.inc.php ..\..\..\home\admin\www\phpMyAdmin\config.inc.php" echo. echo Switched to US Mode echo. pause popd </pre> |
cd_mode_switch.bat
Double click on this file and you are ready to make a few beer coasters. It really does not require an explanation; you are copying new files and overwriting the old ones.
cd_mode_switch.bat |
---|
<pre style="border:none"> rem File Name: cd_mode_switch.bat rem Location: Uniform Server\udrive\plugins\uscd1\uscd rem Created By: UniCenter rem Comment: Run either directly or from folder Uniform Server using cd_mode.bat rem Example plugin USCD1 3.5-Apollo rem Edited Last By: Mike Gleaves (Ric) rem 30-6-08 V1.0 rem Tutorial Oily Rag 1: CD Part 2
echo off cls rem === Set current working directory pushd %~dp0 rem === Copy original files back to server rem == Uniserver control copy /Y new_Server_Start.bat ..\..\..\..\Server_Start.bat copy /Y new_Stop.bat ..\..\..\..\Stop.bat rem == Apache copy /Y new_httpd.conf ..\..\..\usr\local\apache2\conf\httpd.conf" rem == MySQL copy /Y new_my-small.cnf ..\..\..\usr\local\mysql\bin\my-small.cnf" rem == php copy /Y new_php.ini ..\..\..\usr\local\php\php.ini" rem == phpMyAdmin copy /Y new_config.inc.php ..\..\..\home\admin\www\phpMyAdmin\config.inc.php" echo. echo Switched to CD Mode echo. pause popd </pre> |
us_mode.bat
An alternative method of running the above two files.
us_mode.bat |
---|
<pre style="margin:0;border:none"> rem Location: *\Uniform Server\udrive\plugins\uscd1 uscd\us_mode_switch.bat </pre> |
<br>
us_mode.bat |
---|
<pre style="margin:0;border:none"> rem Location: Uniform Server udrive\plugins\uscd1\uscd\us_mode_switch.bat </pre> |
cd_mode.bat
Another alternative method of running the above two main files.
cd_mode.bat |
---|
<pre style="margin:0;border:none"> rem Location: *\Uniform Server\udrive\plugins\uscd1 uscd\cd_mode_switch.bat </pre> |
<br>
cd_mode.bat |
---|
<pre style="margin:0;border:none"> rem Location: Uniform Server udrive\plugins\uscd1\uscd\cd_mode_switch.bat </pre> |
File Overview
This shows where to place all the files.
File Overview |
---|
<pre style="border:none"> Uniform Server us_mode.bat Server_Start.bat cd_mode.bat Stop.bat uscd2.exe Uniform Server\udrive\plugins\uscd1 cd_mode.bat us_mode.bat Uniform Server\udrive\plugins\uscd1\uscd new_php.ini old_php.ini new_Server_Start.bat old_Server_Start.bat cd_mode_switch.bat new_Stop.bat old_Stop.bat new_config.inc.php old_config.inc.php us_mode_switch.bat new_httpd.conf old_httpd.conf new_my-small.cnf old_my-small.cnf </pre> |
How to use the plugin
Before running the servers it is good practice to run either us_mode.bat or cd_mode.bat.
- us_mode.bat If you are developing a web site this selects the normal Uniform Server mode.
- cd_mode.bat When you are ready to transfer the servers and site/s to a CD run this batch file to setup CD mode. There is no need to start the servers just copy folder Uniform Server and all its content to a CD.
Download
Download this overlay (plugin USCD1) file CD Part 2 copy the file to folder Uniform Server double click to extract the files. See above file overview for details of file locations.
What's next
The above is a solid foundation for producing a plugin, it can be used as is but lacks features that a real plugin should have. Part 3 revisits what we currently have and resolves these shortcomings.
Ric |