diff options
author | Shireesh Anjal <shireesh@gluster.com> | 2011-11-25 17:52:15 +0530 |
---|---|---|
committer | Shireesh Anjal <shireesh@gluster.com> | 2011-11-25 17:55:30 +0530 |
commit | 17c05d3c9874c2083a91fe59711afce1ae1e565e (patch) | |
tree | 4366880b0fdcd50e4153bb10e3e4029f2de3bbbc /build | |
parent | a7c75101995a38cb4da84e399d4ed5777ef14d20 (diff) |
Modified so that gmc-build.sh can now be used to build gmc+gmg+backend from source.
Diffstat (limited to 'build')
-rwxr-xr-x | build/gmc-build.sh | 65 | ||||
-rwxr-xr-x | build/gmg-install.sh | 172 |
2 files changed, 228 insertions, 9 deletions
diff --git a/build/gmc-build.sh b/build/gmc-build.sh index c25713a9..dcebdfc8 100755 --- a/build/gmc-build.sh +++ b/build/gmc-build.sh @@ -1,3 +1,24 @@ +#!/bin/bash + +#------------------------------------------------------------------ +# Copyright (c) 2006-2011 Gluster, Inc. <http://www.gluster.com> +# This file is part of GlusterFS. +# +# Gluster Management Console is free software; you can redistribute +# it and/or modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# GlusterFS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# <http://www.gnu.org/licenses/>. +#------------------------------------------------------------------ + USAGE_ERR=1 BUCKMINSTER_URL=http://download.eclipse.org/tools/buckminster/headless-3.7/ @@ -62,6 +83,27 @@ install_buckminster() ./buckminster install ${BUCKMINSTER_URL} org.eclipse.buckminster.emma.headless.feature } +# Create keystore for jar signing (self signed) +setup_keys() +{ + mkdir -p ${KEYS_DIR} + cd ${KEYS_DIR} + keytool -genkeypair -keystore gluster.keystore -storepass gluster -alias gluster -keyalg RSA << EOF +Gluster +Gluster +Gluster +Dummy +Dummy +US +yes +EOF + + keytool -selfcert -alias gluster -keystore gluster.keystore << EOF +gluster +EOF + cd - +} + configure_workspace() { echo "Configuring the workspace..." @@ -76,11 +118,6 @@ configure_workspace() echo "Importing target platform..." ${BUCKMINSTER_HOME}/buckminster importtarget -data ${WORKSPACE_DIR} --active gmc-target/com.gluster.storage.management.console.target/gmc.target - echo "Importing component query for glustermc..." - ${BUCKMINSTER_HOME}/buckminster import -data ${WORKSPACE_DIR} build/com.gluster.storage.management.console.feature.webstart.cquery - #${BUCKMINSTER_HOME}/buckminster import -data ${WORKSPACE_DIR} build/com.gluster.storage.management.core.cquery - echo "Importing component query for glustermg..." - ${BUCKMINSTER_HOME}/buckminster import -data ${WORKSPACE_DIR} build/com.gluster.storage.management.gateway.cquery cd - } @@ -95,14 +132,17 @@ build_gmc() mkdir -p ${DIST_DIR} fi - echo "Building GMC for [${os}.${ws}.${arch}" + echo "Importing component query for glustermc..." + ${BUCKMINSTER_HOME}/buckminster import -data ${WORKSPACE_DIR} build/com.gluster.storage.management.console.feature.webstart.cquery + + echo "Building GMC for [${os}.${ws}.${arch}]" ${BUCKMINSTER_HOME}/buckminster perform -Dbuckminster.output.root=${DIST_DIR} -data ${WORKSPACE_DIR} -Dtarget.os=${os} -Dtarget.ws=${ws} -Dtarget.arch=${arch} -Dcbi.include.source=false --properties ${PROPERTIES_FILE} ${GMC_WEBSTART_PROJECT}#create.eclipse.jnlp.product - ${BUCKMINSTER_HOME}/buckminster perform -Dbuckminster.output.root=${DIST_DIR} --properties ${PROPERTIES_FILE} ${GMC_WEBSTART_PROJECT}#copy.root.files + ${BUCKMINSTER_HOME}/buckminster perform -Dbuckminster.output.root=${DIST_DIR} -data ${WORKSPACE_DIR} --properties ${PROPERTIES_FILE} ${GMC_WEBSTART_PROJECT}#copy.root.files # buckminster signs the jars using eclipse certificate - hence unsign and sign them again echo "Signing product jars..." - ${BUCKMINSTER_HOME}/buckminster perform --properties ${PROPERTIES_FILE} ${GMC_WEBSTART_PROJECT}#unsign.jars - ${BUCKMINSTER_HOME}/buckminster perform --properties ${PROPERTIES_FILE} ${GMC_WEBSTART_PROJECT}#sign.jars + ${BUCKMINSTER_HOME}/buckminster perform -data ${WORKSPACE_DIR} -Dbuckminster.output.root=${DIST_DIR} --properties ${PROPERTIES_FILE} ${GMC_WEBSTART_PROJECT}#unsign.jars + ${BUCKMINSTER_HOME}/buckminster perform -data ${WORKSPACE_DIR} -Dbuckminster.output.root=${DIST_DIR} -Djar.signing.keystore=${KEYS_DIR}/gluster.keystore --properties ${PROPERTIES_FILE} ${GMC_WEBSTART_PROJECT}#sign.jars } build_gmg() @@ -113,8 +153,13 @@ build_gmg() mkdir -p ${DIST_DIR} fi + echo "Importing component query for glustermg..." + ${BUCKMINSTER_HOME}/buckminster import -data ${WORKSPACE_DIR} build/com.gluster.storage.management.core.cquery + ${BUCKMINSTER_HOME}/buckminster import -data ${WORKSPACE_DIR} build/com.gluster.storage.management.gateway.cquery + echo "Building CORE..." ${BUCKMINSTER_HOME}/buckminster perform -Dbuckminster.output.root=${DIST_DIR} -data ${WORKSPACE_DIR} -Dcbi.include.source=false --properties ${PROPERTIES_FILE} ${GMC_CORE_PROJECT}#bundle.jar + echo "Building Gateway..." ${BUCKMINSTER_HOME}/buckminster perform -Dbuckminster.output.root=${DIST_DIR} -data ${WORKSPACE_DIR} -Dcbi.include.source=false --properties ${PROPERTIES_FILE} ${GMG_PROJECT}#archive @@ -172,6 +217,7 @@ BUILD_MODE=${1} BASE_DIR=${PWD}/../.. TOOLS_DIR=${BASE_DIR}/tools DIST_BASE=${BASE_DIR}/dist +KEYS_DIR=${TOOLS_DIR}/keys BUCKMINSTER_HOME=${TOOLS_DIR}/buckminster WORKSPACE_DIR=${BUCKMINSTER_HOME}/workspace PROPERTIES_FILE=${WORKSPACE_DIR}/build/glustermc_build.properties @@ -180,6 +226,7 @@ SCRIPT_DIR=${PWD} if [ "${BUILD_MODE}" == "${TYPE_ALL}" -o "${BUILD_MODE}" == "${TYPE_SETUP}" ]; then get_director install_buckminster + setup_keys fi if [ "${BUILD_MODE}" == "${TYPE_ALL}" -o "${BUILD_MODE}" == "${TYPE_BUILD}" ]; then diff --git a/build/gmg-install.sh b/build/gmg-install.sh new file mode 100755 index 00000000..7e0e23f4 --- /dev/null +++ b/build/gmg-install.sh @@ -0,0 +1,172 @@ +#!/bin/bash + +#------------------------------------------------------------------ +# Copyright (c) 2006-2011 Gluster, Inc. <http://www.gluster.com> +# This file is part of GlusterFS. +# +# Gluster Management Gateway is free software; you can redistribute +# it and/or modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# GlusterFS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# <http://www.gnu.org/licenses/>. +#------------------------------------------------------------------ + +# Variables +GMG_LOG_DIR="/var/log/glustermg"; +GMG_ROOT_DIR="/opt/glustermg" +GMG_KEYS_DIR="${GMG_ROOT_DIR}/keys" +USAGE_ERR=1 +TOMCAT_ERR=2 +JAVA_ERR=3 +TAR_ERR=4 + +function quit() +{ + echo ${1} + echo + exit ${2} +} + +function post_install() +{ + if [ ! -f /etc/init.d/$TOMCAT_BIN ]; then + echo "All operations completed. Please restart tomcat." + else + echo "Re-starting [${TOMCAT_BIN}].." + service $TOMCAT_BIN restart; + fi + echo +} + +function configure_server() +{ + TOMCAT_CONFIG_FILE="/etc/sysconfig/$TOMCAT_BIN" + if [ -f ${TOMCAT_CONFIG_FILE} ]; then + if ! grep -q '^JAVA_HOME="/usr/lib/jvm/jre-1.6.0-openjdk.x86_64"' ${TOMCAT_CONFIG_FILE}; then + sed -i 's/^JAVA_HOME=/# JAVA_HOME=/g' ${TOMCAT_CONFIG_FILE} + echo 'JAVA_HOME="/usr/lib/jvm/jre-1.6.0-openjdk.x86_64"' >> ${TOMCAT_CONFIG_FILE} + fi + + if ! grep -q '# Added by Gluster: JAVA_OPTS="${JAVA_OPTS} -Xms1024m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m"' ${TOMCAT_CONFIG_FILE}; then + echo '# Added by Gluster: JAVA_OPTS="${JAVA_OPTS} -Xms1024m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m"' >> ${TOMCAT_CONFIG_FILE} + echo 'JAVA_OPTS="${JAVA_OPTS} -Xms1024m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m"' >> ${TOMCAT_CONFIG_FILE} + fi + fi + + if ! grep -q ${GMG_HOME_DIR}/glustermg/ssl/gmg-ssl.keystore $TOMCAT_DIR/conf/server.xml; then + sed -i '/<\/Service>/i \ + <Connector SSLEnabled="true" \ + clientAuth="false" \ + executor="tomcatThreadPool" \ + maxThreads="150" \ + port="8443" \ + keystoreFile="$TOMCAT_DIR/webapps/glustermg/ssl/gmg-ssl.keystore" \ + keystorePass="gluster" \ + protocol="org.apache.coyote.http11.Http11Protocol" \ + scheme="https" \ + secure="true" \ + sslProtocol="TLS" />' $TOMCAT_DIR/conf/server.xml + sed -i "s,keystoreFile=\"\$TOMCAT_DIR/webapps/glustermg/ssl/gmg-ssl.keystore\",keystoreFile=\"$TOMCAT_DIR/webapps/glustermg/ssl/gmg-ssl.keystore\"," $TOMCAT_DIR/conf/server.xml + fi + if ! grep -q "org.apache.catalina.authenticator.NonLoginAuthenticator" $TOMCAT_DIR/conf/context.xml; then + sed -i '/<\/Context>/i \ + <Valve className="org.apache.catalina.authenticator.NonLoginAuthenticator" \ + disableProxyCaching="false" />' $TOMCAT_DIR/conf/context.xml + fi + + GMG_SCRIPTS_DIR="${GMG_HOME_DIR}/glustermg/scripts" + ln -sf ${GMG_SCRIPTS_DIR}/grun.py /usr/sbin/grun.py + ln -sf ${GMG_SCRIPTS_DIR}/add_user_cifs_all.py /usr/sbin/add_user_cifs_all.py + ln -sf ${GMG_SCRIPTS_DIR}/delete_user_cifs_all.py /usr/sbin/delete_user_cifs_all.py + ln -sf ${GMG_SCRIPTS_DIR}/setup_cifs_config_all.py /usr/sbin/setup_cifs_config_all.py + ln -sf ${GMG_SCRIPTS_DIR}/gmg-reset-password.sh /usr/sbin/gmg-reset-password.sh +} + +function make_dirs() +{ + mkdir -p $GMG_HOME_DIR $GMG_KEYS_DIR $GMG_LOG_DIR; + if [ ! -f ${GMG_KEYS_DIR}/gluster.pem ]; then + ssh-keygen -t rsa -f /opt/glustermg/keys/gluster.pem -N '' + mv -f /opt/glustermg/keys/gluster.pem.pub /opt/glustermg/keys/gluster.pub + fi + chown -R tomcat:tomcat $GMG_HOME_DIR $GMG_LOG_DIR; +} + + +function check_tar_gz() +{ + file $GMG_ARCHIVE_PATH | grep "gzip" > /dev/null; + if [ $? != 0 ] ; then + quit "The given filename is not a gunzipped tarball. The file name must be of the form glustermg-version.war.tar.gz" ${TAR_ERR} + fi +} + +function get_GMG_VERSION() +{ + # Format is /path/to/glustermg-version.war.tar.gz + # Remove prefix + PART1=${GMG_ARCHIVE_PATH#*glustermg-} + # Remove suffix + GMG_VERSION=${PART1%.war.tar.gz} + + GMG_HOME_DIR="${GMG_HOME_DIR}/${GMG_VERSION}"; +} + +function check_tomcat_dir() +{ + WEBAPPS_DIR="${TOMCAT_DIR}/webapps/" + if [ ! -d "${WEBAPPS_DIR}" ]; then + quit "There is no webapps directory in [${TOMCAT_DIR}]." ${TOMCAT_ERR} + fi + TOMCAT_BIN=$(basename /usr/sbin/tomcat* ); +} + +function check_java_version() +{ + java -version 2>/dev/null || quit "java command not available. Please make sure that Java >=1.6.0 is installed and is present in \$PATH" ${JAVA_ERR} + JAVA_VERSION=`java -version 2>&1 |awk 'NR==1{ gsub(/"/,""); gsub(/_.*/, ""); print $3 }'` + MINVERSION=1.6 + + if expr $JAVA_VERSION \>= $MINVER > /dev/null; then + echo "Found java version [${JAVA_VERSION}]" + else + quit "Java minimum version expected [${MINVER}], found [${JAVA_VERSION}]!" ${JAVA_ERR} + fi +} + +function install_gmg() +{ + tar -xvf ${GMG_ARCHIVE_PATH} -C ${GMG_HOME_DIR} + ln -fs ${GMG_HOME_DIR}/glustermg ${WEBAPPS_DIR} +} + +#----------------------------------- +# Main Action Body +#----------------------------------- + +if [ "x$1" == "x" ] || [ "x$1$2" == "x$1" ] || [ $# -gt 2 ]; then + echo "Usage: $0 <path to glustermg-version.war.tar.gz> <path to tomcat directory>"; + exit 1; +fi + +GMG_ARCHIVE_PATH="$1"; +TOMCAT_DIR="$2"; + +check_tomcat_dir +check_java_version +check_tar_gz +get_GMG_VERSION + +make_dirs +install_gmg + +configure_server +post_install |