Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #691 from sks/patch-1
Fix issues reported by shellcheck
- Loading branch information
Showing
1 changed file
with
43 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}" |