#!/usr/bin/env bash if [[ -f /etc/rvmrc ]] ; then source /etc/rvmrc ; fi if [[ -f "$HOME/.rvmrc" ]] ; then source "$HOME/.rvmrc" ; fi if [[ -z "$rvm_path" ]] ; then unset rvm_path ; fi if [[ -z "$rvm_path" ]] ; then if [[ "root" = "$(whoami)" ]] ; then rvm_path="${rvm_path:-/usr/local/rvm}" else rvm_path="${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 Installing 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 # # Bin Scripts # cp -Rf "$source_dir/binscripts/" $rvm_path/bin chmod +x $rvm_path/bin/* ln -nfs $rvm_path/scripts/rvm $rvm_path/bin/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 [[ -z "$(awk "/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 line:\nif [[ -s $rvm_path/scripts/rvm ]] ; then source $rvm_path/scripts/rvm ; fi\n" >> $rcfile else : # it exists... remove it and append at the end fi done fi if [[ "root" = "$(whoami)" ]] ; then ln -nfs $rvm_path/scripts/rvm /usr/local/bin/rvm else ln -nfs $rvm_path/scripts/rvm $rvm_path/bin/rvm fi chmod +x $rvm_path/scripts/rvm # # 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 " $item if [[ -s $rvm_path/scripts/rvm ]] ; then source $rvm_path/scripts/rvm ; fi" echo -e " $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" $cwd/scripts/rvm -v exit 0