Last active
March 20, 2018 09:59
-
-
Save mgoellnitz/c9ef627df99ed8efe2f9bc83da12bfd6 to your computer and use it in GitHub Desktop.
Build and import theme for DXP workspaces e.g. from cron
This file contains hidden or 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
#!/bin/bash | |
# | |
# Import theme from given workspace into CoreMedia CMS-9 | |
# | |
# $1 - importer user - default theme-importer | |
# $2 - importer user's password - default importingthemes | |
# $3 - workspace directory - default ~/coremedia9 | |
# $4 - themes subdirectory - default modules/frontend | |
# $5 - theme - default corporate | |
# | |
# Copyright (c) 2017-2018, Martin Goellnitz | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without modification, | |
# are permitted provided that the following conditions are met: | |
# | |
# 1. Redistributions of source code must retain the above copyright notice, | |
# this list of conditions and the following disclaimer. | |
# | |
# 2. Redistributions in binary form must reproduce the above copyright notice, | |
# this list of conditions and the following disclaimer in the documentation | |
# and/or other materials provided with the distribution. | |
# | |
# 3. Neither the name of the copyright holder nor the names of its contributors | |
# may be used to endorse or promote products derived from this software | |
# without specific prior written permission. | |
# | |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | |
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
# | |
USERNAME=${1:theme-importer} | |
PASSWORD=${2:-importingthemes} | |
WORKSPACE=${3:-~/coremedia9} | |
DIR=${4:-modules/frontend} | |
THEME=${5:-corporate} | |
LOG=/var/log/cms-theme-$THEME.log | |
if [ ! -w $LOG ] ; then | |
LOG=/tmp/cms-theme-$THEME.log | |
fi | |
source /etc/profile | |
cd $WORKSPACE | |
echo -n "Syncing with GIT upstream " >> $LOG | |
date >> $LOG | |
git stash >> $LOG | |
git fetch >> $LOG | |
git rebase >> $LOG | |
git stash apply >> $LOG 2>&1 | |
git stash clear >> $LOG 2>&1 | |
NOW=`date +%s` | |
LASTREBASE=`cat /tmp/lastthemecommit-$THEME` | |
LASTCOMMIT=`git log -n1 --format="%h"` | |
if [ "$LASTCOMMIT" != "$LASTREBASE" ] ; then | |
echo -n "Building theme $THEME. " > $LOG | |
date >> $LOG | |
echo $LASTCOMMIT > /tmp/lastthemecommit-$THEME | |
cd $DIR | |
export MAVEN_OPTS="-Xms1024m -Xmx4096m -Dorg.slf4j.simpleLogger.defaultLogLevel=warn" | |
mvn clean >>$LOG | |
mvn install >> $LOG | |
echo -n "Uploading theme $THEME " >> $LOG | |
ls $WORKSPACE/$DIR/target/themes/$THEME-theme.zip >> $LOG | |
/opt/coremedia/theme-importer-tools/bin/cm import-themes -u $USERNAME -p $PASSWORD $WORKSPACE/$DIR/target/themes/$THEME-theme.zip >> $LOG | |
echo -n "Updating theme done. " >> $LOG | |
date >> $LOG | |
else | |
echo "Last unchanged commit was $LASTCOMMIT" >> $LOG | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment