make --default boolean in type __rvm_ruby
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
3d4bb3837f
commit
482ec3c5d8
3 changed files with 23 additions and 22 deletions
|
@ -24,23 +24,24 @@ user="$(cat "$__object/parameter/user")"
|
||||||
default="$(cat "$__object/parameter/default" 2>/dev/null || true)"
|
default="$(cat "$__object/parameter/default" 2>/dev/null || true)"
|
||||||
state_should="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
if [ "$state_is" != "$state_should" ]; then
|
[ "$state_is" = "$state_should" ] && exit 0
|
||||||
case "$state_should" in
|
|
||||||
|
case "$state_should" in
|
||||||
present)
|
present)
|
||||||
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
|
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
|
||||||
"rvm install $ruby\""
|
"rvm install $ruby\""
|
||||||
case "$default" in
|
if [ -f "$__object/parameter/default" ]; then
|
||||||
no)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
|
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
|
||||||
"rvm use --default $ruby\""
|
"rvm use --default $ruby\""
|
||||||
;;
|
fi
|
||||||
esac
|
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
|
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
|
||||||
"rvm remove $ruby\""
|
"rvm remove $ruby\""
|
||||||
;;
|
;;
|
||||||
esac
|
|
||||||
fi
|
*)
|
||||||
|
echo "Unknown state $state_should" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
|
@ -23,7 +23,7 @@ state::
|
||||||
BOOLEAN PARAMETERS
|
BOOLEAN PARAMETERS
|
||||||
------------------
|
------------------
|
||||||
default:
|
default:
|
||||||
If set to anything but "no" (the default), set the given version as default
|
Set the given version as default
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
--------
|
--------
|
||||||
|
@ -33,7 +33,7 @@ EXAMPLES
|
||||||
__rvm_ruby ruby-1.9.3-p0 --user thelonious --state present
|
__rvm_ruby ruby-1.9.3-p0 --user thelonious --state present
|
||||||
|
|
||||||
# Install ruby 1.9.3 through rvm for user ornette and make it the default
|
# Install ruby 1.9.3 through rvm for user ornette and make it the default
|
||||||
__rvm_ruby ruby-1.9.3-p0 --user ornette --state present --default yes
|
__rvm_ruby ruby-1.9.3-p0 --user ornette --state present --default
|
||||||
|
|
||||||
# Remove ruby 1.9.3 for user john
|
# Remove ruby 1.9.3 for user john
|
||||||
__rvm_ruby ruby-1.9.3-p0 --user john --state absent
|
__rvm_ruby ruby-1.9.3-p0 --user john --state absent
|
||||||
|
|
Loading…
Reference in a new issue