-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·67 lines (54 loc) · 1.29 KB
/
install.sh
File metadata and controls
executable file
·67 lines (54 loc) · 1.29 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
#!/usr/bin/env bash
export GVM_DIR="$HOME/.gvm"
app_has() {
type "$1" > /dev/null 2>&1
}
app_check() {
if ! app_has "$1"; then
echo "Error: $1 not found"
exit 1
fi
}
git_clone(){
git clone --quiet --branch "master" --single-branch https://github.com/osspkg/gvm.git "${GVM_DIR}/.tmp"
}
get_profile_path(){
local PROFILE_PATH
PROFILE_PATH=''
for PROFILE in ".bashrc" ".bash_profile" ".profile"
do
if [ -f "${HOME}/${PROFILE}" ]; then
PROFILE_PATH="${HOME}/${PROFILE}"
break
fi
done
if [ -z "${PROFILE_PATH}" ]; then
echo "Failed profile detect"
exit 1
fi
echo "${PROFILE_PATH}"
}
setup_profile(){
local PROFILE_PATH
PROFILE_PATH=$(get_profile_path)
ENV_STRING="\\n[ -s \"\$HOME/.gvm/env.sh\" ] && \\. \"\$HOME/.gvm/env.sh\" # This loads gvm\\n\\n"
if ! command grep -qc '/.gvm/env.sh' "${PROFILE_PATH}"; then
command printf "${ENV_STRING}" >> "${PROFILE_PATH}"
fi
}
app_check "curl"
app_check "git"
mkdir -p "$GVM_DIR"
mkdir -p "${GVM_DIR}/.cache"
rm -rf "${GVM_DIR}/.tmp"
mkdir -p "${GVM_DIR}/.tmp"
if ! git_clone; then
echo "Failed clone GVM"
exit 1
fi
rm -rf "${GVM_DIR}"/.tmp/.git*
cp -rlf "${GVM_DIR}"/.tmp/* "${GVM_DIR}"/
rm -rf "${GVM_DIR}/.tmp"
setup_profile
command gvm default "1.22.0"
echo "Done! Please reboot system!"