-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·99 lines (83 loc) · 3.04 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
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
#!/usr/bin/env bash
if [[ -f /etc/rvmrc ]] ; then source /etc/rvmrc ; fi
if [[ -f "$HOME/.rvmrc" ]] ; then source "$HOME/.rvmrc" ; fi
if [[ ! -d "$rvm_path" ]] || [[ "$rvm_path" = "/" ]] ; then
unset rvm_path
if [[ "root" = "$(whoami)" ]] ; then
rvm_path="/usr/local/rvm"
else
rvm_path="$HOME/.rvm"
fi
fi
source scripts/initialize
#
# Setup
#
item="$(tput setaf 2)* $(tput sgr0)"
question="\n$(tput setaf 2)<?>$(tput sgr0)"
cwd=$(pwd)
source_dir="${source_dir:-"$(dirname $0 | xargs dirname)"}"
if [[ ! -d "$source_dir" ]] ; then unset source_dir ; fi
source_dir="${source_dir:-$cwd}"
# State what is required to use rvm
echo -e "\n$(tput setaf 2)rvm$(tput sgr0) - shell scripts that allows a user to manage multiple ruby versions in their own account."
echo -e "\n Prepairing $rvm_path ..."
for dir_name in src scripts bin log archives config gems examples ; do
mkdir -p "$rvm_path/$dir_name"
done
cp -f "$source_dir/README" "$rvm_path/"
#
# Scripts
#
echo -e "\n Installing rvm to $rvm_path/ ..."
rm -rf $rvm_path/scripts # Clear the old scripts directory so that the old style rvm- scripts are cleared out.
for dir_name in config scripts examples lib hooks ; do
mkdir -p "$rvm_path/$dir_name"
if [[ -d "$source_dir/$dir_name" ]] ; then
cp -Rf "$source_dir/$dir_name" "$rvm_path"
fi
done ; unset dir_name
if [[ ! -s "$rvm_path/config/user" ]] ; then
echo '# Users settings file, overrides db file settings and persists across installs.' >> $rvm_path/config/user
fi
#
# Bin Scripts
#
echo -e "\n Installing bin scripts to $rvm_path/bin ..."
# Cleanse and purge...
rm -f $rvm_path/bin/rvm ; rm -rf $rvm_path/bin/binscripts
for file in rvm-prompt rvm ; do
cp -f "$source_dir/binscripts/$file" $rvm_path/bin/
done
chmod +x $rvm_path/bin/*
#
# RC Files
#
echo -e "\n Checking rc files ($rvm_rc_files) ..."
if [[ "$rvm_loaded_flag" != "1" ]] ; then
for rcfile in $(echo $rvm_rc_files) ; do
if [[ ! -f $rcfile ]] ; then touch $rcfile ; fi
grep "scripts\/rvm" "$rcfile" > /dev/null 2>&1
if [[ $? -gt 0 ]] ; then
echo " Adding 'if [[ -s $rvm_path/scripts/rvm ]] ; then source $rvm_path/scripts/rvm ; fi' to $rcfile."
echo -e "\n# rvm-install added line:\nif [[ -s $rvm_path/scripts/rvm ]] ; then source $rvm_path/scripts/rvm ; fi\n" >> $rcfile
fi
done
fi
if [[ "root" = "$(whoami)" ]] ; then
echo -e "\n Symlinking rvm to $rvm_symlink_path/rvm ..."
ln -nfs $rvm_path/bin/rvm $rvm_symlink_path/rvm
chmod +x $rvm_symlink_path/rvm
fi
#
# System Checks
#
$rvm_path/scripts/notes
echo -e " $item In order to use rvm the following line must occur in your shell's loading files, after all path/variable settings:"
echo -e "\n if [[ -s $rvm_path/scripts/rvm ]] ; then source $rvm_path/scripts/rvm ; fi"
echo -e "\n $item CLOSE THIS SHELL AND OPEN A NEW ONE in order to use rvm."
echo -e "\n$(tput setaf 2)RTFM:\n $(tput sgr0) http://rvm.beginrescueend.com/ \n"
echo -e "$(tput setaf 2)w⦿‿⦿t!$(tput sgr0)"
echo -e "\n ~ Wayne\n"
if [[ -x "$rvm_path/bin/rvm" ]] ; then "$rvm_path/bin/rvm" -v ; fi
exit 0