lib/whipped-cream/deployer.rb in whipped-cream-0.0.1 vs lib/whipped-cream/deployer.rb in whipped-cream-0.1.0
- old
+ new
@@ -24,21 +24,38 @@
def ssh
@ssh ||= Net::SSH.start(*connection_arguments)
end
- private
-
def connection_arguments
- [pi_address, 'pi', { password: 'raspberry' }]
+ options = { password: 'raspberry' }
+
+ ip_address, port = pi_address.split(':')
+ options.merge!(port: port) if port
+
+ [ip_address, 'pi', options]
end
+ private
+
def bootstrap
ssh_exec <<-SCRIPT
- which ruby ||
- (time sudo apt-get update &&
- time sudo apt-get install ruby1.9.3 -y)
+ if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
+ source "$HOME/.rvm/scripts/rvm"
+ alias sudo=rvmsudo
+ which ruby ||
+ rvm install 1.9.3
+ elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
+ source "/usr/local/rvm/scripts/rvm"
+ alias sudo=rvmsudo
+ which ruby ||
+ rvm install 1.9.3
+ else
+ dpkg --status ruby1.9.3 > /dev/null ||
+ (time sudo apt-get update &&
+ time sudo apt-get install ruby1.9.3 -y)
+ fi
which whipped-cream ||
time sudo gem install whipped-cream --no-ri --no-rdoc --pre
mkdir -p ~/whipped-cream/
@@ -53,9 +70,16 @@
ssh_exec 'sudo pkill -9 -f whipped-cream'
end
def run_plugin
ssh_exec <<-SCRIPT
+ if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
+ source "$HOME/.rvm/scripts/rvm"
+ alias sudo=rvmsudo
+ elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
+ source "/usr/local/rvm/scripts/rvm"
+ alias sudo=rvmsudo
+ fi
cd ~/whipped-cream
sudo whipped-cream start #{plugin_filename} --daemonize
SCRIPT
end