复制代码
- @echo off&title APMA Server
- mode con cols=45 lines=11
- setlocal enabledelayedexpansion
- color 0f
- ::***************************************
- ::Startup type: auto, demand
- set ApacheST=demand
- set MySQLST=demand
- ::***************************************
- ::Setting Apache port
- set port=80
- ::***************************************
- :pre
- echo APMA control panel
- echo ______________________________
- echo 丨Apache( ) 丨MySQL ( ) 丨
- echo 丨 7.Re/Start 丨 8.Re/Start 丨9.All Start
- echo 丨 4.Shut 丨 5.Shut 丨6.All Shut
- echo 丨 1.Monitor 丨 2.Password 丨3.Home
- echo 丨_____________丨_____________丨0.Uninstall
- echo Input:
- PUSHD ".\apache"
- if not exist .\install.lock (goto install)
- :main
- net start|findstr /i /c:"Apache_APMA" 1>nul 2>nul && set "buff=√" || set "buff=×"
- net start|findstr /i /c:"MySQL_APMA" 1>nul 2>nul && set "buf=√" || set "buf=×"
- cls
- echo APMA control panel
- echo ______________________________
- echo 丨Apache(!buff!) 丨MySQL (!buf!) 丨
- echo 丨 7.Re/Start 丨 8.Re/Start 丨9.All Start
- echo 丨 4.Shut 丨 5.Shut 丨6.All Shut
- echo 丨 1.Monitor 丨 2.Password 丨3.Home
- echo 丨_____________丨_____________丨0.Uninstall
- set "cho="
- set /p cho=Input:
- echo Waitting...
- if "!cho!"=="" goto main
- if "!cho!"=="2" goto resetpass
- if /i "!cho!"=="0" goto uninstall
- goto APMA!cho!
- exit
- :APMA1
- start .\bin\ApacheMonitor.exe
- goto main
- :APMA3
- start http://127.0.0.1:!port!
- goto main
- :APMA4
- net stop Apache_APMA 1>nul 2>nul && echo ------Succeed------ || echo ------Failed------
- goto main
- :APMA5
- net stop MySQL_APMA 1>nul 2>nul && echo ------Succeed------ || echo ------Failed------
- goto main
- :APMA6
- net stop Apache_APMA 1>nul 2>nul && echo ------Succeed------ || echo ------Failed------
- net stop MySQL_APMA 1>nul 2>nul && echo ------Succeed------ || echo ------Failed------
- goto main
- :APMA7
- net stop Apache_APMA 1>nul 2>nul
- net start Apache_APMA 1>nul 2>nul && echo ------Succeed------ || echo ------Failed------
- goto main
- :APMA8
- net stop MySQL_APMA 1>nul 2>nul
- net start MySQL_APMA 1>nul 2>nul && echo ------Succeed------ || echo ------Failed------
- goto main
- :APMA9
- net start Apache_APMA 1>nul 2>nul && echo ------Succeed------ || echo ------Failed------
- net start MySQL_APMA 1>nul 2>nul && echo ------Succeed------ || echo ------Failed------
- goto main
- :resetpass
- net stop MySQL_APMA 1>nul 2>nul
- cls
- echo ______________________________
- echo ^| ^|
- echo ### Reset MySQL password
- echo ^|______________________________^|.
- set "passnew="
- set /p passnew=-^> New password:
- CD "..\mysql\bin"
- start .\mysqld.exe --skip-grant-tables
- :authen
- echo use mysql;>.\temp.ini
- echo update user set %string%=password("!passnew!") where user="root";>>.\temp.ini
- echo flush privileges;>>.\temp.ini
- echo quit>>.\temp.ini
- mysql<.\temp.ini 1>nul 2>nul|| set string=authentication_string && goto authen
- del .\temp.ini
- mysqladmin.exe shutdown -uroot -p"!passnew!" 1>nul 2>nul|| echo Reset password failed && pause>nul && exit
- CD "..\..\apache"
- goto main
- :install
- sc query "Apache_APMA" 1>nul 2>nul && echo Service "Apache_APMA" already exists && pause>nul && exit
- cls
- echo ______________________________
- echo ^| ^|
- echo ### Install APMA
- echo ^|______________________________^|.
- echo Check port...
- netstat -ano|find "0.0.0.0:!port! " 1>nul 2>nul && echo Apache port is occupied, please release or modify the port && pause>nul && exit
- netstat -ano|find "0.0.0.0:3306 " 1>nul 2>nul && echo MySQL default port is occupied, please try again after the release port && pause>nul && exit
- CD ".\conf\"
- rename .\httpd.conf temp.conf
- echo Listen !port!>.\httpd.conf
- findstr /i /v "^listen.*[0-9]*$" <.\temp.conf>>.\httpd.conf
- del .\temp.conf
- CD "..\"
- set er=0
- .\bin\httpd.exe -k install -n Apache_APMA
- net start Apache_APMA 1>nul 2>nul || set er=1
- CD "..\mysql"
- .\bin\mysqld.exe --install MySQL_APMA --defaults-file="%CD%\my.ini"
- net start MySQL_APMA 1>nul 2>nul || set er=1
- if !er! equ 1 (echo Service failed to start & pause>nul & exit)
- sc config Apache_APMA start= !ApacheST! 1>nul 2>nul
- sc config MySQL_APMA start= !MySQLST! 1>nul 2>nul
- CD "..\apache"
- echo.>.\install.lock
- goto main
- :uninstall
- cls
- echo ______________________________
- echo ^| ^|
- echo ### Uninstall APMA
- echo ^|______________________________^|.
- net stop Apache_APMA 1>nul 2>nul
- .\bin\httpd.exe -k uninstall -n Apache_APMA
- net stop MySQL_APMA 1>nul 2>nul
- ..\mysql\bin\mysqld.exe --remove MySQL_APMA
- del .\install.lock
- exit
欢迎光临 批处理之家 (http://bbs.bathome.net/) | Powered by Discuz! 7.2 |