-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·61 lines (52 loc) · 1.55 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
#!/usr/bin/env sh
# This script installs veidemannctl
#
# It tries to detect the architecture and operating system
# and downloads the appropriate binary.
#
# If you want to install a specific version or architecture
# you can set the environment variables VERSION and ARCH
# before running this script.
#
# For example:
# $ VERSION=1.0.0 ARCH=arm64 ./install.sh
#
# This script requires curl, sed and tr to be installed.
set -e
RELEASES="https://github.com/nlnwa/veidemannctl/releases"
# Detect architecture
ARCH=${ARCH:-$(uname -m)}
case $ARCH in
"x86_64")
ARCH="amd64"
;;
"aarch64"|"arm64")
ARCH="arm64"
;;
"armv7l")
ARCH="armv7"
;;
"armv6l"|"aprm")
ARCH="armv6"
;;
"armv5l")
ARCH="armv5"
;;
esac
# Detect operating system
KERNEL=$(uname -s | tr '[:upper:]' '[:lower:]')
# Detect version
VERSION=${VERSION:-$(curl -s -I "${RELEASES}/latest" | grep location | sed -E 's|.*tag/v?([0-9.]+.*)$|\1|' | tr -d '\r')}
echo "Installing veidemannctl v${VERSION}"
curl -Lo veidemannctl "${RELEASES}/download/v${VERSION}/veidemannctl_${VERSION}_${KERNEL}_${ARCH}"
sudo install veidemannctl /usr/local/bin/veidemannctl
rm veidemannctl
# Install command completion for bash and zsh
if [ -n "${BASH}" ]; then
echo "Installing bash completion for veidemannctl"
sudo sh -c "/usr/local/bin/veidemannctl completion bash > /etc/bash_completion.d/veidemannctl"
fi
if [ -n "${ZSH_NAME}" ]; then
echo "Installing zsh completion for veidemannctl"
sudo sh -c "/usr/local/bin/veidemannctl completion zsh > /usr/local/share/zsh/site-functions/_veidemannctl"
fi