#!/usr/bin/env bash __rvm_system_wide_permissions() { [[ -z "$1" ]] && return 1 chown -R root:"$rvm_group_name" "$1" chmod -R g+w "$1" [[ -d "$1" ]] && find "$1" -type d -print0 | xargs -n1 -0 chmod g+s } # Require root to install it. if [[ "$(whoami)" != "root" ]]; then echo "Please rerun this installer as root." >&2 exit 1 # Check for the presence of git. elif ! command -v git >/dev/null 2>&1 ; then echo "Please ensure git is installed and available in PATH to continue." >&2 exit 1 elif [[ "$(uname)" != "Linux" ]]; then echo "The rvm system wide installer is currently Linux only." >&2 exit 1 fi # Load the rvm config. rvm_ignore_rvmrc=${rvm_ignore_rvmrc:-0} if [[ $rvm_ignore_rvmrc -eq 0 ]]; then [[ -s /etc/rvmrc ]] && source /etc/rvmrc [[ -s "$HOME/.rvmrc" ]] && source "$HOME/.rvmrc" fi rvm_path="${rvm_path:-"/usr/local/rvm"}" export rvm_selfcontained=0 rvm_group_name="${rvm_group_name:-"rvm"}" if \grep -q "${rvm_group_name}$" /etc/group ; then echo "Group '$rvm_group_name' exists, proceeding with installation." else echo "Creating the group '$rvm_group_name'" groupadd -f "$rvm_group_name" fi echo "Adding $(whoami) the '$rvm_group_name'" usermod -a -G "$rvm_group_name" "$(whoami)" echo "Creating the destination dir and making sure the permissions are correct" \mkdir -p "$rvm_path" __rvm_system_wide_permissions "$rvm_path" \mkdir -p "$rvm_path/src/" builtin cd "$rvm_path/src" \rm -rf ./rvm/ git clone --depth 1 git://github.com/wayneeseguin/rvm.git || git clone http://github.com/wayneeseguin/rvm.git builtin cd rvm echo "Running the install script." bash ./scripts/install "$@" __rvm_system_wide_permissions "$rvm_path" echo "Setting up group permissions" rvm_parent_dir="$(dirname "$rvm_path")" for dir in bin share/man; do __rvm_system_wide_permissions "$rvm_parent_dir/$dir" done; unset dir echo "Generating system wide rvmrc" \rm -f /etc/rvmrc \touch /etc/rvmrc cat > /etc/rvmrc < "$rvm_parent_dir/lib/rvm" <