Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO_NOT_MERGE] Update scripts so that they are compatible with bash and zsh. #5809

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/build-images/build-images.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
if [ "$TAG" == "" ]; then
if [ "$TAG" = "" ]; then
echo "TAG not found"
exit 1
fi
Expand Down Expand Up @@ -45,7 +45,7 @@ for ((i = 0; i < LEN; i++)); do
fi
docker push "$IMAGE:$TAG-jdk$v"
echo "Pushed $IMAGE:$TAG-jdk$v"
if [ "$DEFAULT_JDK" == "$v" ]; then
if [ "$DEFAULT_JDK" = "$v" ]; then
docker tag "$IMAGE:$TAG-jdk$DEFAULT_JDK" "$IMAGE:$TAG"
docker push "$IMAGE:$TAG"
echo "Pushed $IMAGE:$TAG"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function check_env() {
eval ev='$'$1
if [ "$ev" == "" ]; then
if [ "$ev" = "" ]; then
echo "env var $1 not defined"
if ((sourced != 0)); then
return 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
function check_env() {
eval ev='$'$1
if [ "$ev" == "" ]; then
if [ "$ev" = "" ]; then
echo "env var $1 not defined"
if ((sourced != 0)); then
return 1
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/publish-bundle/publish-bundle.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -e
IMG_PKG_OPT=
if [ "$USE_SRP" == "true" ]; then
if [ "$USE_SRP" = "true" ]; then
IMG_PKG_OPT="--debug"
if [ "$SSL_CERT_FILE" != "" ] && [ -f "$SSL_CERT_FILE" ]; then
IMG_PKG_OPT="$IMG_PKG_OPT --registry-ca-cert-path $SSL_CERT_FILE"
Expand Down
31 changes: 20 additions & 11 deletions .github/workflows/build-image.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
#!/usr/bin/env bash
if [ -z "$BASH_VERSION" ]; then
echo "This script requires Bash. Use: bash $0 $*"
exit 1
if [ -n "$BASH_SOURCE" ]; then
SCDIR="$(readlink -f "${BASH_SOURCE[0]}")"
elif [ -n "$ZSH_VERSION" ]; then
setopt function_argzero
SCDIR="${(%):-%N}"
elif eval '[[ -n ${.sh.file} ]]' 2>/dev/null; then
eval 'SCDIR=${.sh.file}'
else
echo 1>&2 "Unsupported shell. Please use bash, ksh93 or zsh."
exit 2
fi
SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
SCDIR="$(dirname "$SCDIR")"
SCDIR="$(realpath "$SCDIR")"

set +e
if [ "$PUSH" == "" ]; then
if [ "$PUSH" = "" ]; then
PUSH=true
fi
if [ "$TAG" == "" ]; then
if [ "$TAG" = "" ]; then
echo "TAG not found"
exit 1
fi
Expand Down Expand Up @@ -66,8 +75,8 @@ for v in 8 11 17; do
exit $RC
fi
echo "Created: $REPO:$TAG-jdk$v"
if [ "$PUSH" == "true" ]; then
if [ "$DELETE_TAGS" == "true" ]; then
if [ "$PUSH" = "true" ]; then
if [ "$DELETE_TAGS" = "true" ]; then
$SCDIR/docker-rm-tag.sh $REPO $TAG-jdk$v
fi
docker push "$REPO:$TAG-jdk$v"
Expand All @@ -80,10 +89,10 @@ for v in 8 11 17; do
echo "Skipped push $REPO:$TAG-jdk$v"
fi

if [ "$DEFAULT_JDK" == "$v" ]; then
if [ "$DEFAULT_JDK" = "$v" ]; then
docker tag "$REPO:$TAG-jdk$DEFAULT_JDK" "$REPO:$TAG"
if [ "$PUSH" == "true" ]; then
if [ "$DELETE_TAGS" == "true" ]; then
if [ "$PUSH" = "true" ]; then
if [ "$DELETE_TAGS" = "true" ]; then
$SCDIR/docker-rm-tag.sh $REPO $TAG-jdk$v
fi
docker push "$REPO:$TAG"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/skipper-docs-name.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/usr/bin/env bash
VERSION=$1
if [ "$1" == "" ]; then
if [ "$1" = "" ]; then
echo "Version is required"
exit 1
fi
Expand All @@ -9,16 +9,16 @@ if [ "$2" != "" ]; then
fi

if [ -z "$REPO" ]; then
if [[ "$VERSION" == *"-SNAPSHOT"* ]]; then
if [[ "$VERSION" = *"-SNAPSHOT"* ]]; then
REPO="libs-snapshot-local"
elif [[ "$VERSION" == *"-M"* ]] || [[ "${VERSION}" == *"-RC"* ]]; then
elif [[ "$VERSION" = *"-M"* ]] || [[ "${VERSION}" = *"-RC"* ]]; then
REPO="libs-milestone-local"
else
REPO="libs-release-local"
fi
fi
CURL_TOKEN="$ARTIFACTORY_USERNAME:$ARTIFACTORY_PASSWORD"
if [[ "$REPO" == *"snapshot"* ]]; then
if [[ "$REPO" = *"snapshot"* ]]; then
META_DATA_URL="https://repo.spring.io/artifactory/$REPO/org/springframework/cloud/spring-cloud-skipper-docs/${VERSION}/maven-metadata.xml"
curl -u "$CURL_TOKEN" --basic -o maven-metadata.xml -s -XGET -L "$META_DATA_URL" # > /dev/null
DL_TS=$(xmllint --xpath "/metadata/versioning/snapshot/timestamp/text()" maven-metadata.xml | sed 's/\.//')
Expand Down
22 changes: 16 additions & 6 deletions spring-cloud-dataflow-package/set-package-version.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
#!/usr/bin/env bash
if [ -z "$BASH_VERSION" ]; then
echo "This script requires Bash. Use: bash $0 $*"
exit 0
if [ -n "$BASH_SOURCE" ]; then
SCDIR="$(readlink -f "${BASH_SOURCE[0]}")"
elif [ -n "$ZSH_VERSION" ]; then
setopt function_argzero
SCDIR="${(%):-%N}"
elif eval '[[ -n ${.sh.file} ]]' 2>/dev/null; then
eval 'SCDIR=${.sh.file}'
else
echo 1>&2 "Unsupported shell. Please use bash, ksh93 or zsh."
exit 2
fi
SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
MVNW=$SCDIR/../mvnw
SCDIR="$(dirname "$SCDIR")"
ROOTDIR="$(realpath "$SCDIR/..")"
MVNW="$ROOTDIR/mvnw"
pushd "$ROOTDIR" > /dev/null
if [ "$PACKAGE_VERSION" = "" ]; then
$MVNW help:evaluate -Dexpression=project.version -q -DforceStdout > /dev/null
PACKAGE_VERSION=$($MVNW help:evaluate -Dexpression=project.version -q -DforceStdout)
if [[ "$PACKAGE_VERSION" == *"Downloading"* ]]; then
if [[ "$PACKAGE_VERSION" = *"Downloading"* ]]; then
PACKAGE_VERSION=$($MVNW help:evaluate -Dexpression=project.version -q -DforceStdout)
fi
fi
Expand All @@ -20,3 +29,4 @@ if [[ "$PACKAGE_VERSION" != *"SNAPSHOT"* ]]; then
echo "Setting scdf-type.oss.release=$PACKAGE_VERSION"
yq ".scdf-type.oss.release=\"$PACKAGE_VERSION\"" -i "$SCDIR/../src/deploy/versions.yaml"
fi
popd
25 changes: 16 additions & 9 deletions spring-cloud-skipper/local/create-container.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#!/usr/bin/env bash
if [ -z "$BASH_VERSION" ]; then
echo "This script requires Bash. Use: bash $0 $*"
exit 0
if [ -n "$BASH_SOURCE" ]; then
SCDIR="$(readlink -f "${BASH_SOURCE[0]}")"
elif [ -n "$ZSH_VERSION" ]; then
setopt function_argzero
SCDIR="${(%):-%N}"
elif eval '[[ -n ${.sh.file} ]]' 2>/dev/null; then
eval 'SCDIR=${.sh.file}'
else
echo 1>&2 "Unsupported shell. Please use bash, ksh93 or zsh."
exit 2
fi
SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
SCDIR=$(realpath $SCDIR)
ROOT_DIR=$(realpath $SCDIR/..)
SCDIR="$(dirname "$SCDIR")"

ROOT_DIR=$(realpath "$SCDIR/..")
# set to specific version
if [ "$1" != "" ]; then
TAG=$1
Expand All @@ -18,13 +25,13 @@ else
v=11
fi
PROCESSOR=$(uname -p)
if [ "$ARCH" == "" ]; then
if [ "$ARCH" = "" ]; then
case $PROCESSOR in
"x86_64")
ARCH=amd64
;;
*)
if [[ "$PROCESSOR" == *"arm"* ]]; then
if [[ "$PROCESSOR" = *"arm"* ]]; then
ARCH=arm64v8
fi
;;
Expand All @@ -38,4 +45,4 @@ if [ "$DOCKER_USERNAME" != "" ]; then
fi
jib jar --from=$IMAGE $CRED \
--target=docker://springcloud/spring-cloud-skipper-server:$TAG \
$ROOT_DIR/spring-cloud-skipper-server/target/spring-cloud-skipper-server-$TAG.jar
"$ROOT_DIR/spring-cloud-skipper-server/target/spring-cloud-skipper-server-$TAG.jar"
25 changes: 16 additions & 9 deletions spring-cloud-skipper/local/download-app.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
#!/usr/bin/env bash
if [ -z "$BASH_VERSION" ]; then
echo "This script requires Bash. Use: bash $0 $*"
exit 0
if [ -n "$BASH_SOURCE" ]; then
SCDIR="$(readlink -f "${BASH_SOURCE[0]}")"
elif [ -n "$ZSH_VERSION" ]; then
setopt function_argzero
SCDIR="${(%):-%N}"
elif eval '[[ -n ${.sh.file} ]]' 2>/dev/null; then
eval 'SCDIR=${.sh.file}'
else
echo 1>&2 "Unsupported shell. Please use bash, ksh93 or zsh."
exit 2
fi
SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
SCDIR=$(realpath $SCDIR)
ROOT_DIR=$(realpath $SCDIR/..)
SCDIR="$(dirname "$SCDIR")"

