-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·62 lines (53 loc) · 1.26 KB
/
install.sh
File metadata and controls
executable file
·62 lines (53 loc) · 1.26 KB
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
#!/usr/bin/env sh
detect_platform() {
platform="$(uname -s | tr '[:upper:]' '[:lower:]')"
case "${platform}" in
linux) platform="linux" ;;
darwin) platform="darwin" ;;
esac
printf '%s' "${platform}"
}
detect_arch() {
arch="$(uname -m | tr '[:upper:]' '[:lower:]')"
case "${arch}" in
x86_64) arch="amd64" ;;
armv*) arch="arm" ;;
arm64) arch="arm64" ;;
esac
printf '%s' "${arch}"
}
has_bindir() {
if [ ! -d "$BIN_DIR" ]; then
echo "Installation location $BIN_DIR does not appear to be a directory"
echo "Make sure the location exists and is a directory, then try again."
exit 1
fi
}
can_write() {
fake_file=$1/total_bs.txt
if touch "${fake_file}" 2>/dev/null; then
rm "${fake_file}"
return 0
fi
return 1
}
download() {
platform=$1
arch=$2
sudo=""
if ! can_write $BIN_DIR; then
sudo="sudo"
fi
echo "$BIN_DIR/spamd $BASE_URL/spamd_${platform}_${arch}"
${sudo} curl --fail --location --output $BIN_DIR/spamd $BASE_URL/spamd_${platform}_${arch}
${sudo} chmod +x $BIN_DIR/spamd
}
do_install() {
platform=$(detect_platform)
arch=$(detect_arch)
has_bindir
download "${platform}" "${arch}"
}
BIN_DIR=/usr/local/bin
BASE_URL=https://github.com/Vui-Chee/spamd/releases/latest/download
do_install