-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·58 lines (46 loc) · 1.43 KB
/
install.sh
File metadata and controls
executable file
·58 lines (46 loc) · 1.43 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
#!/usr/bin/env bash
# shellcheck disable=SC2155
main() {
readonly DEST="$HOME/.local/bin"
readonly NCMLOC="$DEST/ncm"
if command -v tput > /dev/null; then
readonly GREEN=$(tput setaf 2)
readonly RESET=$(tput sgr0)
fi
SILENT='false'
TAG='main'
while [[ $# -gt 0 ]]; do
case "$1" in
-s | --silent) readonly SILENT='true' ;;
-t | --tag)
if [[ -n "$2" ]] && [[ "$2" != -* ]]; then
readonly TAG="$2"
shift
else
echo "Option --tag requires an argument"
exit 1
fi
;;
--tag=?*)
readonly TAG="${1#*=}"
;;
*) echo "Invalid argument: $1" && exit 1 ;;
esac
shift
done
if [[ "$TAG" != "main" && ! "$TAG" =~ ^v0\.[1-9]\.[0-9]+$ ]]; then
echo "Tag $TAG does not exist."
exit 1
fi
[[ "$SILENT" == "true" ]] || echo "Installing ncm..."
mkdir -p "$DEST"
if [[ "$SILENT" == "true" ]]; then
curl -fsSL# "https://raw.githubusercontent.com/trimclain/ncm/$TAG/ncm" --output ncm.tmp
else
curl -fL# "https://raw.githubusercontent.com/trimclain/ncm/$TAG/ncm" --output ncm.tmp
fi
mv -f ncm.tmp "$NCMLOC"
chmod 755 "$NCMLOC"
[[ "$SILENT" == "true" ]] || echo "${GREEN}Installation finished${RESET}"
}
main "$@"