contrib/install-system-wide in rvm-1.0.5 vs contrib/install-system-wide in rvm-1.0.6
- old
+ new
@@ -1,27 +1,86 @@
#!/usr/bin/env bash
+usage() {
+ printf "
+
+ Usage:
+
+ rvm-install-system-wide [options]
+
+ Options:
+
+ --trace - Run turn on bash xtrace while the script runs.
+ --debug - Turn on bash verbose while the script runs.
+ --version X - Install RVM version X
+ --revision X - Install RVM revision X (sha1)
+ --help - Display this usage text.
+
+"
+return 0
+}
+
__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
+
+ if [[ -d "$1" ]] ; then
+ find "$1" -type d -print0 | xargs -n1 -0 chmod g+s
+ fi
+
+ return 0
}
# 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
+elif [[ -z "$(command -v git)" ]] ; 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
+while [[ $# -gt 0 ]] ; do
+ case $1 in
+ --trace)
+ rvm_trace_flag=1
+ set -o xtrace
+ ;;
+ --debug)
+ rvm_trace_flag=1
+ set -o verbose
+ ;;
+ --version|--revision)
+ if [[ -n "${1:-""}" ]] ; then
+ revision="$1"
+ shift
+ else
+ usage
+ exit 1
+ fi
+ ;;
+ --help)
+ usage
+ exit 0
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
# 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"
@@ -39,22 +98,27 @@
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"
+mkdir -p "$rvm_path"
__rvm_system_wide_permissions "$rvm_path"
-\mkdir -p "$rvm_path/src/"
+mkdir -p "$rvm_path/src/"
builtin cd "$rvm_path/src"
-\rm -rf ./rvm/
+rm -rf ./rvm/
git clone --depth 1 git://github.com/wayneeseguin/rvm.git || git clone http://github.com/wayneeseguin/rvm.git
builtin cd rvm
+if [[ "${revision:-""}" ]]; then
+ echo "Checking out revision $revision"
+ git checkout $revision
+fi
+
echo "Running the install script."
bash ./scripts/install "$@"
__rvm_system_wide_permissions "$rvm_path"
@@ -63,12 +127,12 @@
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
+rm -f /etc/rvmrc
+touch /etc/rvmrc
cat > /etc/rvmrc <<END_OF_RVMRC
# Setup default configuration for rvm.
# If an rvm install exists in the home directory, don't load this.'
if [[ ! -s "\$HOME/.rvm/scripts/rvm" ]]; then
umask g+w
@@ -76,11 +140,11 @@
export rvm_prefix="$rvm_parent_dir/"
fi
END_OF_RVMRC
echo "Generating $rvm_parent_dir/lib/rvm to load rvm"
-\rm -f "$rvm_parent_dir/lib/rvm"
-\touch "$rvm_parent_dir/lib/rvm"
+rm -f "$rvm_parent_dir/lib/rvm"
+touch "$rvm_parent_dir/lib/rvm"
cat > "$rvm_parent_dir/lib/rvm" <<END_OF_RVM_SH
# Automatically source rvm
if [[ -s "\$HOME/.rvm/scripts/rvm" ]]; then
source "\$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]]; then