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

Commit 1a9ce3b

Browse files
committed
Add POSIX compatibility
1 parent edffea3 commit 1a9ce3b

File tree

4 files changed

+426
-563
lines changed

4 files changed

+426
-563
lines changed

.github/workflows/ci.yaml.example

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
---
3+
name: CI
4+
5+
env:
6+
MAVEN_CLI_OPTS: '-Dspring.main.banner-mode=off --batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true'
7+
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'
8+
9+
on:
10+
pull_request:
11+
push:
12+
branches:
13+
- master
14+
15+
jobs:
16+
shellcheck:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Lint check
23+
uses: azohra/[email protected]
24+
with:
25+
path: "*.sh"
26+
27+
shfmt:
28+
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
steps:
32+
- uses: actions/checkout@v2
33+
- name: Download shfmt
34+
run: curl -sSL $SHFMT_URL -o ~/shfmt && chmod +x ~/shfmt
35+
env:
36+
SHFMT_URL: https://github.com/mvdan/sh/releases/download/v0.4.0/shfmt_v0.4.0_linux_amd64
37+
- name: Run shfmt
38+
run: ~/shfmt -l -w -i 2 .
39+
- name: Test if syntax is correct
40+
run: git diff --exit-code && echo "shfmt OK"

install-binary.sh

+48-67
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,66 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22

3-
set -ueo pipefail
3+
set -eu
44

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

119
RED='\033[0;31m'
12-
GREEN='\033[0;32m'
10+
#GREEN='\033[0;32m'
1311
#BLUE='\033[0;34m'
14-
YELLOW='\033[1;33m'
12+
#YELLOW='\033[1;33m'
1513
NOC='\033[0m'
1614

17-
# Find some tools
18-
case "${HELM_BIN}" in
19-
helm)
20-
HELM_DIR="$(dirname $(command -v helm))"
21-
;;
22-
*)
23-
HELM_DIR="$(dirname ${HELM_BIN})"
24-
;;
25-
esac
26-
27-
get_sha_256 () {
28-
if command -v sha256sum > /dev/null; then res=$(sha256sum $1)
29-
elif command -v shasum > /dev/null; then res=$(shasum -a 256 $1)
30-
else res=$(/usr/bin/shasum -a 256 $1)
31-
fi
32-
echo $res | cut -d ' ' -f 1
15+
download() {
16+
if command -v curl >/dev/null; then
17+
curl -sSfL "$1"
18+
elif command -v wget >/dev/null; then
19+
wget -q -O- "$1"
20+
else
21+
return 1
22+
fi
3323
}
3424

35-
# Install the helm wrapper in the same dir as helm itself. That's not
36-
# guaranteed to work, but it's better than hard-coding it.
37-
HELM_WRAPPER="${HELM_DIR}/helm-wrapper"
25+
get_sha_256() {
26+
if command -v sha256sum >/dev/null; then
27+
res=$(sha256sum "$1")
28+
elif command -v shasum >/dev/null; then
29+
res=$(shasum -a 256 "$1")
30+
else
31+
res=''
32+
fi
33+
34+
echo "$res" | cut -d ' ' -f 1
35+
}
3836

3937
if hash sops 2>/dev/null; then
40-
echo "sops is already installed:"
41-
sops --version
38+
echo "sops is already installed: "
39+
sops --version
4240
else
43-
44-
# Try to install sops.
45-
46-
### Mozilla SOPS binary install
47-
if [ "$(uname)" == "Darwin" ];
48-
then
49-
brew install sops
50-
elif [ "$(uname)" == "Linux" ];
51-
then
52-
if which dpkg;
53-
then
54-
curl -sL "${SOPS_DEB_URL}" > /tmp/sops
55-
if [ "$(get_sha_256 /tmp/sops)" == "${SOPS_DEB_SHA}" ];
56-
then
57-
sudo dpkg -i /tmp/sops;
58-
else
59-
echo -e "${RED}Wrong SHA256${NOC}"
60-
fi
61-
else
62-
curl -sL "${SOPS_LINUX_URL}" > /tmp/sops
63-
if [ "$(get_sha_256 /tmp/sops)" == "${SOPS_LINUX_SHA}" ];
64-
then
65-
chmod +x /tmp/sops
66-
mv /tmp/sops /usr/local/bin/
67-
else
68-
echo -e "${RED}Wrong SHA256${NOC}"
69-
fi
70-
fi
71-
rm /tmp/sops 2>/dev/null || true
41+
# Try to install sops.
42+
if [ "$(uname)" = "Darwin" ]; then
43+
brew install sops
44+
elif [ "$(uname)" = "Linux" ]; then
45+
if ! download "${SOPS_LINUX_URL}" >/tmp/sops; then
46+
printf "${RED}%s${NOC}\n" "Can't download SOPS ..."
7247
else
73-
echo -e "${RED}No SOPS package available${NOC}"
74-
exit 1
48+
SOPS_SHA256="$(get_sha_256 /tmp/sops)"
49+
if [ "${SOPS_SHA256}" = "${SOPS_LINUX_SHA}" ] || [ "${SOPS_SHA256}" = "" ]; then
50+
chmod +x /tmp/sops
51+
mv /tmp/sops /usr/local/bin/
52+
else
53+
printf "${RED}%s${NOC}\n" "Wrong SHA256"
54+
fi
55+
rm -f /tmp/sops
7556
fi
57+
else
58+
printf "${RED}%s${NOC}\n" "No SOPS package available"
59+
exit 1
60+
fi
7661
fi
7762

78-
### git diff config
79-
if [ -x "$(command -v git --version)" ];
80-
then
81-
git config --global diff.sopsdiffer.textconv "sops -d"
82-
else
83-
echo -e "${RED}[FAIL]${NOC} Install git command"
84-
exit 1
63+
# If git is no available, fail silent.
64+
if hash git 2>/dev/null; then
65+
git config --global diff.sopsdiffer.textconv "sops -d"
8566
fi

0 commit comments

Comments
 (0)