forked from ungleich-public/cdist
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
|
|
||||||
present)
|
case "$state_should" in
|
||||||
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
|
present)
|
||||||
"rvm install $ruby\""
|
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
|
||||||
case "$default" in
|
"rvm install $ruby\""
|
||||||
no)
|
if [ -f "$__object/parameter/default" ]; then
|
||||||
;;
|
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
|
||||||
*)
|
"rvm use --default $ruby\""
|
||||||
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
|
fi
|
||||||
"rvm use --default $ruby\""
|
;;
|
||||||
;;
|
absent)
|
||||||
esac
|
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
|
||||||
;;
|
"rvm remove $ruby\""
|
||||||
absent)
|
;;
|
||||||
echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
|
|
||||||
"rvm remove $ruby\""
|
*)
|
||||||
;;
|
echo "Unknown state $state_should" >&2
|
||||||
esac
|
exit 1
|
||||||
fi
|
;;
|
||||||
|
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