Browse Source

[scripts] declare bash function in portable fashion

tags/7.5
Sébastien Lesaint 6 years ago
parent
commit
7e59b1e27f
6 changed files with 21 additions and 21 deletions
  1. 5
    5
      scripts/editions.sh
  2. 4
    4
      scripts/generate_batch_reports.sh
  3. 4
    4
      scripts/logs.sh
  4. 3
    3
      scripts/property_utils.sh
  5. 1
    1
      scripts/stop.sh
  6. 4
    4
      travis.sh

+ 5
- 5
scripts/editions.sh View File

@@ -5,11 +5,11 @@ set -euo pipefail
DEFAULT_EDITION="oss"
EDITIONS="oss"

function toLower() {
toLower() {
echo "$1" | tr '[:upper:]' '[:lower:]'
}

function checkEditionArgument() {
checkEditionArgument() {
local editionArg="$1"
local lowerEditionArg=$(toLower $editionArg)

@@ -27,7 +27,7 @@ function checkEditionArgument() {
exit 1
}

function distributionDirOf() {
distributionDirOf() {
local edition="$1"

if [ "$edition" = "oss" ]; then
@@ -38,7 +38,7 @@ function distributionDirOf() {
fi
}

function baseFileNameOf() {
baseFileNameOf() {
local edition="$1"

if [ "$edition" = "oss" ]; then
@@ -49,7 +49,7 @@ function baseFileNameOf() {
fi
}

function targetDirOf() {
targetDirOf() {
local edition="$1"

if [ "$edition" = "oss" ]; then

+ 4
- 4
scripts/generate_batch_reports.sh View File

@@ -16,11 +16,11 @@

set -euo pipefail

function clean() {
clean() {
rm -Rf $BUILD_DIR
}

function createPrivateClone() {
createPrivateClone() {
BRANCH=$(git symbolic-ref -q HEAD)
BRANCH=${BRANCH##refs/heads/}
BRANCH=${BRANCH:-HEAD}
@@ -39,7 +39,7 @@ function createPrivateClone() {
cd ${BUILD_DIR}${RELATIVE_PATH}
}

function showHelp() {
showHelp() {
echo "Usage: $0 -d DIR_PATH [ -l integer ] [ -h URL ] [ -u string ] [ -p string ]
-d : path to directory where batch report bumpds will be created
-l : number of commit in the past (optional: default is $HISTORY_LENGTH)
@@ -48,7 +48,7 @@ function showHelp() {
-p : password to authentication on the SQ instance (optional: default is $SONAR_USER)"
}

function checkOptions() {
checkOptions() {
if [[ -z "$DUMP_DIR" ]]; then
>&2 echo "-d option is mandatory"
showHelp

+ 4
- 4
scripts/logs.sh View File

@@ -23,11 +23,11 @@ DEFAULT_LOG="all"
DEFAULT_LINES="25"
LOGS="sonar web ce es"

function toLower() {
toLower() {
echo "$1" | tr '[:upper:]' '[:lower:]'
}

function checkLogArgument() {
checkLogArgument() {
local logArg="$1"
local lowerLogArg=$(toLower $logArg)

@@ -45,7 +45,7 @@ function checkLogArgument() {
exit 1
}

function buildTailArgs() {
buildTailArgs() {
local logArg="$(toLower $1)"
local logLines="$2"
local res=""
@@ -59,7 +59,7 @@ function buildTailArgs() {
echo "$res"
}

function doTail() {
doTail() {
local logArg="$1"
local logLines="${2:-"$DEFAULT_LINES"}"
TAIL_ARG=$(buildTailArgs "$logArg" "$logLines")

+ 3
- 3
scripts/property_utils.sh View File

@@ -8,12 +8,12 @@

set -euo pipefail

function cnt_lines {
cnt_lines() {
local FILE=$1
wc -l < "$FILE"
}

function write_prop {
write_prop() {
local PROPERTY=$1
local VALUE=$2
local FILE=$3
@@ -25,7 +25,7 @@ function write_prop {
echo "${PROPERTY}=${VALUE}" >> "$FILE"
}

function set_property {
set_property() {
local PROPERTY=$1
local VALUE=$2
local FILE=$3

+ 1
- 1
scripts/stop.sh View File

@@ -17,7 +17,7 @@ else
OS='linux-x86-64'
fi

function stopAny() {
stopAny() {
for edition in $EDITIONS; do
SONAR_SH="$(distributionDirOf "$edition")/$(targetDirOf "$edition")/sonarqube-*/bin/$OS/sonar.sh"
if ls $SONAR_SH &> /dev/null; then

+ 4
- 4
travis.sh View File

@@ -9,7 +9,7 @@ set -euo pipefail
# JDK is kept in cache. It does not need to be downloaded from Oracle
# at each build.
#
function installJdk8 {
installJdk8() {
echo "Setup JDK 1.8u171"
mkdir -p ~/jvm
pushd ~/jvm > /dev/null
@@ -26,7 +26,7 @@ function installJdk8 {
#
# Configure Maven settings and install some script utilities
#
function configureTravis {
configureTravis() {
mkdir -p ~/.local
curl -sSL https://github.com/SonarSource/travis-utils/tarball/v47 | tar zx --strip-components 1 -C ~/.local
source ~/.local/bin/install
@@ -35,10 +35,10 @@ configureTravis

#
# Travis fails on timeout when build does not print logs
# during 10 minutes. This function aims to bypass this
# during 10 minutes. This aims to bypass this
# behavior when building the slow sonar-server sub-project.
#
function keep_alive() {
keep_alive() {
while true; do
echo -en "\a"
sleep 60

Loading…
Cancel
Save