Skip to content

Commit

Permalink
Enhance distribution package
Browse files Browse the repository at this point in the history
  • Loading branch information
Román SG committed Jun 3, 2015
1 parent 4b9d881 commit e8c33d7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
35 changes: 32 additions & 3 deletions bin/make-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,46 @@ if [ "$0" != "bin/make-dist.sh" ]; then
exit 1
fi

DESTDIR=sla-service/target
DESTDIR=dist/target
DESTFILE=sla-service.tar.gz
SOURCEFILE=sla-service.war

mvn clean package
#mvn clean package

if [ -e "$DESTDIR" ]; then
echo "Directory $DESTDIR exists. You must remove it by hand"
exit 2
fi

mkdir "$DESTDIR"

cd $DESTDIR
cd sla-service/target

tar cvzf "$DESTFILE" "$SOURCEFILE"

cd -

mv sla-service/target/$DESTFILE $DESTDIR

echo "Resulting $DESTFILE is in $DESTDIR"

MOSDIR="$DESTDIR/mos"
MOSFILE=sla-core-distribution.tar.gz

rm -Rf "$MOSDIR"
mkdir "$MOSDIR"
mkdir "$MOSDIR/bin"
mkdir "$MOSDIR/etc"
mkdir "$MOSDIR/lib"
mkdir "$MOSDIR/share"


cp sla-service/target/dependency/jetty-runner.jar $MOSDIR/lib
cp sla-service/target/sla-service.war $MOSDIR/lib
cp dist/bin/restoreDatabase.sh $MOSDIR/bin
cp sla-repository/src/main/resources/sql/database.sql $MOSDIR/share
cp sla-repository/src/main/resources/sql/atossla.sql $MOSDIR/share/schema.sql

tar -cvzf $DESTDIR/$MOSFILE -C $MOSDIR .

echo "mOS package $MOSFILE is in $DESTDIR"
15 changes: 15 additions & 0 deletions dist/bin/restoreDatabase.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
DIR=$(cd "$(dirname "$0")" && pwd)

SCHEMA="$DIR/../share/schema.sql"

MODACLOUDS_MYSQL_IP=${MODACLOUDS_MYSQL_IP:-127.0.0.1}
MODACLOUDS_MYSQL_PORT=${MODACLOUDS_MYSQL_PORT:-3306}
MODACLOUDS_MYSQL_DB=${MODACLOUDS_MYSQL_DB:-atossla}
MODACLOUDS_MYSQL_USERNAME=${MODACLOUDS_MYSQL_USERNAME:-atossla}
MODACLOUDS_MYSQL_PASSWORD=${MODACLOUDS_MYSQL_PASSWORD:-_atossla_}

echo "Cleaning database: DB='$MODACLOUDS_MYSQL_DB' USER='$MODACLOUDS_MYSQL_USERNAME'"
mysql --host="${MODACLOUDS_MYSQL_IP}" --port="${MODACLOUDS_MYSQL_PORT}" \
-p"${MODACLOUDS_MYSQL_PASSWORD}" -u "${MODACLOUDS_MYSQL_USERNAME}" "${MODACLOUDS_MYSQL_DB}" < "$SCHEMA"

6 changes: 6 additions & 0 deletions sla-repository/src/main/resources/sql/database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- Default database and user initialization
CREATE DATABASE IF NOT EXISTS atossla;
CREATE USER atossla@'%' IDENTIFIED BY '_atossla_';
CREATE USER atossla@'localhost' IDENTIFIED BY '_atossla_';
GRANT ALL PRIVILEGES ON atossla.* TO atossla@'%';
GRANT ALL PRIVILEGES ON atossla.* TO atossla@'localhost';

0 comments on commit e8c33d7

Please sign in to comment.