This repository has been archived by the owner on Jun 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 155
/
install-binary.sh
executable file
·89 lines (78 loc) · 2.51 KB
/
install-binary.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
set -ueo pipefail
SOPS_VERSION="3.0.4"
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_SHA="e185d2752defdcb18c054f67682a6684c72d6a6bf2341f6bef1dd7d33a110459"
RED='\033[0;31m'
GREEN='\033[0;32m'
#BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NOC='\033[0m'
# Find some tools
case "${HELM_BIN}" in
helm)
HELM_DIR="$(dirname $(command -v helm))"
;;
*)
HELM_DIR="$(dirname ${HELM_BIN})"
;;
esac
get_sha_256 () {
if command -v sha256sum > /dev/null; then res=$(sha256sum $1)
elif command -v shasum > /dev/null; then res=$(shasum -a 256 $1)
else res=$(/usr/bin/shasum -a 256 $1)
fi
echo $res | cut -d ' ' -f 1
}
# Install the helm wrapper in the same dir as helm itself. That's not
# guaranteed to work, but it's better than hard-coding it.
HELM_WRAPPER="${HELM_DIR}/helm-wrapper"
if hash sops 2>/dev/null; then
echo "sops is already installed:"
sops --version
else
# Try to install sops.
### Mozilla SOPS binary install
if [ "$(uname)" == "Darwin" ];
then
brew install sops
elif [ "$(uname)" == "Linux" ];
then
if which dpkg;
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
curl -sL "${SOPS_LINUX_URL}" > /tmp/sops
if [ "$(get_sha_256 /tmp/sops)" == "${SOPS_LINUX_SHA}" ];
then
chmod +x /tmp/sops
mv /tmp/sops /usr/local/bin/
else
echo -e "${RED}Wrong SHA256${NOC}"
fi
fi
rm /tmp/sops 2>/dev/null || true
else
echo -e "${RED}No SOPS package available${NOC}"
exit 1
fi
fi
### git diff config
if [ -x "$(command -v git --version)" ];
then
git config --global diff.sopsdiffer.textconv "sops -d"
else
echo -e "${RED}[FAIL]${NOC} Install git command"
exit 1
fi
echo "Deprecation Info"
echo " Please note, this project is no longer being maintained."
echo " Link to active helm-secret plugin could be found in helm documentation: https://helm.sh/docs/community/related/#helm-plugins"