ROOT_DIR=$(realpath "$SCDIR/..")

if [ "$1" != "" ]; then
VER=$1
else
VER=2.9.0-SNAPSHOT
VER=2.11.3-SNAPSHOT
fi

function download_deps() {
Expand All @@ -36,7 +43,7 @@ function download_deps() {
VERSION=$(echo "$DEP" | awk -F":" '{split($0,a); print a[3]}')
echo "Dependency: groupId: $GROUP_ID, artifactId: $ARTIFACT_ID, version: $VERSION"
TS=
if [ "$INC_VER" == "true" ]; then
if [ "$INC_VER" = "true" ]; then
DEP_PATH="${DEP//\:/\/}"
META_DATA="$URL/${GROUP_ID//\./\/}/$ARTIFACT_ID/$VERSION/maven-metadata.xml"
echo "Reading $META_DATA"
Expand Down Expand Up @@ -76,7 +83,7 @@ function download_deps() {
TARGET_FILE="${TARGET}/${ARTIFACT_ID}-${VERSION}.${EXT}"
if [ "$TS" != "" ] && [ "$DS" != "" ] && [ -f "$TARGET_FILE" ]; then
FD=$(date -r "$TARGET_FILE" +"%Y-%m-%d %H:%M:%S")
if [ "$FD" == "$DS" ]; then
if [ "$FD" = "$DS" ]; then

echo "$(realpath --relative-to $PWD $TARGET_FILE) has same timestamp ($FD) as $SOURCE."
echo "Skipping download"
Expand Down
18 changes: 13 additions & 5 deletions src/deploy/carvel/add-local-registry-secret.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#!/usr/bin/env bash
if [ -z "$BASH_VERSION" ]; then
echo "This script requires Bash. Use: bash $0 $*"
exit 1
if [ -n "$BASH_SOURCE" ]; then
SCDIR="$(readlink -f "${BASH_SOURCE[0]}")"
elif [ -n "$ZSH_VERSION" ]; then
setopt function_argzero
SCDIR="${(%):-%N}"
elif eval '[[ -n ${.sh.file} ]]' 2>/dev/null; then
eval 'SCDIR=${.sh.file}'
else
echo 1>&2 "Unsupported shell. Please use bash, ksh93 or zsh."
exit 2
fi
SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
SCDIR="$(dirname "$SCDIR")"

function check_env() {
eval ev='$'$1
if [ "$ev" == "" ]; then
if [ "$ev" = "" ]; then
echo "env var $1 not defined"
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions src/deploy/carvel/add-roles.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
function add_role() {
ROLE=$1
ROLE_NAME=$(echo "rolebinding-$NS-default-$ROLE" | sed 's/:/-/g')
Expand All @@ -16,7 +16,7 @@ function add_role() {
--clusterrole=$ROLE \
--group=system:authenticated --namespace $NS
}
if [ "$NS" == "" ]; then
if [ "$NS" = "" ]; then
echo "NS not defined"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion src/deploy/carvel/carvel-add-package.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
function check_env() {
eval ev='$'$1
if [ "$ev" == "" ]; then
if [ "$ev" = "" ]; then
echo "env var $1 not defined"
exit 1
fi
Expand Down
18 changes: 13 additions & 5 deletions src/deploy/carvel/carvel-add-registry-secret.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#!/usr/bin/env bash
if [ -z "$BASH_VERSION" ]; then
echo "This script requires Bash. Use: bash $0 $*"
exit 1
if [ -n "$BASH_SOURCE" ]; then
SCDIR="$(readlink -f "${BASH_SOURCE[0]}")"
elif [ -n "$ZSH_VERSION" ]; then
setopt function_argzero
SCDIR="${(%):-%N}"
elif eval '[[ -n ${.sh.file} ]]' 2>/dev/null; then
eval 'SCDIR=${.sh.file}'
else
echo 1>&2 "Unsupported shell. Please use bash, ksh93 or zsh."
exit 2
fi
SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
SCDIR="$(dirname "$SCDIR")"

function check_env() {
eval ev='$'$1
if [ "$ev" == "" ]; then
if [ "$ev" = "" ]; then
echo "env var $1 not defined"
exit 1
fi
Expand Down
18 changes: 13 additions & 5 deletions src/deploy/carvel/carvel-deploy-package.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#!/usr/bin/env bash
if [ -z "$BASH_VERSION" ]; then
echo "This script requires Bash. Use: bash $0 $*"
exit 1
if [ -n "$BASH_SOURCE" ]; then
SCDIR="$(readlink -f "${BASH_SOURCE[0]}")"
elif [ -n "$ZSH_VERSION" ]; then
setopt function_argzero
SCDIR="${(%):-%N}"
elif eval '[[ -n ${.sh.file} ]]' 2>/dev/null; then
eval 'SCDIR=${.sh.file}'
else
echo 1>&2 "Unsupported shell. Please use bash, ksh93 or zsh."
exit 2
fi
SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
SCDIR="$(dirname "$SCDIR")"

function check_env() {
eval ev='$'$1
if [ "$ev" == "" ]; then
if [ "$ev" = "" ]; then
echo "env var $1 not defined"
exit 1
fi
Expand Down
6 changes: 3 additions & 3 deletions src/deploy/carvel/carvel-import-secret.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ if [ "$3" != "" ] && [ "$3" != "--import" ] && [ "$3" != "--placeholder" ]; then
else
FROM_NAMESPACE=secret-ns
fi
if [ "$3" == "--import" ]; then
if [ "$3" = "--import" ]; then
IMPORT_TYPE=import
elif [ "$3" == "--placeholder" ]; then
elif [ "$3" = "--placeholder" ]; then
IMPORT_TYPE=placeholder
fi
if [ "$SECRET_NAME" = "" ]; then
Expand All @@ -25,7 +25,7 @@ if [ "$NAMESPACE" = "" ]; then
echo "NAMESPACE required"
exit 2
fi
if [ "$IMPORT_TYPE" == "import" ]; then
if [ "$IMPORT_TYPE" = "import" ]; then
kubectl apply -f - <<EOF
apiVersion: secretgen.carvel.dev/v1alpha1
kind: SecretImport
Expand Down
Loading
Loading