Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to work with Ubuntu 2204, current cbrain and ruby version #3

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# cbrain-vagrant
This is a VagrantFile that will provision and create a CBRAIN instance using a base of ubuntu/xenial64.
This is a VagrantFile that will provision and create a CBRAIN instance using a base of Ubuntu 22.04

The Vagrant provisions an image to provide you with the following components:
1. An admin account which you will be asked to change the password on upon first instantiation.
Expand All @@ -10,9 +10,10 @@ The Vagrant provisions an image to provide you with the following components:
To use:
1. vagrant up (will provision)
1. at the end of the provision process, the temporary CBRAIN password will be displayed in the log
1. Currently rvm is installed in a direct way. The method of rvm install with rsa key is commented out, it might need several attempts or/and some troubleshooting. You may uncomment it, if you like, on your own risk, but no support is provided
1. vagrant ssh
1. cd cbrain/BrainPortal
1. type 'rails server puma -b 0.0.0.0 -p 3000 -e development'
1. go to your local browser and type in the address '127.0.0.1:3000' and you should see the CBRAIN login page.

Note the VagrantFile is using the new plugin interface, if would like to change the resources allocated to the Vagrant, you can set the diskspace and memory requirements there, it is currently set to use 8GB of RAM and 20GB of disk space.
Note the VagrantFile is using the new plugin interface, if would like to change the resources allocated to the Vagrant, you can set the diskspace and memory requirements
6 changes: 3 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.box = "ubuntu/jammy64"

config.vm.network "forwarded_port", guest: 3000, host: 3000
# config.vm.network "public_network"
Expand All @@ -25,7 +25,7 @@ Vagrant.configure(2) do |config|
exec "vagrant " + ARGV.join(' ')
end

config.disksize.size="10GB"
config.disksize.size="20GB"

config.vm.provider "virtualbox" do |vb|
vb.memory = "8129"
Expand Down Expand Up @@ -53,6 +53,6 @@ Vagrant.configure(2) do |config|
cd ~/cbrain/BrainPortal
echo "Please login in to the portal for the first time as user 'admin'"
cat /tmp/cbinit.txt
# rails server thin -e development -p 3000 > ~/cbrain.log &
# rails server puma -e development -p 3000 -b 0.0.0.0> ~/cbrain.log &
SHELL
end
98 changes: 67 additions & 31 deletions provision/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ logFile=/tmp/provision.log

echo "Installing MySQL Server" > $logFile
echo "-----------------------------------------------" >> $logFile
sudo apt-get update
sudo apt-get update >> $logFile
sudo apt-get install -y software-properties-common >> $logFile

sudo apt-get install mariadb-server -y >> $logFile

sqlscript="/tmp/tmp.sql"
Expand All @@ -20,23 +22,70 @@ echo "FLUSH PRIVILEGES;" >> $sqlscript

cat $sqlscript | sudo mysql -u root >> $logFile


echo "Installing Apptainer" > $logFile
echo "-----------------------------------------------" >> $logFile



# For the non-setuid installation use these commands:

sudo add-apt-repository -y ppa:apptainer/ppa
sudo apt-get update >> $logFile
sudo apt-get install -y apptainer >> $logFile

# For the setuid installation uncomment these:
# sudo apt install -y apptainer-suid


### Installing Ruby Version Manager

echo "Installing Ruby Version Manager" >> $logFile
echo "-----------------------------------------------" >> $logFile

cd $HOME
\curl -sSL https://rvm.io/mpapis.asc | gpg --import - >> $logFile
\curl -sSL https://get.rvm.io | bash -s stable >> $logFile

source $HOME/.rvm/scripts/rvm >> $logFile
sudo apt-get install curl libsodium-dev gnupg2 -y >> $logFile
gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB >> $logFile


sudo apt-add-repository -y ppa:rael-gc/rvm >> $logFile
sudo apt-get update >> $logFile


sudo apt-get install -y rvm >> $logFile

sudo usermod -a -G rvm $USER >>$logFile

# command curl -ksSL https://rvm.io/mpapis.asc | gpg2 --import - >> $logfile
# command curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import - >> $logFile
# \curl -sSL https://get.rvm.io | bash -s stable >> $logFile

source /usr/share/rvm/scripts/rvm >> $logFile

echo "Installing Ruby" > $logFile
echo "Installing Ruby" >> $logFile
echo "-----------------------------------------------" >> $logFile
echo "rmv info" >> $logFile

rvm info >> $logFile
rvm install 2.4 >> $logFile
rvm --default 2.4 >> $logFile

echo "openssl pkg install" >> $logFile



echo "export rvm_max_time_flag=20" >> ~/.rvmrc
rvm fix-permissions system
rvm fix-permissions user


rvm pkg install openssl >> $logFile




rvm install ruby-2.7.2 --with-openssl-dir=/usr/share/rvm/usr >> $logFile

rvm --default 2.7.2 >> $logFile

## Get CBRAIN Code

Expand All @@ -51,9 +100,13 @@ git clone https://github.com/aces/cbrain.git >> $logFile
echo "Installing additional packages" >> $logFile
echo "-----------------------------------------------" >> $logFile

sudo apt-get install libmysqlclient-dev -y >> $logFile
sudo apt-get install libmariadb-dev-compat libmariadb-dev >> $logFile
#sudo apt-get install libmysqlclient-dev -y >> $logFile
sudo apt-get install libxml2 libxml2-dev -y >> $logFile
sudo apt-get install libxslt1.1 -y >> $logFile
sudo apt-get install libsodium-dev -y >> $logFile
sudo apt-get install libcurl4-openssl-dev -y >> $logFile


