-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·51 lines (42 loc) · 1.33 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
#!/usr/bin/env bash
main() {
# Colors
local BLUE="\033[1;34m"
local GREEN="\033[1;32m"
local RED="\e[1;31m"
local RESET="\033[0m"
local NCM_DIR="$HOME/.local/share/ncm"
local LOCAL_BIN="$HOME/.local/bin/"
# don't allow any arguments for now
if [[ -n $1 ]]; then
echo -e "${RED}Error: unknown argument \"$1\"${RESET}"
return 1
fi
# TODO: this doesn't work when using curl
# check if $LOCAL_BIN is in $PATH
# if [[ ! ":$PATH:" == *":$LOCAL_BIN:"* ]]; then
# echo -e "${RED}Error: $LOCAL_BIN not in \$PATH${RESET}"
# return 1
# fi
# check if NCM_DIR already exists
if [[ -d "$NCM_DIR" ]]; then
echo "NCM is already installed in \"$NCM_DIR\"!"
read -n1 -rp "Do you want to reinstall? [y/N] " res
echo ""
if [[ $res == "n" ]] || [[ $res == "N" ]]; then
echo -e "${GREEN}Skipped!${RESET}"
return 0
fi
echo -n -e "${BLUE}Reinstalling NCM... ${RESET}"
rm -rf "$NCM_DIR"
else
echo -n -e "${BLUE}Installing NCM... ${RESET}"
fi
git clone https://github.com/trimclain/ncm.git "$NCM_DIR" > /dev/null 2>&1
rm -f "$LOCAL_BIN/ncm"
# Symlink ncm to ~/.local/bin/
ln -s "$NCM_DIR/ncm" "$LOCAL_BIN/ncm"
echo -e "${GREEN}Done${RESET}"
return 0
}
main "$@"