Skip to content
This repository has been archived by the owner on Jul 21, 2019. It is now read-only.

Rstudio pkg #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Berksfile.lock
Gemfile.lock
*.swp
*.bak
3 changes: 3 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
default['rstudio']['cran']['packages'] = []

# RStudio Server
default['rstudio']['server']['base_download_url'] = 'http://download2.rstudio.org'
default['rstudio']['server']['www_port'] = '8787'
default['rstudio']['server']['www_address'] = '127.0.0.1'
default['rstudio']['server']['ld_library_path'] = ''
default['rstudio']['server']['r_binary_path'] = ''
default['rstudio']['server']['user_group'] = ''
default['rstudio']['server']['version'] = '0.98.507'
default['rstudio']['server']['arch'] = node['kernel']['machine'] =~ /x86_64/ ? "amd64" : "i386"

# RStudio Session
default['rstudio']['session']['timeout'] = '30'
Expand Down
102 changes: 60 additions & 42 deletions recipes/server.rb
Original file line number Diff line number Diff line change
@@ -1,42 +1,60 @@
# Set up the package repository.
case node["platform"].downcase
when "ubuntu", "debian"
include_recipe "apt"

apt_repository "rstudio-cran" do
uri node['rstudio']['apt']['uri']
keyserver node['rstudio']['apt']['keyserver']
key node['rstudio']['apt']['key']
distribution "#{node['lsb']['codename']}/"
end

package "r-base" do
action :install
end

package "rstudio-server" do
action :install
end
end

service "rstudio-server" do
provider Chef::Provider::Service::Upstart
supports :start => true, :stop => true, :restart => true
action :start
end

template "/etc/rstudio/rserver.conf" do
source "etc/rstudio/rserver.conf.erb"
mode 0644
owner "root"
group "root"
notifies :restart, "service[rstudio-server]"
end

template "/etc/rstudio/rsession.conf" do
source "etc/rstudio/rsession.conf.erb"
mode 0644
owner "root"
group "root"
notifies :restart, "service[rstudio-server]"
end
# Set up the package repository.
case node['platform_family'].downcase
when "debian"
include_recipe "apt"

apt_repository "rstudio-cran" do
uri node['rstudio']['apt']['uri']
keyserver node['rstudio']['apt']['keyserver']
key node['rstudio']['apt']['key']
distribution "#{node['lsb']['codename']}/"
end

package "r-base" do
action :install
end

package "libssl0.9.8" do
action :install
end

Chef::Log.info('Retrieving RStudio Server file.')
remote_rstudio_server_file = "#{node['rstudio']['server']['base_download_url']}/rstudio-server-#{node['rstudio']['server']['version']}-#{node['rstudio']['server']['arch']}.deb"
local_rstudio_server_file = "#{Chef::Config[:file_cache_path]}/rstudio-server-#{node['rstudio']['server']['version']}-#{node['rstudio']['server']['arch']}.deb"
remote_file local_rstudio_server_file do
source remote_rstudio_server_file
action :create_if_missing
not_if { ::File.exists?('/etc/init/shiny-server.conf') }
end

Chef::Log.info('Installing RStudio Server via dpkg.')
dpkg_package "rstudio-server" do
source local_rstudio_server_file
action :install
end

when "rhel"
Chef::Application.fatal!("Redhat based platforms are not yet supported")
end

service "rstudio-server" do
provider Chef::Provider::Service::Upstart
supports :start => true, :stop => true, :restart => true
action :start
end

template "/etc/rstudio/rserver.conf" do
source "etc/rstudio/rserver.conf.erb"
mode 0644
owner "root"
group "root"
notifies :restart, "service[rstudio-server]"
end

template "/etc/rstudio/rsession.conf" do
source "etc/rstudio/rsession.conf.erb"
mode 0644
owner "root"
group "root"
notifies :restart, "service[rstudio-server]"
end