Fix the script to make sure binary package can execute scripts correctly
- fix the release jar path
- copy the common script to each modules otherwise the built package won't be able to execute
- change the type of runner and copy the runner script to each tutorial module
Author: Sijie Guo <sijie@apache.org>
Reviewers: Jia Zhai <zhaijia@apache.org>
Closes #111 from sijie/sijie/copy_all_scripts_to_modules
diff --git a/scripts/common.sh b/distributedlog-benchmark/bin/common.sh
similarity index 94%
rename from scripts/common.sh
rename to distributedlog-benchmark/bin/common.sh
index 8df5248..0b8278c 100755
--- a/scripts/common.sh
+++ b/distributedlog-benchmark/bin/common.sh
@@ -54,13 +54,13 @@
[ -f "${DLOG_HOME}/conf/dlogenv.sh" ] && source "${DLOG_HOME}/conf/dlogenv.sh"
# exclude tests jar
-RELEASE_JAR=$(ls "${DLOG_HOME}/distributedlog-*.jar" 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
if [ $? == 0 ]; then
DLOG_JAR="${RELEASE_JAR}"
fi
# exclude tests jar
-BUILT_JAR=$(ls "${DLOG_HOME}"/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
if [ -e "${BUILD_JAR}" ] && [ -e "${DLOG_JAR}" ]; then
echo "\nCouldn't find dlog jar.";
diff --git a/distributedlog-benchmark/bin/dbench b/distributedlog-benchmark/bin/dbench
index afcca62..b2ffd65 100755
--- a/distributedlog-benchmark/bin/dbench
+++ b/distributedlog-benchmark/bin/dbench
@@ -21,9 +21,8 @@
set -e
BASEDIR=$(dirname "$0")
-DLOG_ROOT="${BASEDIR}/../.."
-DLOG_HOME="${DLOG_ROOT}/distributedlog-benchmark"
+DLOG_HOME="${BASEDIR}/.."
usage() {
cat <<EOF
@@ -44,7 +43,7 @@
EOF
}
-source ${DLOG_ROOT}/scripts/common.sh
+source ${DLOG_HOME}/bin/common.sh
# get arguments
COMMAND=$1
diff --git a/scripts/common.sh b/distributedlog-core/bin/common.sh
similarity index 94%
copy from scripts/common.sh
copy to distributedlog-core/bin/common.sh
index 8df5248..0b8278c 100755
--- a/scripts/common.sh
+++ b/distributedlog-core/bin/common.sh
@@ -54,13 +54,13 @@
[ -f "${DLOG_HOME}/conf/dlogenv.sh" ] && source "${DLOG_HOME}/conf/dlogenv.sh"
# exclude tests jar
-RELEASE_JAR=$(ls "${DLOG_HOME}/distributedlog-*.jar" 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
if [ $? == 0 ]; then
DLOG_JAR="${RELEASE_JAR}"
fi
# exclude tests jar
-BUILT_JAR=$(ls "${DLOG_HOME}"/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
if [ -e "${BUILD_JAR}" ] && [ -e "${DLOG_JAR}" ]; then
echo "\nCouldn't find dlog jar.";
diff --git a/distributedlog-core/bin/dlog b/distributedlog-core/bin/dlog
index bf48148..6a93eb3 100755
--- a/distributedlog-core/bin/dlog
+++ b/distributedlog-core/bin/dlog
@@ -21,9 +21,8 @@
set -e
BASEDIR=$(dirname "$0")
-DLOG_ROOT="${BASEDIR}/../.."
-DLOG_HOME="${DLOG_ROOT}/distributedlog-core"
+DLOG_HOME="${BASEDIR}/.."
usage() {
cat <<EOF
@@ -48,7 +47,7 @@
EOF
}
-source "${DLOG_ROOT}"/scripts/common.sh
+source "${DLOG_HOME}"/bin/common.sh
# get arguments
COMMAND=$1
diff --git a/scripts/common.sh b/distributedlog-service/bin/common.sh
similarity index 94%
copy from scripts/common.sh
copy to distributedlog-service/bin/common.sh
index 8df5248..0b8278c 100755
--- a/scripts/common.sh
+++ b/distributedlog-service/bin/common.sh
@@ -54,13 +54,13 @@
[ -f "${DLOG_HOME}/conf/dlogenv.sh" ] && source "${DLOG_HOME}/conf/dlogenv.sh"
# exclude tests jar
-RELEASE_JAR=$(ls "${DLOG_HOME}/distributedlog-*.jar" 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
if [ $? == 0 ]; then
DLOG_JAR="${RELEASE_JAR}"
fi
# exclude tests jar
-BUILT_JAR=$(ls "${DLOG_HOME}"/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
if [ -e "${BUILD_JAR}" ] && [ -e "${DLOG_JAR}" ]; then
echo "\nCouldn't find dlog jar.";
diff --git a/distributedlog-service/bin/dlog b/distributedlog-service/bin/dlog
index 30e8d38..99cad40 100755
--- a/distributedlog-service/bin/dlog
+++ b/distributedlog-service/bin/dlog
@@ -21,8 +21,7 @@
set -e
BASEDIR=$(dirname "$0")
-DLOG_ROOT="${BASEDIR}/.."
-DLOG_HOME="${DLOG_ROOT}"
+DLOG_HOME="${BASEDIR}/.."
usage() {
cat <<EOF
@@ -49,7 +48,7 @@
EOF
}
-source "${DLOG_ROOT}"/../scripts/common.sh
+source "${DLOG_HOME}"/bin/common.sh
# get arguments
COMMAND=$1
diff --git a/scripts/common.sh b/distributedlog-tutorials/distributedlog-basic/bin/common.sh
similarity index 94%
copy from scripts/common.sh
copy to distributedlog-tutorials/distributedlog-basic/bin/common.sh
index 8df5248..0b8278c 100755
--- a/scripts/common.sh
+++ b/distributedlog-tutorials/distributedlog-basic/bin/common.sh
@@ -54,13 +54,13 @@
[ -f "${DLOG_HOME}/conf/dlogenv.sh" ] && source "${DLOG_HOME}/conf/dlogenv.sh"
# exclude tests jar
-RELEASE_JAR=$(ls "${DLOG_HOME}/distributedlog-*.jar" 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
if [ $? == 0 ]; then
DLOG_JAR="${RELEASE_JAR}"
fi
# exclude tests jar
-BUILT_JAR=$(ls "${DLOG_HOME}"/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
if [ -e "${BUILD_JAR}" ] && [ -e "${DLOG_JAR}" ]; then
echo "\nCouldn't find dlog jar.";
diff --git a/distributedlog-tutorials/distributedlog-basic/bin/runner b/distributedlog-tutorials/distributedlog-basic/bin/runner
deleted file mode 120000
index 7a0fefc..0000000
--- a/distributedlog-tutorials/distributedlog-basic/bin/runner
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env bash
-#
-#/**
-# * Copyright 2007 The Apache Software Foundation
-# *
-# * Licensed to the Apache Software Foundation (ASF) under one
-# * or more contributor license agreements. See the NOTICE file
-# * distributed with this work for additional information
-# * regarding copyright ownership. The ASF licenses this file
-# * to you under the Apache License, Version 2.0 (the
-# * "License"); you may not use this file except in compliance
-# * with the License. You may obtain a copy of the License at
-# *
-# * http://www.apache.org/licenses/LICENSE-2.0
-# *
-# * Unless required by applicable law or agreed to in writing, software
-# * distributed under the License is distributed on an "AS IS" BASIS,
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# * See the License for the specific language governing permissions and
-# * limitations under the License.
-# */
-
-../../../scripts/runner
diff --git a/scripts/runner b/distributedlog-tutorials/distributedlog-basic/bin/runner
similarity index 95%
rename from scripts/runner
rename to distributedlog-tutorials/distributedlog-basic/bin/runner
index 78ce126..be23e00 100755
--- a/scripts/runner
+++ b/distributedlog-tutorials/distributedlog-basic/bin/runner
@@ -23,7 +23,6 @@
set -e
BASEDIR=$(dirname "$0")
-DLOG_ROOT="${BASEDIR}/../../.."
DLOG_HOME="${BASEDIR}/.."
usage() {
@@ -44,7 +43,7 @@
EOF
}
-source "${DLOG_ROOT}/scripts/common.sh"
+source "${DLOG_HOME}/bin/common.sh"
# get arguments
COMMAND="${1}"
diff --git a/scripts/common.sh b/distributedlog-tutorials/distributedlog-messaging/bin/common.sh
similarity index 94%
copy from scripts/common.sh
copy to distributedlog-tutorials/distributedlog-messaging/bin/common.sh
index 8df5248..0b8278c 100755
--- a/scripts/common.sh
+++ b/distributedlog-tutorials/distributedlog-messaging/bin/common.sh
@@ -54,13 +54,13 @@
[ -f "${DLOG_HOME}/conf/dlogenv.sh" ] && source "${DLOG_HOME}/conf/dlogenv.sh"
# exclude tests jar
-RELEASE_JAR=$(ls "${DLOG_HOME}/distributedlog-*.jar" 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+RELEASE_JAR=$(ls ${DLOG_HOME}/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
if [ $? == 0 ]; then
DLOG_JAR="${RELEASE_JAR}"
fi
# exclude tests jar
-BUILT_JAR=$(ls "${DLOG_HOME}"/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
+BUILT_JAR=$(ls ${DLOG_HOME}/target/distributedlog-*.jar 2> /dev/null | grep -v 'tests|javadoc|sources' | tail -1)
if [ -e "${BUILD_JAR}" ] && [ -e "${DLOG_JAR}" ]; then
echo "\nCouldn't find dlog jar.";
diff --git a/distributedlog-tutorials/distributedlog-messaging/bin/runner b/distributedlog-tutorials/distributedlog-messaging/bin/runner
deleted file mode 120000
index 7a0fefc..0000000
--- a/distributedlog-tutorials/distributedlog-messaging/bin/runner
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env bash
-#
-#/**
-# * Copyright 2007 The Apache Software Foundation
-# *
-# * Licensed to the Apache Software Foundation (ASF) under one
-# * or more contributor license agreements. See the NOTICE file
-# * distributed with this work for additional information
-# * regarding copyright ownership. The ASF licenses this file
-# * to you under the Apache License, Version 2.0 (the
-# * "License"); you may not use this file except in compliance
-# * with the License. You may obtain a copy of the License at
-# *
-# * http://www.apache.org/licenses/LICENSE-2.0
-# *
-# * Unless required by applicable law or agreed to in writing, software
-# * distributed under the License is distributed on an "AS IS" BASIS,
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# * See the License for the specific language governing permissions and
-# * limitations under the License.
-# */
-
-../../../scripts/runner
diff --git a/scripts/runner b/distributedlog-tutorials/distributedlog-messaging/bin/runner
similarity index 95%
copy from scripts/runner
copy to distributedlog-tutorials/distributedlog-messaging/bin/runner
index 78ce126..be23e00 100755
--- a/scripts/runner
+++ b/distributedlog-tutorials/distributedlog-messaging/bin/runner
@@ -23,7 +23,6 @@
set -e
BASEDIR=$(dirname "$0")
-DLOG_ROOT="${BASEDIR}/../../.."
DLOG_HOME="${BASEDIR}/.."
usage() {
@@ -44,7 +43,7 @@
EOF
}
-source "${DLOG_ROOT}/scripts/common.sh"
+source "${DLOG_HOME}/bin/common.sh"
# get arguments
COMMAND="${1}"
diff --git a/scripts/integration/smoketest.sh b/scripts/integration/smoketest.sh
index 991dc6b..0de830d 100755
--- a/scripts/integration/smoketest.sh
+++ b/scripts/integration/smoketest.sh
@@ -88,10 +88,20 @@
sleep 20
# kill the writer
-kill `cat ${LOG_DIR}/writer.pid`
+if [ -f ${LOG_DIR}/writer.pid ]; then
+ writerpid=$(cat ${LOG_DIR}/writer.pid)
+ if kill -0 $writerpid > /dev/null 2>&1; then
+ kill $writerpid
+ fi
+fi
# stop the reader
-kill `cat ${LOG_DIR}/reader.pid`
+if [ -f ${LOG_DIR}/reader.pid ]; then
+ readerpid=$(cat ${LOG_DIR}/reader.pid)
+ if kill -0 $readerpid > /dev/null 2>&1; then
+ kill $readerpid
+ fi
+fi
# check the number of records received
NUM_RECORDS=`cat ${LOG_DIR}/reader.out | grep "record-" | wc -l`