-
Notifications
You must be signed in to change notification settings - Fork 1
/
xvm_install.sh
executable file
·97 lines (80 loc) · 1.92 KB
/
xvm_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
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
#/bin/bash
read -p "Enter a working folder(abs path, default: \$HOME/xvm): " workingfolder
if [ -z "$workingfolder" ]; then
workingfolder=$HOME/xvm
fi
if [ -e "$workingfolder" ]; then
echo "folder: $workingfolder exist, please check, and try again"
exit 0
fi
read -p "Enter your github access token: " GITHUB_ACCESS_TOKEN
if [ -z "$GITHUB_ACCESS_TOKEN" ]; then
echo "github access token MUST be setted"
exit 0
fi
echo "You workingfolder: $workingfolder"
echo "You github access token: $GITHUB_ACCESS_TOKEN"
# ###########################################
# function show_path() {
# cat >$XVM/xvm/profile <<EOF
# export GITHUB_ACCESS_TOKEN=$GITHUB_ACCESS_TOKEN
# EOF
# }
# function import_path() {
# outputFile=$@
# if [ -e "$outputFile" ]; then
# cat >>$outputFile <<EOF
# export XVM=$workingfolder
# export PATH=\$PATH:\$XVM/xvm
# source \$XVM/profile
# EOF
# fi
# }
# export XVM=$workingfolder
# PATH=$PATH:$XVM/xvm
# source $XVM/xvm/.util/tool_app.sh
# show_path
# refresh_path
# import_path $HOME/.bashrc
# import_path $HOME/.zshrc
# exit 0
###########################################
function yes_or_no {
while true; do
read -p "$*confirm? [y/n]: " yn
case $yn in
[Yy]*) return 0 ;;
[Nn]*)
echo "Aborted"
exit 0
;;
esac
done
}
yes_or_no "$message" #&& do_something
mkdir -p $workingfolder
cd $workingfolder
git clone https://github.com/izouxv/xvm.git
function show_path() {
cat >$XVM/xvm/profile <<EOF
export GITHUB_ACCESS_TOKEN=$GITHUB_ACCESS_TOKEN
EOF
}
function import_path() {
outputFile=$@
if [ -e "$outputFile" ]; then
cat >>$outputFile <<EOF
export XVM=$workingfolder
export PATH=\$PATH:\$XVM/xvm
source \$XVM/profile
EOF
fi
}
export XVM=$workingfolder
PATH=$PATH:$XVM/xvm
source $XVM/xvm/.util/tool_app.sh
show_path
refresh_path
import_path $HOME/.bashrc
import_path $HOME/.zshrc
exit 0