@echo off ::########################################## ::###########Get Parameters################# ::########################################## ::###ADD RESELLER##### if %reseller%==add ( CALL :addip CALL :adduser CALL :createvhostfile CALL :addvhostconfig CALL :createHTML CALL :resetfunction ) ::###REMOVE RESELLER##### if %reseller%==remove ( CALL :removevhostfile CALL :removevhostconfig CALL :removecertificate CALL :removeHTML CALL :removeip CALL :removeuser CALL :resetfunction ) ::###CREATE CERT##### if %reseller%==certonly ( CALL :createcertificate CALL :resetfunction ) ::###RESTART APACHE##### if %reseller%==restart ( CALL :restart CALL :resetfunction ) ::pause ::echo. echo ------------------------------- echo [END OF SCRIPT] echo ------------------------------- echo. ENDLOCAL GOTO:EOF ::########################################## ::###########Create Vhost File############## ::########################################## :createvhostfile echo ------------------------------- echo CREATING VIRTUAL HOST FILE. echo ------------------------------- copy template-vhosts.conf %subdomain%.%domain%.%TLD%.conf echo. echo ----- echo Virtual Host File Copied. echo. copy template-vhosts.conf %subdomain%.%domain%.%TLD%.conf cscript replace.vbs "%subdomain%.%domain%.%TLD%.conf" "[IP]" "%IP%" cscript replace.vbs "%subdomain%.%domain%.%TLD%.conf" "[SUBDOMAIN]" "%subdomain%" cscript replace.vbs "%subdomain%.%domain%.%TLD%.conf" "[DOMAIN]" "%domain%" cscript replace.vbs "%subdomain%.%domain%.%TLD%.conf" "[TLD]" "%TLD%" echo. echo ----- echo Virtual Host File Edited. echo. move /y %subdomain%.%domain%.%TLD%.conf .\conf\extra\resellers\%subdomain%.%domain%.%TLD%.conf echo. echo ----- echo Virtual Host File Moved. echo. goto :eof ::########################################## ::###########Remove Vhost File############### ::########################################## :removevhostfile echo ------------------------------- echo REMOVING VIRTUAL HOST FILE. echo ------------------------------- del .\conf\extra\resellers\%subdomain%.%domain%.%TLD%.conf /Q goto :eof ::########################################## ::###########Add to Vhost List############## ::########################################## :addvhostconfig echo ------------------------------- echo ADDING VIRTUAL HOST TO LIST. echo ------------------------------- copy /y .\conf\extra\chttpd-resellers.conf chttpd-resellers.conf cscript replace.vbs "chttpd-resellers.conf" "Include conf/extra/resellers/%subdomain%.%domain%.%TLD%.conf" "" cscript replace.vbs "chttpd-resellers.conf" "#[NEXT]" "Include conf/extra/resellers/%subdomain%.%domain%.%TLD%.conf VbCrLf#[NEXT]" cscript replace-VbCrLf.vbs "chttpd-resellers.conf" "VbCrLf" "" move /y chttpd-resellers.conf .\conf\extra\chttpd-resellers.conf echo. echo ----- echo Reseller VHOST Entry Added. echo. goto :eof ::########################################## ::###########Remove From Vhost List######### ::########################################## :removevhostconfig echo ------------------------------- echo REMOVING VIRTUAL HOST FROM LIST. echo ------------------------------- copy /y .\conf\extra\chttpd-resellers.conf chttpd-resellers.conf cscript replace.vbs "chttpd-resellers.conf" "Include conf/extra/resellers/%subdomain%.%domain%.%TLD%.conf" "" move /y chttpd-resellers.conf .\conf\extra\chttpd-resellers.conf echo. echo ----- echo Removed VHOST Entry. echo. goto :eof ::########################################## ::###########ADD IP######################### ::########################################## :addip echo ------------------------------- echo ADDING NEW IP. echo ------------------------------- echo ----- echo Confirming IP Available. echo. ping %IP% wmic /node:%webserver% process call create "netsh interface ip add address name="%nic%" addr=%IP% mask=255.255.0.0" echo. echo ----- echo Confirming IP Addeded to %newserver%. echo. ping %IP% echo. echo ----- echo IP Added to %newserver%. echo. goto :eof ::########################################## ::###########REMOVE IP###################### ::########################################## :removeip echo ------------------------------- echo REMOVING IP. echo ------------------------------- wmic /node:%webserver% process call create "netsh interface ip delete address name="%nic%" addr=%IP%" echo ----- echo Confirming IP Removed. echo. ping %IP% goto :eof ::########################################## ::###########CREATE SSL############## ::########################################## :createcertificate echo ------------------------------- echo CREATING SSL CERTIFICATE. echo ------------------------------- @echo off copy .\bin\template-openssl.conf %URL%-openssl.conf cscript replace.vbs "%URL%-openssl.conf" "[url]" "%url%" cscript replace.vbs "%URL%-openssl.conf" "[password]" "%password%" cscript replace.vbs "%URL%-openssl.conf" "[country]" "%country%" cscript replace.vbs "%URL%-openssl.conf" "[state]" "%state%" cscript replace.vbs "%URL%-openssl.conf" "[city]" "%city%" cscript replace.vbs "%URL%-openssl.conf" "[company]" "%company%" cscript replace.vbs "%URL%-openssl.conf" "[unit]" "%unit%" cscript replace.vbs "%URL%-openssl.conf" "[email]" "%email%" move /y %URL%-openssl.conf .\bin\%URL%-openssl.conf set OPENSSL_CONF=./bin/%URL%-openssl.conf if not exist .\conf\ssl.crt mkdir .\conf\ssl.crt if not exist .\conf\ssl.key mkdir .\conf\ssl.key bin\openssl req -new -out %url%.csr bin\openssl rsa -in privkey.pem -out %url%.key -passin pass:%password% bin\openssl x509 -in %url%.csr -out %url%.crt -req -signkey %url%.key -days 365 set OPENSSL_CONF= del ./bin/%URL%-openssl.conf del .rnd del privkey.pem :: del server.csr move /y %URL%.crt .\conf\ssl.crt move /y %URL%.key .\conf\ssl.key move /y %URL%.csr .\conf\ssl.csr echo. echo ----- echo The certificate was provided. echo. goto :eof ::########################################## ::###########Remove Certificates############ ::########################################## :removecertificate echo ------------------------------- echo REMOVING CERTIFICATES. echo ------------------------------- del .\conf\ssl.crt\%URL%.crt /Q del .\conf\ssl.key\%URL%.key /Q del .\conf\ssl.csr\%URL%.csr /Q goto :eof ::########################################## ::###########CREATE HTML#################### ::########################################## :createHTML echo ------------------------------- echo COPYING HTML TO NEW DIRECTORY echo ------------------------------- MD C:\Inetpub\%location%\resellers\%url%\ xcopy "C:\Inetpub\%location%\resellers\template.syncweb.net" "C:\Inetpub\%location%\resellers\%url%" /s /y echo ------------------------------- echo UPDATING HTML & PHP FOR NEW COMPANY echo ------------------------------- :filelist dir "%directory%" /b *.htm | find ".htm" > htmlLIST.txt dir "%directory%" /b *.html | find ".html" >> htmlLIST.txt dir "%directory%" /b *.php | find ".php" >> htmlLIST.txt ::set directory=%directory%%url%\ set old=[url] set new=%url% CALL :change set old=syncweb.net set new=%domain%.%TLD% CALL :change set old=[phone] set new=%phone% CALL :change set old=[fax] set new=%fax% CALL :change set old=[address] set new=%address% CALL :change set old=[zip] set new=%zip% CALL :change set old=[servicename] set new=%servicename% CALL :change set old=[state] set new=%state% CALL :change set old=[city] set new=%city% CALL :change set old=[company] set new=%company% CALL :change set old=[supportemail] set new=%supportemail% CALL :change set old=[salesemail] set new=%salesemail% CALL :change GOTO:EOF :change for /f "tokens=*" %%H in (htmlLIST.txt) do call :sub1 %%H cls goto :eof :sub1 echo Replacing %old% with %new% echo %directory%%1 cscript replace.vbs "%directory%%1" "%old%" "%new%" goto :eof ::########################################## ::###########REMOVE HTML#################### ::########################################## :removeHTML echo ------------------------------- echo REMOVING HTML DIRECTORY echo ------------------------------- RMDIR C:\Inetpub\%location%\resellers\%url% /s /q goto :eof ::########################################## ::###########ADD USER####################### ::########################################## :adduser echo ------------------------------- echo ADDING APACHE USER. echo ------------------------------- cd C:\apachefriends\xampp\apache\bin htpasswd -b ../../security/xampp.users %username% %password% cd C:\apachefriends\xampp\apache cscript replace.vbs "..\security\xampp.groups" "%username% " "" cscript replace.vbs "..\security\xampp.groups" "Resellers:" "Resellers: %username%" goto :eof ::########################################## ::###########REMOVE USER#################### ::########################################## :removeuser echo ------------------------------- echo REMOVING APACHE USER. echo ------------------------------- cd C:\apachefriends\xampp\apache\bin htpasswd -b -D ../../security/xampp.users %username% %password% cd C:\apachefriends\xampp\apache cscript replace.vbs "..\security\xampp.groups" "%username% " "" goto :eof ::########################################## ::###########RESTART APACHE############## ::########################################## :restart echo ------------------------------- echo RESTARTING APACHE echo ------------------------------- net stop apache2.2 net start apache2.2 ::apache -n "apache2.2" -k restart ::apache -n "apache" -k stop goto :eof ::########################################## ::###########RESET VARIABLES################ ::########################################## :resetfunction echo ------------------------------- echo RESETING VARIABLES echo ------------------------------- set reseller= set location= set directory= set url= set subdomain= set domain= set TLD= set IP= set webserver= set nic= set username= set password= set country= set state= set city= set company= set unit= set email= set phone= set fax= set address= set zip= set servicename= set supportemail= set salesemail= echo Reset Complete. GOTO:EOF :: DONE