-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor tomcat_start.sh, mysql_start.sh; extract version config for:…
… java, tomcat, mysql server; replacing the pwd command with dirname, realpath; created tomcat_config.sh
- Loading branch information
Showing
6 changed files
with
152 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
#!/bin/bash | ||
MYSQL_BASE="`pwd`/mysql" | ||
MYSQL_MAJOR_VERSION=8 | ||
MYSQL_MINOR_VERSION=0 | ||
MYSQL_PATCH_VERSION=33 | ||
|
||
INSTALLER_HOME=$(dirname "$(realpath "$0")") | ||
MYSQL_BASE="${INSTALLER_HOME}/mysql" | ||
|
||
export MYSQL_HOME="${MYSQL_BASE}/server" | ||
export DATADIR="$MYSQL_HOME/data" | ||
MY_CNF="$MYSQL_HOME/my.cnf" | ||
BINDIR="$MYSQL_HOME/bin" | ||
|
||
MYSQLD_PID="$DATADIR/mysqld.pid" | ||
|
||
if [ ! -d $DATADIR ]; then | ||
$MYSQL_BASE/mysql_install.sh $MYSQL_BASE | ||
if [ ! -d ${BINDIR} ]; then | ||
${MYSQL_BASE}/mysql_install.sh ${MYSQL_MAJOR_VERSION} ${MYSQL_MINOR_VERSION} ${MYSQL_PATCH_VERSION} | ||
fi | ||
|
||
cd $BINDIR | ||
cd ${BINDIR} | ||
./mysqld --defaults-file=${MY_CNF} --datadir $DATADIR --pid-file=${MYSQLD_PID} --console | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
export CATALINA_HOME="$1" | ||
cd $CATALINA_HOME | ||
cd .. | ||
CATALINA_BASE=`pwd` | ||
|
||
CATALINA_SERVER_XML="$CATALINA_HOME/conf/server.xml" | ||
CATALINA_LIB="$CATALINA_HOME/lib" | ||
CATALINA_TOMCAT_USERS_XML="$CATALINA_HOME/conf/tomcat-users.xml" | ||
CATALINA_WEBAPPS="$CATALINA_HOME/webapps" | ||
SCADA_LTS_HOME="${CATALINA_WEBAPPS}/Scada-LTS" | ||
CATALINA_CONTEXT_XML=${SCADA_LTS_HOME}/META-INF/context.xml | ||
CATALINA_BIN_DIR="$CATALINA_HOME/bin" | ||
|
||
CATALINA_PORT=-1 | ||
CATALINA_USERNAME="" | ||
CATALINA_PASSWORD="" | ||
|
||
DATABASE_PORT=-1 | ||
DATABASE_USERNAME="" | ||
DATABASE_PASSWORD="" | ||
|
||
NUMBER_REGEX='^[0-9]+$' | ||
|
||
cd "${CATALINA_BASE}" | ||
unzip "Scada-LTS.war" -d ${SCADA_LTS_HOME} | ||
cp -rf context.xml ${CATALINA_CONTEXT_XML} | ||
cp -rf ${CATALINA_BASE}/lib/*.jar ${CATALINA_LIB} | ||
cp -ar setenv.sh ${CATALINA_BIN_DIR} | ||
|
||
while [ ${CATALINA_PORT} -eq -1 ] || ! [[ ${CATALINA_PORT} =~ ${NUMBER_REGEX} ]] | ||
do | ||
echo -n "[Apache Tomcat Server] Enter port: " | ||
read -r CATALINA_PORT | ||
done | ||
sed -i "s/<Connector port=\"8080\"/<Connector port=\"${CATALINA_PORT}\"/" ${CATALINA_SERVER_XML} | ||
|
||
if [ -z ${CATALINA_USERNAME} ] || [ -z ${CATALINA_PASSWORD} ]; then | ||
echo -n "[Apache Tomcat Server] Enter username: " | ||
read -r CATALINA_USERNAME | ||
echo -n "[Apache Tomcat Server] Enter password: " | ||
read -r CATALINA_PASSWORD | ||
sed -i "s/<\/tomcat-users>/<role rolename=\"monitoring\"\/><role rolename=\"manager\"\/><role rolename=\"manager-gui\"\/><role rolename=\"admin\"\/><role rolename=\"admin-script\"\/><role rolename=\"admin-gui\"\/><user username=\"${CATALINA_USERNAME}\" password=\"${CATALINA_PASSWORD}\" roles=\"admin,manager,manager-gui,monitoring,admin-script,admin-gui\"\/><\/tomcat-users>/" ${CATALINA_TOMCAT_USERS_XML} | ||
fi | ||
|
||
while [ ${DATABASE_PORT} -eq -1 ] || ! [[ ${DATABASE_PORT} =~ ${NUMBER_REGEX} ]] | ||
do | ||
echo -n "[Apache Tomcat Server] Enter database port: " | ||
read -r DATABASE_PORT | ||
done | ||
sed -i "s/jdbc:mysql:\/\/localhost:3308/jdbc:mysql:\/\/localhost:${DATABASE_PORT}/" ${CATALINA_CONTEXT_XML} | ||
|
||
if [ -z ${DATABASE_USERNAME} ] || [ -z ${DATABASE_PASSWORD} ]; then | ||
echo -n "[Apache Tomcat Server] Enter database username: " | ||
read -r DATABASE_USERNAME | ||
sed -i "s/username=\"root\"/username=\"${DATABASE_USERNAME}\"/" ${CATALINA_CONTEXT_XML} | ||
echo -n "[Apache Tomcat Server] Enter database password: " | ||
read -r DATABASE_PASSWORD | ||
sed -i "s/password=\"\"/password=\"${DATABASE_PASSWORD}\"/" ${CATALINA_CONTEXT_XML} | ||
fi | ||
echo "Tomcat version ${TOMCAT_VERSION} configured" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,20 @@ | ||
#!/bin/bash | ||
export JAVA_HOME="$1/jdk" | ||
export CATALINA_HOME="$2/server" | ||
JAVA_BASE="$1" | ||
CATALINA_BASE="$2" | ||
|
||
CATALINA_SERVER_XML="$CATALINA_HOME/conf/server.xml" | ||
CATALINA_LIB="$CATALINA_HOME/lib" | ||
CATALINA_TOMCAT_USERS_XML="$CATALINA_HOME/conf/tomcat-users.xml" | ||
JAVA_BIN_DIR="$JAVA_HOME/bin" | ||
CATALINA_BIN_DIR="$CATALINA_HOME/bin" | ||
CATALINA_PORT=-1 | ||
CATALINA_USERNAME="" | ||
CATALINA_PASSWORD="" | ||
|
||
DATABASE_PORT=-1 | ||
DATABASE_USERNAME="" | ||
DATABASE_PASSWORD="" | ||
|
||
CATALINA_WEBAPPS="$CATALINA_HOME/webapps" | ||
SCADA_LTS_HOME="${CATALINA_WEBAPPS}/Scada-LTS" | ||
|
||
if [ ! -d "${JAVA_BIN_DIR}" ]; then | ||
${JAVA_BASE}/java_install.sh ${JAVA_BASE} | ||
fi | ||
|
||
if [ ! -d "$CATALINA_BIN_DIR" ]; then | ||
|
||
TOMCAT_MAJOR_VERSION=9 | ||
TOMCAT_MINOR_VERSION=0 | ||
TOMCAT_PATCH_VERSION=76 | ||
TOMCAT_VERSION="${TOMCAT_MAJOR_VERSION}.${TOMCAT_MINOR_VERSION}.${TOMCAT_PATCH_VERSION}" | ||
TOMCAT_DEST="apache-tomcat-${TOMCAT_VERSION}" | ||
TOMCAT_TAR_GZ_FILE="${TOMCAT_DEST}.tar.gz" | ||
|
||
mkdir -p $CATALINA_HOME | ||
cd $CATALINA_HOME | ||
wget "https://archive.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR_VERSION}/v${TOMCAT_VERSION}/bin/${TOMCAT_TAR_GZ_FILE}" | ||
tar -xvf ${TOMCAT_TAR_GZ_FILE} -C "$CATALINA_HOME" | ||
cd "$CATALINA_HOME/${TOMCAT_DEST}" | ||
mv * "$CATALINA_HOME" | ||
cd .. | ||
rm -rf ${TOMCAT_DEST} | ||
rm -f ${TOMCAT_TAR_GZ_FILE} | ||
echo "Tomcat version ${TOMCAT_VERSION} installed" | ||
fi | ||
|
||
if [ ! -d "${SCADA_LTS_HOME}" ]; then | ||
|
||
CATALINA_CONTEXT_XML=${SCADA_LTS_HOME}/META-INF/context.xml | ||
cd "${CATALINA_BASE}" | ||
unzip "Scada-LTS.war" -d ${SCADA_LTS_HOME} | ||
cp -rf context.xml ${CATALINA_CONTEXT_XML} | ||
cp -rf ${CATALINA_BASE}/lib/*.jar ${CATALINA_LIB} | ||
cp -ar setenv.sh ${CATALINA_BIN_DIR} | ||
|
||
if [[ ${CATALINA_PORT} -eq -1 ]]; then | ||
echo -n "[Apache Tomcat Server] Enter port: " | ||
read -r CATALINA_PORT | ||
sed -i "s/8080/${CATALINA_PORT}/" ${CATALINA_SERVER_XML} | ||
fi | ||
|
||
if [ -z ${CATALINA_USERNAME} ] || [ -z ${CATALINA_PASSWORD} ]; then | ||
echo -n "[Apache Tomcat Server] Enter username: " | ||
read -r CATALINA_USERNAME | ||
echo -n "[Apache Tomcat Server] Enter password: " | ||
read -r CATALINA_PASSWORD | ||
sed -i "s/<\/tomcat-users>/<role rolename=\"monitoring\"\/><role rolename=\"manager\"\/><role rolename=\"manager-gui\"\/><role rolename=\"admin\"\/><role rolename=\"admin-script\"\/><role rolename=\"admin-gui\"\/><user username=\"${CATALINA_USERNAME}\" password=\"${CATALINA_PASSWORD}\" roles=\"admin,manager,manager-gui,monitoring,admin-script,admin-gui\"\/><\/tomcat-users>/" ${CATALINA_TOMCAT_USERS_XML} | ||
fi | ||
|
||
if [[ ${DATABASE_PORT} -eq -1 ]]; then | ||
echo -n "[Apache Tomcat Server] Enter database port: " | ||
read -r DATABASE_PORT | ||
sed -i "s/jdbc:mysql:\/\/localhost:3308/jdbc:mysql:\/\/localhost:${DATABASE_PORT}/" ${CATALINA_CONTEXT_XML} | ||
fi | ||
|
||
if [ -z ${DATABASE_USERNAME} ] || [ -z ${DATABASE_PASSWORD} ]; then | ||
echo -n "[Apache Tomcat Server] Enter database username: " | ||
read -r DATABASE_USERNAME | ||
sed -i "s/username=\"root\"/username=\"${DATABASE_USERNAME}\"/" ${CATALINA_CONTEXT_XML} | ||
echo -n "[Apache Tomcat Server] Enter database password: " | ||
read -r DATABASE_PASSWORD | ||
sed -i "s/password=\"\"/password=\"${DATABASE_PASSWORD}\"/" ${CATALINA_CONTEXT_XML} | ||
fi | ||
echo "Tomcat version ${TOMCAT_VERSION} configured" | ||
fi | ||
export CATALINA_HOME="$1" | ||
TOMCAT_MAJOR_VERSION="$2" | ||
TOMCAT_MINOR_VERSION="$3" | ||
TOMCAT_PATCH_VERSION="$4" | ||
|
||
TOMCAT_VERSION="${TOMCAT_MAJOR_VERSION}.${TOMCAT_MINOR_VERSION}.${TOMCAT_PATCH_VERSION}" | ||
TOMCAT_DEST="apache-tomcat-${TOMCAT_VERSION}" | ||
TOMCAT_TAR_GZ_FILE="${TOMCAT_DEST}.tar.gz" | ||
|
||
mkdir -p $CATALINA_HOME | ||
cd $CATALINA_HOME | ||
wget "https://archive.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR_VERSION}/v${TOMCAT_VERSION}/bin/${TOMCAT_TAR_GZ_FILE}" | ||
tar -xvf ${TOMCAT_TAR_GZ_FILE} -C "$CATALINA_HOME" | ||
cd "$CATALINA_HOME/${TOMCAT_DEST}" | ||
mv * "$CATALINA_HOME" | ||
cd .. | ||
rm -rf ${TOMCAT_DEST} | ||
rm -f ${TOMCAT_TAR_GZ_FILE} | ||
echo "Tomcat version ${TOMCAT_VERSION} installed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,34 @@ | ||
#!/bin/bash | ||
JAVA_BASE="`pwd`/java" | ||
CATALINA_BASE="`pwd`/tomcat64" | ||
JAVA_VERSION="11.0.19" | ||
JAVA_UPDATE=7 | ||
|
||
TOMCAT_MAJOR_VERSION=9 | ||
TOMCAT_MINOR_VERSION=0 | ||
TOMCAT_PATCH_VERSION=76 | ||
|
||
INSTALLER_HOME=$(dirname "$(realpath "$0")") | ||
JAVA_BASE="${INSTALLER_HOME}/java" | ||
CATALINA_BASE="${INSTALLER_HOME}/tomcat64" | ||
|
||
export JAVA_HOME="${JAVA_BASE}/jdk" | ||
export CATALINA_HOME="${CATALINA_BASE}/server" | ||
|
||
JAVA_BIN_DIR="$JAVA_HOME/bin" | ||
CATALINA_BIN_DIR="$CATALINA_HOME/bin" | ||
|
||
CATALINA_WEBAPPS="$CATALINA_HOME/webapps" | ||
SCADA_LTS_HOME="${CATALINA_WEBAPPS}/Scada-LTS" | ||
|
||
if [ ! -d "${JAVA_BIN_DIR}" ]; then | ||
${JAVA_BASE}/java_install.sh $JAVA_HOME ${JAVA_VERSION} ${JAVA_UPDATE} | ||
fi | ||
|
||
if [ ! -d "${CATALINA_BIN_DIR}" ]; then | ||
$CATALINA_BASE/tomcat_install.sh ${JAVA_BASE} ${CATALINA_BASE} | ||
$CATALINA_BASE/tomcat_install.sh $CATALINA_HOME ${TOMCAT_MAJOR_VERSION} ${TOMCAT_MINOR_VERSION} ${TOMCAT_PATCH_VERSION} | ||
fi | ||
|
||
if [ ! -d "${SCADA_LTS_HOME}" ]; then | ||
$CATALINA_BASE/tomcat_config.sh $CATALINA_HOME | ||
fi | ||
|
||
$CATALINA_HOME/bin/catalina.sh run |