Skip to content

Commit

Permalink
Merge pull request #691 from sks/patch-1
Browse files Browse the repository at this point in the history
Fix issues reported by shellcheck
  • Loading branch information
noorul committed Jan 12, 2017
2 parents 7408139 + ca364f7 commit 2b6aef7
Showing 1 changed file with 43 additions and 39 deletions.
82 changes: 43 additions & 39 deletions bin/server_package.sh
@@ -1,64 +1,68 @@
#!/bin/bash
#!/bin/bash -ue
# Script for packaging all the job server files to .tar.gz for Mesos or other single-image deploys
WORK_DIR=/tmp/job-server

ENV=$1
if [ -z "$ENV" ]; then
echo "Syntax: $0 <Environment>"
ENV="${1}"
if [ -z "${ENV}" ]; then
echo "Syntax: ${0} <Environment>"
echo " for a list of environments, ls config/*.sh"
exit 0
fi

bin=`dirname "${BASH_SOURCE-$0}"`
bin=`cd "$bin"; pwd`
bin=$(dirname "${BASH_SOURCE-$0}")
bin=$(cd "${bin}"; pwd)

if [ -z "$CONFIG_DIR" ]; then
CONFIG_DIR=`cd "$bin"/../config/; pwd`
if [ -z "${CONFIG_DIR:-}" ]; then
CONFIG_DIR=$(cd "${bin}/../config/"; pwd)
fi
configFile="$CONFIG_DIR/$ENV.sh"
configFile="${CONFIG_DIR}/${ENV}.sh"

if [ ! -f "$configFile" ]; then
echo "Could not find $configFile"
if [ ! -f "${configFile}" ]; then
echo "Could not find ${configFile}"
exit 1
fi
. $configFile
# shellcheck source=/dev/null
. "${configFile}"

majorRegex='([0-9]+\.[0-9]+)\.[0-9]+'
if [[ $SCALA_VERSION =~ $majorRegex ]]
set +u
if [[ "${SCALA_VERSION}" =~ ${majorRegex} ]]
then
majorVersion="${BASH_REMATCH[1]}"
else
echo "Please specify SCALA_VERSION in ${configFile}"
exit 1
fi
set -u

echo Packaging job-server for environment $ENV...
echo "Packaging job-server for environment ${ENV}..."

cd $(dirname $0)/..
sbt ++$SCALA_VERSION job-server-extras/assembly
if [ "$?" != "0" ]; then
echo "Assembly failed"
exit 1
fi
pushd "${bin}/.." > /dev/null
if ! sbt ++"${SCALA_VERSION}" job-server-extras/assembly; then
echo "Assembly failed"
exit 1
fi

FILES="job-server-extras/target/scala-$majorVersion/spark-job-server.jar
bin/server_start.sh
bin/server_stop.sh
bin/kill-process-tree.sh
bin/manager_start.sh
bin/setenv.sh
${CONFIG_DIR}/${ENV}.conf
config/shiro.ini
config/log4j-server.properties"

FILES="job-server-extras/target/scala-$majorVersion/spark-job-server.jar
bin/server_start.sh
bin/server_stop.sh
bin/kill-process-tree.sh
bin/manager_start.sh
bin/setenv.sh
$CONFIG_DIR/$ENV.conf
config/shiro.ini
config/log4j-server.properties"
rm -rf $WORK_DIR
mkdir -p $WORK_DIR
cp ${FILES} "${WORK_DIR}/"
cp "${configFile}" "${WORK_DIR}/settings.sh"
popd > /dev/null

rm -rf $WORK_DIR
mkdir -p $WORK_DIR
cp $FILES $WORK_DIR/
cp $configFile $WORK_DIR/settings.sh
pushd $WORK_DIR
TAR_FILE=$WORK_DIR/job-server.tar.gz
rm -f $TAR_FILE
tar zcvf $TAR_FILE *
popd
pushd "${WORK_DIR}" > /dev/null
TAR_FILE="${WORK_DIR}/job-server.tar.gz"
rm -f "${TAR_FILE}"
tar zcvf "${TAR_FILE}" ./*
popd > /dev/null

echo "Created distribution at $TAR_FILE"
echo "Created distribution at ${TAR_FILE}"

0 comments on commit 2b6aef7

Please sign in to comment.