@echo off
rem Datei CreateVirtualWeLearn.cmd
setlocal
rem EVENTUELL ANPASSUNG ERFORDERLICH: Originalinstallation
set wl_install0=C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\WeLearn2
rem Wurzelverzeichnis fuer alle virtuellen WeLearn-Server
rem Namen ev. kuerzen bei zu langen Dateinamen in CPS-Paketen
set wl_drive=C:
set wl_mount=WL-Mount
set wl_dir=WL
set wl_base=%wl_drive%\%wl_mount%\%wl_dir%
rem WeLearn Originalinstallation gefunden?
if not exist "%wl_install0%\configurator.bat" goto no_WeLearn
if not exist "%wl_install0%\configurator.sh" goto no_WeLearn
echo ...
echo WeLearn Basisinstallation wurde gefunden unter
echo %wl_install0%
echo ...
rem Gewaehltes Laufwerk vorhanden
if not exist %wl_drive% goto no_drive
set wl_virtualserver=%1
rem Default-Annahmen fuer 2. Parameter und Prefix fuer Verzeichnisse
set wl_context=WeLearn2
if not ["%2"]==[""] set wl_context=%2
set wl_contextUS=
if not ["%wl_context%"]==["WeLearn2"] set wl_contextUS=%wl_context%_
rem Basisverzeichnisse und Basisdaten einrichten falls noch nicht vorhanden
if not exist "%wl_drive%\%wl_mount%" md "%wl_drive%\%wl_mount%"
if not exist "%wl_base%" md "%wl_base%"
if not exist "%wl_base%\KeyStore" md "%wl_base%\KeyStore"
rem Erzeugen von web.xml
if exist "%wl_base%\web.xml" goto webxml_ok
echo ^ >"%wl_base%\web.xml"
echo ^ >>"%wl_base%\web.xml"
echo ^ ^index.html^ ^ >>"%wl_base%\web.xml"
echo ^ >>"%wl_base%\web.xml"
:webxml_ok
rem Default Webserver anlegen
if not exist "%wl_base%\default" md "%wl_base%\default"
if not exist "%wl_base%\default\webapps" md "%wl_base%\default\webapps"
if not exist "%wl_base%\default\webapps\ROOT" md "%wl_base%\default\webapps\ROOT"
if not exist "%wl_base%\default\webapps\ROOT\WEB-INF" md "%wl_base%\default\webapps\ROOT\WEB-INF"
if not exist "%wl_base%\default\webapps\ROOT\WEB-INF\web.xml" copy "%wl_base%\web.xml" "%wl_base%\default\webapps\ROOT\WEB-INF" >nul
rem Index.html schon vorhanden? Wenn nicht, Platzhalter erstellen
if exist "%wl_base%\default\webapps\ROOT\index.html" goto index_html_ok
echo ^ ^
^WeLearn Server Overview^ ^ ^ >"%wl_base%\default\webapps\ROOT\index.html"
echo Verteilerseite – in Arbeit >>"%wl_base%\default\webapps\ROOT\index.html"
echo ^ ^ >>"%wl_base%\default\webapps\ROOT\index.html"
:index_html_ok
rem Ueberpruefen Parameter 1
if ["%wl_virtualserver%"]==[""] goto no_parameters
if ["%wl_virtualserver%"]==["default"] goto no_default
if ["%wl_virtualserver%"]==["Default"] goto no_default
if ["%wl_virtualserver%"]==["DEFAULT"] goto no_default
rem Wurzelverzeichnis fuer neuen virtuellen WeLearn-Server erstellen
set wl_VirtDir=%wl_base%\%wl_virtualserver%
rem Basisverzeichnisse und Basisdaten anlegen
if not exist "%wl_VirtDir%" md "%wl_VirtDir%"
if not exist "%wl_VirtDir%\webapps" md "%wl_VirtDir%\webapps"
if not exist "%wl_VirtDir%\webapps\ROOT" md "%wl_VirtDir%\webapps\ROOT"
if not exist "%wl_VirtDir%\webapps\ROOT\WEB-INF" md "%wl_VirtDir%\webapps\ROOT\WEB-INF"
if not exist "%wl_VirtDir%\webapps\ROOT\WEB-INF\web.xml" copy "%wl_base%\web.xml" "%wl_VirtDir%\webapps\ROOT\WEB-INF\" >nul
rem Zusaetzliche Verzeichnisse des virtuellen WeLearn-Servers errichten
if not exist "%wl_VirtDir%\%wl_contextUS%Auditing" md "%wl_VirtDir%\%wl_contextUS%Auditing"
if not exist "%wl_VirtDir%\%wl_contextUS%DiskPmRoot" md "%wl_VirtDir%\%wl_contextUS%DiskPmRoot"
if not exist "%wl_VirtDir%\%wl_contextUS%Uploads" md "%wl_VirtDir%\%wl_contextUS%Uploads"
rem Installation neues WeLearn oder Update ????????????????????????????
if exist "%wl_VirtDir%\webapps\%wl_context%" goto update
rem Code fuer Installation -------------------------------------------------------------------------------------
rem Warnung wegen Tomcat nur wenn nicht der erste Context eines damit neuen virtuellen Servers
if not exist "%wl_VirtDir%\webapps\ROOT\index.html" goto first_context
rem Warnung, ob Tomcat laeuft
echo ACHTUNG: Falls Tomcat aktiv ist, darf diese Installation
echo nicht durchgefuehrt werden.
echo Brechen Sie in diesem Fall das Skript mit ^^C
echo = "Ctrl C" oder auf deutschen Tastaturen mit "Strg C" ab.
echo Stoppen Sie Tomcat z.B. mit "net stop tomcat5" und
echo starten Sie "CreateVirtualWeLearn" erneut.
pause
:first_context
md "%wl_VirtDir%\webapps\%wl_context%"
rem Daten von der Originalinstallation kopieren
"%SystemRoot%\system32\xcopy" "%wl_install0%" "%wl_VirtDir%\webapps\%wl_context%" /s /e /h /q >nul
rem Benutzerkonfiguration loeschen
del "%wl_VirtDir%\webapps\%wl_context%\conf\user.config" >nul
rem Logs oeschen
rd /s /q "%wl_VirtDir%\webapps\%wl_context%\logs"
md "%wl_VirtDir%\webapps\%wl_context%\logs"
copy "%wl_install0%\logs\index.html" "%wl_VirtDir%\webapps\%wl_context%\logs\index.html" >nul 2>nul
rem Richtigen index.html anlegen
echo ^ >"%wl_VirtDir%\webapps\%wl_context%\index.html"
echo ^^ >>"%wl_VirtDir%\webapps\%wl_context%\index.html"
echo ^ >>"%wl_VirtDir%\webapps\%wl_context%\index.html"
echo ^WeLearn^ ^^ >>"%wl_VirtDir%\webapps\%wl_context%\index.html"
echo ^Welcome to the WeLearn-System Release 2^
^
>>"%wl_VirtDir%\webapps\%wl_context%\index.html"
echo ^If you are not connected to the server automatically, use the following link: >>"%wl_VirtDir%\webapps\%wl_context%\index.html"
echo ^%wl_context%^ >>"%wl_VirtDir%\webapps\%wl_context%\index.html"
echo ^
^^ >>"%wl_VirtDir%\webapps\%wl_context%\index.html"
if not exist "%wl_VirtDir%\webapps\ROOT\index.html" (copy "%wl_VirtDir%\webapps\%wl_context%\index.html" "%wl_VirtDir%\webapps\ROOT\index.html" >nul & goto no_override )
echo ...
echo Root-Zugriff sollte korrigiert werden, da mehrere WeLearn-Contexts aktiv sind.
echo Zu aendern ist dafuer die HTML-Datei
echo %wl_VirtDir%\webapps\ROOT\index.html
echo ...
:no_override
rem Aufruf WeLearn-Konfiguration
%wl_drive%
cd "%wl_VirtDir%\webapps\%wl_context%"
if not exist configurator.bat goto copy_error
echo ...
echo Installation von http://%wl_virtualserver%/%wl_context%
echo Vorgeschlagene Parameter fuer die WeLearn-Konfiguration sind:
echo a) Verzeichnis fuer WeLearn System-Dateien:
echo %wl_VirtDir%\%wl_contextUS%DiskPmRoot
echo b) Verzeichnis fuer upgeloadete Dateien:
echo %wl_VirtDir%\%wl_contextUS%Uploads
echo c) Verzeichnis fuer Logging-Dateien:
echo %wl_VirtDir%\webapps\%wl_context%\logs
echo d) Internes Datenbanksystem Verzeichnis (bei Wahl der internen DB):
echo %wl_VirtDir%\%wl_contextUS%Auditing\
echo ACHTUNG: Die Konfiguration muss abgespeichert werden!
:again1
call configurator.bat
echo ...
if exist "%wl_VirtDir%\webapps\%wl_context%\conf\user.config" goto endbat
echo ACHTUNG: Die Konfiguration musss wirklich abgespeichert werden!!!
goto again1
rem Code fuer Update -------------------------------------------------------------------------------------------
:update
rem Warnung, ob Tomcat laeuft
echo ACHTUNG: Falls Tomcat fuer den Context
echo http://%wl_virtualserver%/%wl_context%
echo aktiv ist, darf dieses Update nicht durchgefuehrt werden.
echo Brechen Sie in diesem Fall das Skript mit ^^C
echo = "Ctrl C" oder auf deutschen Tastaturen mit "Strg C" ab.
echo Stoppen Sie dann Tomcat z.B. mit "net stop tomcat5" oder
echo beenden Sie den Servercontext mit der Tomcat Manager-Appli-
echo kation, je nach Konfiguration z.B. mit
echo http://%wl_virtualserver%/manager/stop?path=/%wl_context%
echo Darauf starten Sie "CreateVirtualWeLearn" erneut.
pause
echo ...
echo WeLearn http://%wl_virtualserver%/%wl_context% im Verzeichnis
echo %wl_VirtDir%\webapps\%wl_context%\
echo wird upgedatet durch das WeLearn in Verzeichnis
echo %wl_install0%\
echo ACHTUNG: Es muss sichergestellt sein, dass das Update immer auf
echo eine neuere WeLearn-Version erfolgt!!
echo Noetigenfalls kann dieses Skript hier noch mit ^^C
echo abgebrochen werden.
pause
rem Temporaeres Verzeichnis anlegen
md "%wl_VirtDir%\WLTEMP-%wl_context%"
rem Konfigurationsteile sichern und sonst alles loeschen
move "%wl_VirtDir%\webapps\%wl_context%\index.html" "%wl_VirtDir%\WLTEMP-%wl_context%\"
move "%wl_VirtDir%\webapps\%wl_context%\conf" "%wl_VirtDir%\WLTEMP-%wl_context%\"
rd /s /q "%wl_VirtDir%\webapps\%wl_context%\"
md "%wl_VirtDir%\webapps\%wl_context%\"
rem Daten von der Originalinstallation kopieren
"%SystemRoot%\system32\xcopy" "%wl_install0%" "%wl_VirtDir%\webapps\%wl_context%" /s /e /h /q >nul
rem Neue Konfigurationsdaten in einem eigenen Verzeichnis aufheben
ren "%wl_VirtDir%\webapps\%wl_context%\conf" "conf-new-version"
rem Gesicherte Daten restaurieren
move /y "%wl_VirtDir%\WLTEMP-%wl_context%\index.html" "%wl_VirtDir%\webapps\%wl_context%\"
move /y "%wl_VirtDir%\WLTEMP-%wl_context%\conf" "%wl_VirtDir%\webapps\%wl_context%\"
rem Temporaeres Verzeichnis wieder loeschen
rd %wl_VirtDir%\WLTEMP-%wl_context%"
rem Aufruf WeLearn-Konfiguration
%wl_drive%
cd "%wl_VirtDir%\webapps\%wl_context%"
if not exist configurator.bat goto copy_error
echo ...
echo Vorgeschlagene Parameter fuer die WeLearn-Konfiguration sind:
echo a) Verzeichnis fuer WeLearn System-Dateien:
echo KEINE AENDERUNG ERLAUBT!
echo b) Verzeichnis fuer upgeloadete Dateien:
echo KEINE AENDERUNG ERLAUBT!
echo c) Verzeichnis fuer Logging-Dateien:
echo AENDERUNG NICHT EMPFOHLEN!
echo %wl_VirtDir%\webapps\%wl_context%\logs
echo d) Internes Datenbanksystem Verzeichnis (bei Wahl der internen DB):
echo AENDERUNG DATENBANK NICHT EMPFOHLEN!
echo %wl_VirtDir%\%wl_contextUS%Auditing\
echo ACHTUNG: Die neue Konfiguration muss abgespeichert werden!
:again2
call configurator.bat
if exist "%wl_VirtDir%\webapps\%wl_context%\conf\user.config" goto endbat
echo ACHTUNG: Die Konfiguration musss wirklich abgespeichert werden!!!
goto again2
rem Fehlermeldungen --------------------------------------------------------------------------------------------
:no_drive
echo Das Basis-Laufwerk fuer neue WeLearns %wl_drive% ist nicht vorhanden.
echo Die Variable "wl_drive" im Programm ist anzupassen!!
goto endbat
:no_WeLearn
echo WeLearn-Verzeichnis der Basisinstallation wurde nicht gefunden.
echo Die Variable "wl_install0" im Programm ist anzupassen!!
goto endbat
:no_parameters
echo Basisverzeichnsistruktur ist vorhanden.
echo Es wurden jedoch keine Verzeichnisse fuer einen virtuellen Server oder
echo einen Kontext innerhalb eines virtuellen Webservers angelegt.
echo ...
echo Parameter1: Name des virtuellen Webservers
echo Parameter2: Kontext (also 1. Unterverzeichnis unter der Wurzel)
echo Server wird dann mit http://parameter1/Parameter2 angesprochen.
echo ...
pause
goto endbat
:no_default
echo default ist ein reservierter Name fuer einen Server und
echo kann daher nicht verwendet werden.
goto endbat
:copy_error
echo Original WeLearn-Version wurde nicht korrekt kopiert!!
goto endbat
rem ..................
:endbat
endlocal