Old:Bugs 3.5-Apollo: Server Start bat: Difference between revisions

From The Uniform Server Wiki
Jump to navigation Jump to search
(Punctuation and grammatical changes.)
m (BobS moved page Bugs 3.5-Apollo: Server Start bat to Old:Bugs 3.5-Apollo: Server Start bat without leaving a redirect)
 
(No difference)

Latest revision as of 12:23, 21 June 2013

Uniform Server 3.5-Apollo known bugs or issues.

Server_Start.bat

Bug fix: reinstate %2

File: Server_Start.bat
Location: *\Uniform Server

Problem: Parameter %2 is not checked, preventing disk_start.vbs running correctly. Redundant %3 parameter! Solution: Reinstate %2 checking and use %3 to open a command line prompt.

The third parameter %3 (Console) seems to be redundant; no idea what its original purpose was. When run, it just leaves the command prompt open, which is of little use.

Proposal: let this open a command prompt accessing the MySQL bin folder will allow command line control of the MySQL server using mysql.exe and mysqladmin.exe. I have taken the opportunity to add comments, cleaned-up the script and changed order of commands slightly.

Enhancement: Enclose batch commands between pushd %~dp0 and popd forces current working directory to the folder a batch file is located in. On completion restores original calling working directory. Allows remote processes to start servers.

Proposed changes:

rem Name: Server_Start.bat
rem Location: Uniform Server
rem Created By: The Uniform Server Development Team
rem Edited Last By: Olajide Olaolorun (empirex)
rem Comment: After start, go to apanel directly.
rem To Developers: Implemented %www%, and %apanel% :)
rem Proposed mods MPG 14-4-2008
rem Proposed enhancement MPG 3-7-08

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

rem  Command line parameters:
rem  Server_Start.bat %1 %2 %3
rem  %1 = Drive letter to use
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.
udrive\home\admin\program\pskill.exe Apache.exe
if errorlevel 2 goto :PAUSE
if not errorlevel 1 goto :STARTED

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

rem ### Drive was created. 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

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

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

:PAUSE
echo .
pause

:END

rem restore original working directory
popd

Download

Download this file Server_Start.bat.txt save as Server_Start.bat and copy to the folder Uniform Server.

Allow it to overwrite the existing file.

Forum reference

Additional information or background can be found on these forum pages.

None

Proposed solution

See above.



Ric