forked from flipt-io/flipt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·112 lines (102 loc) · 2.69 KB
/
install.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
#
# _________ __
# / ____/ (_)___ / /_
# / /_ / / / __ \/ __/
# / __/ / / / /_/ / /_
# /_/ /_/_/ .___/\__/
# /_/
#
# Flipt installer
#
# Usage:
# curl -fsSL https://github.com/flipt-io/flipt/raw/main/install.sh | sh
set -e
file_issue_prompt() {
echo "If you wish us to support your platform, please file an issue"
echo "https://github.com/flipt-io/flipt/issues/new"
exit 1
}
get_latest_version() {
res=$(curl -fsSL https://api.github.com/repos/flipt-io/flipt/releases/latest | grep tag_name | cut -d '"' -f 4)
echo "$res"
}
copy() {
case ":PATH:" in
*":HOME/.local/bin:"*)
[ ! -d "$HOME/.local/bin" ] && mkdir -p "$HOME/.local/bin"
mv /tmp/flipt "$HOME/.local/bin/flipt"
;;
*)
mv /tmp/flipt /usr/local/bin/flipt || (
echo "Cannot write to installation target directory as current user, writing as root."
sudo mv /tmp/flipt /usr/local/bin/flipt
)
;;
esac
}
# This function decides what version will be installed based on the following priority:
# 1. Environment variable `VERSION` is set.
# 2. Latest available on GitHub
get_version() {
if [ -z "$VERSION" ]; then
if [ -n "$1" ]; then
VERSION="$1"
else
VERSION=$(get_latest_version)
fi
fi
# ensure version starts with v
case "$VERSION" in
v*) : ;;
*) VERSION="v$VERSION" ;;
esac
echo "$VERSION"
}
install() {
version=$(get_version "$1");
echo "Installing version $version"
OSCHECK=$(uname | tr '[:upper:]' '[:lower:]')
case "$OSCHECK" in
linux*)
ARCH=$(uname -m)
OS="linux"
case "$ARCH" in
x86_64|aarch64) : ;;
*)
echo "flipt is only available for linux x86_64/arm64 architecture"
file_issue_prompt
;;
esac
[ "$ARCH" = "aarch64" ] && ARCH="arm64"
;;
darwin*)
ARCH=$(uname -m)
OS="darwin"
case "$ARCH" in
x86_64|arm64) : ;;
*)
echo "flipt is only available for mac x86_64/arm64 architecture"
file_issue_prompt
;;
esac
[ "$ARCH" = "aarch64" ] && ARCH="arm64"
;;
*)
echo "flipt isn't supported for your platform - $OSTYPE"
file_issue_prompt
;;
esac
curl -o /tmp/flipt.tar.gz -fsSL https://download.flipt.io/flipt/$version/$OS\_$ARCH.tar.gz
tar -xzf /tmp/flipt.tar.gz -C /tmp
chmod +x /tmp/flipt
copy
echo ""
echo "Flipt installed!"
echo ""
echo "For feedback and support, join our Discord server: https://flipt.io/discord,"
echo "open an issue or discussion on GitHub: https://github.com/flipt-io/flipt/"
echo "or send us an email at [email protected]"
echo ""
}
install "$1"