Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Add POSIX compatibility #153

Closed
wants to merge 1 commit into from
Closed
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
40 changes: 40 additions & 0 deletions .github/workflows/ci.yaml.example
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,40 @@

---
name: CI

env:
MAVEN_CLI_OPTS: '-Dspring.main.banner-mode=off --batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true'
MAVEN_OPTS: '-Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true'

on:
pull_request:
push:
branches:
- master

jobs:
shellcheck:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Lint check
uses: azohra/[email protected]
with:
path: "*.sh"

shfmt:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Download shfmt
run: curl -sSL $SHFMT_URL -o ~/shfmt && chmod +x ~/shfmt
env:
SHFMT_URL: https://github.com/mvdan/sh/releases/download/v0.4.0/shfmt_v0.4.0_linux_amd64
- name: Run shfmt
run: ~/shfmt -l -w -i 2 .
- name: Test if syntax is correct
run: git diff --exit-code && echo "shfmt OK"
87 changes: 34 additions & 53 deletions install-binary.sh
Original file line number Original file line Diff line number Diff line change
@@ -1,85 +1,66 @@
#!/usr/bin/env bash #!/usr/bin/env sh


set -ueo pipefail set -eu


SOPS_VERSION="3.0.4" SOPS_VERSION="3.5.0"
SOPS_DEB_URL="https://github.com/mozilla/sops/releases/download/${SOPS_VERSION}/sops_${SOPS_VERSION}_amd64.deb"
SOPS_DEB_SHA="9d9f319882ba05e7050be91bdfc396167ac9b00e2e6f634a647d55ac97915bb6"
SOPS_LINUX_URL="https://github.com/mozilla/sops/releases/download/${SOPS_VERSION}/sops-${SOPS_VERSION}.linux" SOPS_LINUX_URL="https://github.com/mozilla/sops/releases/download/${SOPS_VERSION}/sops-${SOPS_VERSION}.linux"
SOPS_LINUX_SHA="e185d2752defdcb18c054f67682a6684c72d6a6bf2341f6bef1dd7d33a110459" SOPS_LINUX_SHA="610fca9687d1326ef2e1a66699a740f5dbd5ac8130190275959da737ec52f096"


RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' #GREEN='\033[0;32m'
#BLUE='\033[0;34m' #BLUE='\033[0;34m'
YELLOW='\033[1;33m' #YELLOW='\033[1;33m'
NOC='\033[0m' NOC='\033[0m'


# Find some tools download() {
case "${HELM_BIN}" in if command -v curl >/dev/null; then
helm) curl -sSfL "$1"
HELM_DIR="$(dirname $(command -v helm))" elif command -v wget >/dev/null; then
;; wget -q -O- "$1"
*) else
HELM_DIR="$(dirname ${HELM_BIN})" return 1
;; fi
esac }


get_sha_256() { get_sha_256() {
if command -v sha256sum > /dev/null; then res=$(sha256sum $1) if command -v sha256sum >/dev/null; then
elif command -v shasum > /dev/null; then res=$(shasum -a 256 $1) res=$(sha256sum "$1")
else res=$(/usr/bin/shasum -a 256 $1) elif command -v shasum >/dev/null; then
res=$(shasum -a 256 "$1")
else
res=''
fi fi
echo $res | cut -d ' ' -f 1
}


# Install the helm wrapper in the same dir as helm itself. That's not echo "$res" | cut -d ' ' -f 1
# guaranteed to work, but it's better than hard-coding it. }
HELM_WRAPPER="${HELM_DIR}/helm-wrapper"


if hash sops 2>/dev/null; then if hash sops 2>/dev/null; then
echo "sops is already installed: " echo "sops is already installed: "
sops --version sops --version
else else

# Try to install sops. # Try to install sops.

if [ "$(uname)" = "Darwin" ]; then
### Mozilla SOPS binary install
if [ "$(uname)" == "Darwin" ];
then
brew install sops brew install sops
elif [ "$(uname)" == "Linux" ]; elif [ "$(uname)" = "Linux" ]; then
then if ! download "${SOPS_LINUX_URL}" >/tmp/sops; then
if which dpkg; printf "${RED}%s${NOC}\n" "Can't download SOPS ..."
then
curl -sL "${SOPS_DEB_URL}" > /tmp/sops
if [ "$(get_sha_256 /tmp/sops)" == "${SOPS_DEB_SHA}" ];
then
sudo dpkg -i /tmp/sops;
else
echo -e "${RED}Wrong SHA256${NOC}"
fi
else else
curl -sL "${SOPS_LINUX_URL}" > /tmp/sops SOPS_SHA256="$(get_sha_256 /tmp/sops)"
if [ "$(get_sha_256 /tmp/sops)" == "${SOPS_LINUX_SHA}" ]; if [ "${SOPS_SHA256}" = "${SOPS_LINUX_SHA}" ] || [ "${SOPS_SHA256}" = "" ]; then
then
chmod +x /tmp/sops chmod +x /tmp/sops
mv /tmp/sops /usr/local/bin/ mv /tmp/sops /usr/local/bin/
else else
echo -e "${RED}Wrong SHA256${NOC}" printf "${RED}%s${NOC}\n" "Wrong SHA256"
fi fi
rm -f /tmp/sops
fi fi
rm /tmp/sops 2>/dev/null || true
else else
echo -e "${RED}No SOPS package available${NOC}" printf "${RED}%s${NOC}\n" "No SOPS package available"
exit 1 exit 1
fi fi
fi fi


### git diff config # If git is no available, fail silent.
if [ -x "$(command -v git --version)" ]; if hash git 2>/dev/null; then
then
git config --global diff.sopsdiffer.textconv "sops -d" git config --global diff.sopsdiffer.textconv "sops -d"
else
echo -e "${RED}[FAIL]${NOC} Install git command"
exit 1
fi fi
Loading