This repository has been archived by the owner on Nov 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmcp-setup.bash
executable file
·104 lines (79 loc) · 2.84 KB
/
mcp-setup.bash
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# this script will try to setup MCP on the users computer with
# as little humen intervention as possible.
# init variables
MCP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
red=$'\e[1;31m'
end=$'\e[0m'
# confirm
read -p 'Setting up MCP on your system, continue? [y,n] ' yn
case $yn in
[Yy] ) ;;
* ) printf 'Setup has been canceled.\n' && exit 0;;
esac
# add username
while true; do
read -p "Enter your GITHUB username: " USERNAME
read -p "Is this your username, \"$USERNAME\" [y,n] " yn
case $yn in
[Yy] ) break;;
[Nn] ) ;;
* ) printf "Invalid input, try again.\n";;
esac
done
# check for existing PAT
while true; do
read -p "Do you have a Personal Access Token (PAT)? [y,n] " yn
case $yn in
[Yy] ) break;;
[Nn] ) printf "Create PAT here:$red https://github.com/settings/tokens $end\nNote: the PAT needs to have $red'REPO'$end and $red'DELETE_REPO'$end tagged.\n" && break;;
* ) printf "Invalid input, try again.\n";;
esac
done
# ask for PAT
while true; do
read -p "Enter you PAT: " PAT
read -p "Is this your PAT, \"$PAT\" [y,n] " yn
case $yn in
[Yy] ) break;;
[Nn] ) ;;
* ) printf "Invalid input, try again.\n";;
esac
done
# locate .profile or .bashrc
if [[ -f ~/.profile ]]; then
FILE=~/.profile
else
if [[ -f ~/.bashrc ]]; then
FILE=~/.bashrc
else
read -p "Enter full path to .profile or .bashrc: " FILE
fi
fi
# add path to file
if ! grep -q "export PATH=.*$MCP_DIR" "$FILE"; then
printf "export PATH=\"\$PATH:$MCP_DIR\"\n" >> "$FILE"
printf "PATH added to "$FILE".\n"
fi
# add github auth to FILE
if ! grep -q "export GITHUB_USERNAME" "$FILE"; then
printf "export GITHUB_USERNAME=\"$USERNAME\"\n" >> "$FILE"
printf "GITHUB_USERNAME added to "$FILE".\n"
fi
if ! grep -q "export GITHUB_AUTH" "$FILE"; then
printf "export GITHUB_AUTH=\"$PAT\"\n" >> "$FILE"
printf "GITHUB_AUTH added to "$FILE".\n"
fi
# add mcp-auto.bash to FILE
if ! grep -q "mcp-auto.bash" "$FILE"; then
printf "source mcp-auto.bash\n" >> "$FILE"
printf "mcp-auto.bash added to "$FILE".\n"
fi
# check if python3 and pip3 is installed
type -P python3 >/dev/null 2>&1 || printf "$red!! You need to install python3: sudo apt install python3 !!$end\n"
python3 -m venv >/dev/null 2>&1 || if [[ $? != 2 ]]; then printf "$red!! You need to install python3-venv: sudo apt install python3-venv !!$end\n"; fi
type -P pip3 >/dev/null 2>&1 || printf "$red!! You need to install pip3: sudo apt install python3-pip !!$end\n"
type -P pip3 >/dev/null 2>&1 && pip3 list | grep requests >/dev/null 2>&1 || printf "$red!! You need to install requests: pip3 install requests !!$end\n"
# finish text + tips
printf "\nSetup finished.\n\nPlease fix any errors(in$red red$end) that may have occured!\n"
exit 0