-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·57 lines (47 loc) · 1.08 KB
/
install
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
#!/bin/bash
ROOT_URL='https://raw.github.com/mgdelacroix/gw/master/'
FILES='gw gwactivate'
GVM_DIR="$HOME/.gvm"
RC_FILES='.bash_profile .profile .bashrc .zshrc'
function downloadFile {
echo "== Downloading => $1"
curl -# -O "$ROOT_URL/$1"
chmod +x ./$1
}
function checkGVM {
if [ ! -d $GVM_DIR ]; then
installGVM
fi
}
function backupRCs {
TEMP_DIR=`mktemp -dqp $HOME`
echo "++ Saving dotfiles to $TEMP_DIR avoid modifications during GVM installation"
for file in $RC_FILES; do
mv $HOME/$file $TEMP_DIR 2> /dev/null
done
}
function restoreRCs {
echo '++ Restoring dotfiles after GVM installation'
for file in $RC_FILES; do
mv $TEMP_DIR/$file $HOME 2> /dev/null
done
echo '++ Removing temp dir'
rmdir $TEMP_DIR
}
function installGVM {
echo '
== Installing GVM'
backupRCs
curl -s get.gvmtool.net | bash
restoreRCs
}
checkGVM
echo '
==== Installing GW ====
'
for file in $FILES; do
downloadFile $file
done
echo '=======================
'
echo 'GW is now installed. To start using it, run "gw help".'