## create database.yml file

Expand Down Expand Up @@ -102,26 +155,9 @@ mkdir $HOME/FlatLocalDP
mkdir $HOME/SshDP
mkdir $HOME/CBLocalDP

### install docker

dockerLog=/tmp/docker-install.log
sudo apt-get install docker.io -y > $dockerLog
sudo usermod -a -G docker ubuntu >> $dockerLog

## install singularity
singLog=/tmp/singularity.log

mkdir $HOME/singTemp; cd $HOME/singTemp
sudo apt-get install python dh-autoreconf build-essential -y > $singLog
wget https://github.com/singularityware/singularity/releases/download/2.4.1/singularity-2.4.1.tar.gz >> $singLog
tar -xvzf singularity-2.4.1.tar.gz >> $singLog
cd singularity-2.4.1
./configure --prefix=/usr/local --sysconfdir=/etc >> $singLog
make >> $singLog
sudo make install >> $singLog

cd $HOME
rm -rf $HOME/singTemp


#### Set up the BrainPortal Cache and timezone
cd $HOME/cbrain/BrainPortal
Expand All @@ -135,7 +171,7 @@ echo $timezone | xargs -I {} echo 'p=User.first; p.time_zone = "{}"; p.save' | r
echo $HOME | xargs -I {} echo 'DataProvider.create :id => 2, :name => "LocalDP", :type => "FlatDirLocalDataProvider", :remote_dir => "{}/FlatLocalDP", :description => "Automatically Generated Local Data Provider", :user_id => 1, :group_id => 1, :online => 1' | rails c >> $logFile
echo $timezone | xargs -I {} echo 'd=DataProvider.where("id=2").first; d.time_zone = "{}"; d.save' | rails c >> $logFile

cat ~/.ssh/id_cbrain_portal.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/id_cbrain_ed25519.pub >> ~/.ssh/authorized_keys
echo $HOME | xargs -I {} echo 'DataProvider.create :id => 3, :name => "SshDP", :type => "FlatDirSshDataProvider", :remote_dir => "{}/SshDP", :description => "Automatically Generated SSH Data Provider", :user_id => 1, :group_id => 1, :online => 1' | rails c >> $logFile
echo $timezone | xargs -I {} echo 'd=DataProvider.where("id=3").first; d.time_zone = "{}"; d.save' | rails c >> $logFile
echo $USER | xargs -I {} echo 'd=DataProvider.where("id=3").first; d.remote_user = "{}"; d.remote_host = "localhost"; d.remote_port = 22; d.save' | rails c >> $logFile
Expand All @@ -148,15 +184,15 @@ echo $timezone | xargs -I {} echo 'd=DataProvider.where("id=4").first; d.time_zo

# Make sure you can see bundle at login
cd $HOME
echo 'export PATH="$PATH:$HOME/.rvm/bin"' > .tmpbashrc
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> .tmpbashrc
echo 'export PATH="$PATH:/usr/share/rvm/bin"' > .tmpbashrc
echo '[[ -s "/usr/share/rvm/scripts/rvm" ]] && source "/usr/share/rvm/scripts/rvm"' >> .tmpbashrc
cat .bashrc >> .tmpbashrc
cp .bashrc .bashrc.old
mv .tmpbashrc .bashrc

# Create the Bourreau
cd $HOME/cbrain/BrainPortal

echo $HOME | xargs -I {} echo 'RemoteResource.create :id => 2, :name => "LocalBourreau", :type => "Bourreau", :user_id => 1, :group_id => 1, :online => 1, :description => "Automatically Generated Local Bourreau", :ssh_control_host => "localhost", :ssh_control_port => 22, :ssh_control_rails_dir => "{}/cbrain/Bourreau", :tunnel_mysql_port => 3333, :tunnel_actres_port => 3334, :dp_cache_dir => "{}/BorCache", :workers_instances=> 3, :workers_chk_time => 5, :workers_log_to => "combined", :workers_verbose => 1, :read_only => 0, :portal_locked => 0, :cache_trust_expire => 2592000, :cms_class => "ScirUnix", :cms_shared_dir => "{}/BorWork", :docker_executable_name => "docker", :singularity_executable_name => "singularity"' | rails c >> $logFile
echo $HOME | xargs -I {} echo 'RemoteResource.create :id => 2, :name => "LocalBourreau", :type => "Bourreau", :user_id => 1, :group_id => 1, :online => 1, :description => "Automatically Generated Local Bourreau", :ssh_control_host => "localhost", :ssh_control_port => 22, :ssh_control_rails_dir => "{}/cbrain/Bourreau", :dp_cache_dir => "{}/BorCache", :workers_instances=> 3, :workers_chk_time => 5, :workers_log_to => "combined", :workers_verbose => 1, :read_only => 0, :portal_locked => 0, :cache_trust_expire => 2592000, :cms_class => "ScirUnix", :cms_shared_dir => "{}/BorWork", :docker_executable_name => "docker", :singularity_executable_name => "singularity"' | rails c >> $logFile
echo $USER | xargs -I {} echo 'p=RemoteResource.where("id=2").first; p.ssh_control_user = "{}"; p.save' | rails c >> $logFile
echo $timezone | xargs -I {} echo 'p=RemoteResource.where("id=2").first; p.time_zone = "{}"; p.save' | rails c >> $logFile
echo $timezone | xargs -I {} echo 'p=RemoteResource.where("id=2").first; p.time_zone = "{}"; p.save' | rails c >> $logFile