I am trying to have RVM and ruby installed in an Ubuntu 12 virtual machine without human interaction apart from the password prompts.
I created a shell script to do this that works pretty fine until I need to use RVM itself.
I am using multi-user installation.
#!/bin/bash -l mainUser=`whoami` echo "Installing as '${mainUser}'" echo "Installing git..." sudo -S apt-get install --yes curl git-core echo "Installing RVM..." \curl -L https://get.rvm.io | sudo bash -s stable echo "Adding ${mainuser} to RVM group..." sudo adduser $mainUser rvm newgrp rvm From here things get weird.. I need to load dvm as a source. I want both my script to have this source and my user's bash_profile / bashrc. Anyway.. I know how to do it manually, but I can't have this done from the script. This is the last code I tried:
. "/usr/local/rvm/bin/rvm" rvm use ruby-head rubyVersion=`rvm list | awk '/ruby-head/{print x;print};{x=$0}' | sed -n '/ruby-head/{g;1!p;};h' | awk -F ' ' '{print $1}'` rubyTest=${rubyVersion}@test rvm use $rubyTest --create --default The error I get is this:
test.sh: 7: /usr/local/rvm/bin/rvm: Syntax error: "(" unexpected (expecting "fi") If I simply try to use the full path, like this:
rvm=/usr/local/rvm/bin/rvm $rvm use ruby-head rubyVersion=`$rvm list | awk '/ruby-head/{print x;print};{x=$0}' | sed -n '/ruby-head/{g;1!p;};h' | awk -F ' ' '{print $1}'` rubyTest =${rubyVersion}@test $rvm use $rubyTest --create --default I get this error instead:
RVM is not a function, selecting rubies with 'rvm use ...' will not work. I am clueless. Why can't I use /usr/local/rvm/bin/rvm?
Is there a way to execute source /etc/profile.d/rvm.sh for this user from the script?
I am not so good at shell script and Linux, so I appreciate any references and examples you could give.
Thanks!
UPDATE
I also tried:
source "/usr/local/rvm/scripts/rvm" ... and all it's variants. Same error: "RVM is not a function".
source ~/.rvm/scripts/rvmin your script?