-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathinstall.sh
More file actions
28 lines (22 loc) · 1023 Bytes
/
install.sh
File metadata and controls
28 lines (22 loc) · 1023 Bytes
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
#!/bin/bash
# allow specifying different destination directory
DIR="${DIR:-"$HOME/.local/bin"}"
# map different architecture variations to the available binaries
ARCH=$(uname -m)
case $ARCH in
i386|i686) ARCH=x86_64 ;;
aarch64*) ARCH=aarch64 ;;
esac
# prepare the download URL
GITHUB_LATEST_VERSION=$(curl -L -s -H 'Accept: application/json' https://github.com/rgwood/systemctl-tui/releases/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
GITHUB_FILE="systemctl-tui-${ARCH}-unknown-linux-musl.tar.gz"
GITHUB_URL="https://github.com/rgwood/systemctl-tui/releases/download/${GITHUB_LATEST_VERSION}/${GITHUB_FILE}"
# install/update the local binary
# check curl downloads bin correctly
if ! curl -L -f -o systemctl-tui.tar.gz "$GITHUB_URL"; then
echo "The requested file '$GITHUB_FILE' for version '$GITHUB_LATEST_VERSION' and architecture '$ARCH' may not exist." >&2
exit 1
fi
tar xzvf systemctl-tui.tar.gz systemctl-tui
install -Dm 755 systemctl-tui -t "$DIR"
rm systemctl-tui systemctl-tui.tar.gz