#!/usr/bin/env bash if [[ "--auto" = "$1" ]] ; then rvm_auto_flag=1 ; else unset rvm_auto_flag ; fi if [[ -f /etc/rvmrc ]] ; then source /etc/rvmrc ; fi if [[ -f "$HOME/.rvmrc" ]] ; then source "$HOME/.rvmrc" ; fi if ! [[ "$rvm_path" =~ /rvm/?$ ]] ; then unset rvm_path if [[ "root" = "$(whoami)" ]] ; then rvm_path="/usr/local/rvm" else rvm_path="$HOME/.rvm" fi fi source scripts/utility source scripts/initialize __rvm_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 "\nInstalling rvm to $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 # 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 # # Cleanse and purge... rm -f $rvm_path/bin/rvm ; rm -rf $rvm_path/bin/binscripts for file in rvm-prompt rvm rvmsudo ; do cp -f "$source_dir/binscripts/$file" $rvm_path/bin/ done chmod +x $rvm_path/bin/* # # RC Files # if [[ ! -z "$rvm_auto_flag" ]] ; then echo -e "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 if [[ -s "$HOME/.profile" ]] ; then if ! grep -q '.profile' "$rcfile" ; then echo " Adding 'if [[ -s \$HOME/.profile ]] ; then source \$HOME ; fi' to $rcfile." echo -e "\n# rvm-install added line:\nif [[ -s \$HOME/.profile ]] ; then source \$HOME/.profile ; fi\n" >> $rcfile fi fi if ! grep -q "scripts\/rvm" "$rcfile" ; then echo " Adding 'if [[ -s $rvm_path/scripts/rvm ]] ; then source $rvm_path/scripts/rvm ; fi' to $rcfile." echo -e "\n# rvm-install added:\nif [[ -s $rvm_path/scripts/rvm ]] ; then source $rvm_path/scripts/rvm ; fi\n" >> $rcfile fi done fi fi if [[ "root" = "$(whoami)" ]] ; then echo -e "\n Symlinking rvm to $rvm_symlink_path/rvm ..." mkdir -p $rvm_symlink_path ln -nfs $rvm_path/bin/rvm $rvm_symlink_path/rvm ln -nfs $rvm_path/bin/rvmsudo $rvm_symlink_path/rvmsudo chmod +x $rvm_symlink_path/rvm chmod +x $rvm_symlink_path/rvmsudo fi echo -e "\n$(tput setaf 2)rvm$(tput sgr0) - shell scripts that allows a user to manage multiple ruby versions in their own account." $rvm_path/scripts/notes echo -e "$(tput setaf 2)RTFM: $(tput sgr0) http://rvm.beginrescueend.com/" echo -e "\n$(tput setaf 2)HELP: $(tput sgr0) http://webchat.freenode.net/?channels=rvm " echo "================================================================================" name="$(awk -F= '/^[[:space:]]*name/{print $2}' ~/.gitconfig 2>/dev/null)" echo -e "\n${name:-"$(whoami)"},\n" echo -e "\nThank you for using rvm. I hope that it makes your work easier and more enjoyable." echo -e "If you have any questions, issues and/or ideas for improvement please hop in #rvm on irc.freenode.net and let me know." echo -e "My irc nickname is 'wayneeseguin' and I hang out from ~09:00-17:00EST and again from ~21:00EST-~00:00EST." echo -e "If I do not respond right away, please hang around after asking your question, I will respond as soon as I am back." echo -e "\n w$(tput setaf 2)⦿‿⦿$(tput sgr0)t!" echo -e "\n ~ Wayne\n" echo "================================================================================" echo -e "\n$(tput setaf 1)You must now finish the install manually:$(tput sgr0)" echo -e "\n1) Place the folowing line at the end of your shell's loading files(.bash_profile and/or .zshenv), after all path/variable settings:" echo -e "\n if [[ -s $rvm_path/scripts/rvm ]] ; then source $rvm_path/scripts/rvm ; fi" echo -e "\n2) Ensure that there is no 'return' from inside the .bashrc file. (otherwise rvm will be prevented from working properly)." echo -e "\n3) $(tput setaf 1)CLOSE THIS SHELL$(tput sgr0) and open a new one in order to use rvm.\n" if [[ -x "$rvm_path/bin/rvm" ]] ; then "$rvm_path/bin/rvm" -v ; fi exit 0