-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheasy-msi-install.sh
More file actions
executable file
·124 lines (105 loc) · 2.07 KB
/
easy-msi-install.sh
File metadata and controls
executable file
·124 lines (105 loc) · 2.07 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# Script to set up botbot.
# Written by Jack Stanek and Rob Schaefer.
NAME='BotBot'
BASE="/home/mccuem/shared/.local/conda"
CWD=`pwd`
function get-canonical-path() {
cd -P -- "$(dirname -- "$1")" &&
printf '%s\n' "$(pwd -P)/$(basename -- "$1")"
}
function usage()
{
cat <<EOF
Usage: $0 [flags]
Flags
-----
-b | Specify the directory where conda is installed.
(By default: $)
EOF
exit 0
}
function vecho()
{
if [[ $VERBOSE -eq 1 ]]; then
echo $1
fi
}
function color()
{
local RED='\033[1;31m'
local GREEN='\033[1;32m'
local NC='\033[0m'
case "$1" in
1) echo -e "$RED$2$NC"
;;
2) echo -e "$GREEN$2$NC"
;;
esac
}
function red()
{
color 1 "$1"
}
function green()
{
color 2 "$1"
}
function parse-args()
{
while [[ $# -gt 0 ]]
do
local key="$1"
case $key in
"-h"|"--help")
usage
shift
exit
;;
"-b"|"--base")
BASE=$2
shift
;;
"-v"|"--verbose")
VERBOSE=1
shift
;;
*)
usage
exit 1
;;
esac
done
# This should be in the path
BIN_BASE="$(get-canonical-path $BASE)/bin"
vecho "Set BIN_BASE to $BIN_BASE"
}
function separate-path-var()
{
echo $PATH | tr ":" "\n"
}
function add-conda-to-path()
{
echo "export PATH=\$PATH:$BIN_BASE" >> $HOME/.bash_profile
}
function test-conda-bin-dir-in-path()
{
PATH_N=$(separate-path-var)
for path in $PATH_N; do
if [[ $(get-canonical-path $path) == $BIN_BASE ]]; then
green "Found $BIN_BASE in PATH..."
exit 0
else
vecho "Checked $path..."
fi
done
red "Could not find conda installation in $BIN_BASE..."
green "Adding conda to \$PATH bash config..."
add-conda-to-path
}
function do-everything()
{
parse-args $@
test-conda-bin-dir-in-path
}
do-everything $@