The mojoPortal deployment package includes the setup and upgrade scripts for the 5 different database platforms it supports. Of course a single installation of mojoPortal will only use 1 of those database platforms. These extra files aren't really all that big and hard disk space is cheap but many people would like to remove the extra files to keep things as slim as possible.
i7MEDIA hosts many mojoPortal sites so we put together a nice little batch script to remove all the extra files from our installations. This script can be ran against an actual installation of mojoPortal or it can be ran against the installation files prior to copying them to the site. Most of our sites use MSSQL so we generally run the script against a single set of installation files to remove all the extra database scripts prior to upgrading current sites or installing new sites.
In the Open Source spirit, we decided to give this script to the community. So here it is:
::******************************************************************************************************
::Author: Joe Davis, i7MEDIA, LLC
::Created: July 29, 2009
::Version: 0.1a
::Purpose: Remove unnecessary DB scripts from mojoPortal
::******************************************************************************************************
@ECHO off
cls
SETLOCAL ENABLEEXTENSIONS
ECHO.==========================================================
ECHO %0 -- v. 0.1a
ECHO July 2009, i7MEDIA, LLC
ECHO Removes unncessary Database Setup Scripts from mojoPortal
ECHO.
::Check for the existance of the SiteRoot. If it doesn't exist, show syntax. If it does exist, continue.
IF {%1}=={} (
ECHO.
ECHO %0 [Path To Your mojoPortal Installation]
ECHO EX.: %0 d:\sites\jimbob\wwwroot
GOTO END
)
SET _SITEROOT=%1
ECHO.
ECHO.
ECHO The mojoPortal deployment package comes with setup scripts for the following DB types
ECHO.
ECHO (1) FirebirdSQL
ECHO (2) MSSQL
ECHO (3) MySQL
ECHO (4) PgSQL
ECHO (5) SQLite
ECHO.
SET /P _KEEPDB=Which DB do you use for this installation of mojoPortal (enter the number)?
IF "%_KEEPDB%"=="1" SET _KEEPDB-NAME=FirebirdSQL
IF "%_KEEPDB%"=="2" SET _KEEPDB-NAME=MSSQL
IF "%_KEEPDB%"=="3" SET _KEEPDB-NAME=MySQL
IF "%_KEEPDB%"=="4" SET _KEEPDB-NAME=PgSQL
IF "%_KEEPDB%"=="5" SET _KEEPDB-NAME=SQLite
ECHO.
ECHO.
ECHO This script is about to remove all database setup files other than:
ECHO %_KEEPDB-NAME%
ECHO from the mojoPortal installation at:
ECHO %_SITEROOT%
ECHO.
SET /P _CONTINUE=Is this okay (y,n)?
IF /I "%_CONTINUE%"=="n" (
ECHO Cancelled, nothing done.
GOTO END
)
FOR /f "tokens=*" %%J IN ('DIR %_SITEROOT%\Setup\applications /ad /b') DO (
CD %_SITEROOT%\Setup\applications\%%J\
FOR /f "tokens=*" %%K IN ('DIR /ad /b') DO (
::If current directory is NOT the FeatureDefinitions directory, continue
IF /I NOT %%K==FeatureDefinitions (
::If chosen DB is FirebirdSQL, remove all the others
IF /I "%_KEEPDB-NAME%"=="FirebirdSQL" (
RD %%K\mssql /S/ Q
RD %%K\mysql /S /Q
RD %%K\pgsql /S /Q
RD %%K\sqlite /S /Q
) ELSE (
::If chosen DB is MSSQL, remove all the others
IF /I "%_KEEPDB-NAME%"=="MSSQL" (
RD %%K\firebirdsql /S /Q
RD %%K\mysql /S /Q
RD %%K\pgsql /S /Q
RD %%K\sqlite /S /Q
) ELSE (
::If chosen DB is MySQL, remove all the others
IF /I "%_KEEPDB-NAME%"=="MySQL" (
RD %%K\firebirdsql /S /Q
RD %%K\mssql /S /Q
RD %%K\pgsql /S /Q
RD %%K\sqlite /S /Q
) ELSE (
::If chosen DB is PgSQL, remove all the others
IF /I "%_KEEPDB-NAME%"=="PgSQL" (
RD %%K\firebirdsql /S /Q
RD %%K\mssql /S /Q
RD %%K\mysql /S /Q
RD %%K\sqlite /S /Q
) ELSE (
::If chosen DB is SQLite, remove all the others
IF /I "%_KEEPDB-NAME%"=="SQLite" (
RD %%K\firebirdsql /S /Q
RD %%K\mssql /S /Q
RD %%K\mysql /S /Q
RD %%K\pgsql /S /Q
)
)
)
)
)
)
)
ECHO Removed extra DB scripts from %%J
)
:END
ENDLOCAL