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

Make provisioning scripts run in unprivileged mode + more #17

Merged
merged 7 commits into from
Apr 28, 2021
Merged
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
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Ready-to-use boxes are available on [Vagrant Cloud](https://app.vagrantup.com/pr
You can afterwards also see and manage the produced VM in VirtualBox.

A few things you may need:

- The username and password are `vagrant`/`vagrant`
- The keyboard layout is US English (QWERTY). You can change this in [`install-basics.sh`](./install-basics.sh) or through the keyboard setting shortcut on `~/Desktop`.
- Find scripts to install additional software on `~/Desktop/shared`.
Expand All @@ -40,6 +41,7 @@ A few things you may need:
## What is included?

This box is based on the [bento/ubuntu-20.04](https://github.com/chef/bento/blob/master/packer_templates/ubuntu/ubuntu-20.04-amd64.json) base box and installs:

- Xubuntu-core (Xfce desktop environment) and related tools
- VirtualBox guest additions
- Terminator (a nice split-window terminal emulator, find it in `Applications > System`)
Expand All @@ -49,14 +51,15 @@ This box is based on the [bento/ubuntu-20.04](https://github.com/chef/bento/blob
- preCICE config visualizer latest from the master branch
- preCICE Python bindings
- OpenFOAM v2012 and the OpenFOAM-preCICE adapter
- deal.II 9.2 from the official backports and the deal.II-preCICE adapter (you still need to copy the compiled executables wherever you need them)
- deal.II 9.2 from the official backports and the deal.II-preCICE adapter
- CalculiX 2.16 from source and the CalculiX-preCICE adapter
- FEniCS latest from the FEniCS PPA and the FEniCS-preCICE adapter
- Nutils latest from PIP
- SU2 6.0.0 and the SU2-preCICE adapter from source
- Paraview from the official binaries

It then adds on the `/home/vagrant/Desktop`:
It then adds on the `/home/vagrant/`:

- The preCICE examples (solverdummies), including a copy of the Python solverdummy.
- The preCICE tutorials from the `precice/tutorials`

Expand Down
29 changes: 16 additions & 13 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,35 @@ Vagrant.configure("2") do |config|
end

# Install a desktop environment and basic tools
config.vm.provision "shell", path: "provisioning/install-basics.sh"
config.vm.provision "shell", path: "provisioning/install-basics.sh", privileged: false

# Install common development tools
config.vm.provision "shell", path: "provisioning/install-devel.sh"
config.vm.provision "shell", path: "provisioning/install-devel.sh", privileged: false

# Install preCICE
config.vm.provision "shell", path: "provisioning/install-precice.sh"
config.vm.provision "shell", path: "provisioning/install-precice.sh", privileged: false

# Install solvers, adapters, and related tools
config.vm.provision "shell", path: "provisioning/install-config-visualizer.sh"
config.vm.provision "shell", path: "provisioning/install-openfoam.sh"
config.vm.provision "shell", path: "provisioning/install-dealii.sh"
config.vm.provision "shell", path: "provisioning/install-calculix.sh"
config.vm.provision "shell", path: "provisioning/install-fenics.sh"
config.vm.provision "shell", path: "provisioning/install-nutils.sh"
config.vm.provision "shell", path: "provisioning/install-su2.sh"
config.vm.provision "shell", path: "provisioning/install-paraview.sh"
config.vm.provision "shell", path: "provisioning/install-config-visualizer.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-openfoam.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-dealii.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-calculix.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-fenics.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-nutils.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-su2.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-paraview.sh", privileged: false

# Post-installation steps
config.vm.provision "shell", path: "provisioning/post-install.sh"
config.vm.provision "file", source: "provisioning/install-vscode.sh", destination: "~/Desktop/install-vscode.sh"
config.vm.provision "shell", path: "provisioning/post-install.sh", privileged: false
config.vm.provision "file", source: "provisioning/install-vscode.sh", destination: "~/install-vscode.sh"
config.vm.provision "file", source: "provisioning/get-started.desktop", destination: "~/Desktop/get-started.desktop"

# Pre-packaging steps
# config.vm.provision "shell", path: "provisioning/cleanup.sh", privileged: false
# Add the default Vagrant insecure public key to the authorized keys
config.vm.provision "file", source: "provisioning/vagrant.pub", destination: "~/.ssh/vagrant.pub"
config.vm.provision "shell", inline: <<-SHELL
cat /home/vagrant/.ssh/vagrant.pub >> /home/vagrant/.ssh/authorized_keys
SHELL

end
8 changes: 8 additions & 0 deletions provisioning/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -ex

# Cleanup the APT cache to save space
sudo apt-get clean

# Cleanup all object files from compilation
find /home/vagrant/ -type f -name '*.o' -exec rm -fv {} \;
6 changes: 6 additions & 0 deletions provisioning/get-started.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Desktop Entry]
Encoding=UTF-8
Name=Get started
Type=Link
URL=https://precice.org/installation-vm.html
Icon=text-html
16 changes: 6 additions & 10 deletions provisioning/install-basics.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

USER="vagrant"

# We (may) need the multiverse repository for the VBox Guest Additions
sudo apt-add-repository multiverse
apt-get update
sudo apt-get update
sudo apt-get upgrade -qy

# Install the Xfce desktop environment and basic applications
Expand All @@ -15,16 +13,14 @@ sudo apt-get install -y thunar xfce4-terminal terminator bash-completion tree ev
# Install the VirtualBox guest additions
sudo apt-get install -y virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11

# Create /home/${USER}/desktop
sudo -u ${USER} mkdir -p /home/${USER}/Desktop
chown ${USER}:${USER} /home/${USER}/Desktop
# Create Desktop
mkdir -p ~/Desktop

# Use US-English keyboard layout
L='us' && sudo sed -i 's/XKBLAYOUT=\"\w*"/XKBLAYOUT=\"'$L'\"/g' /etc/default/keyboard
# Add a shortcut to the keyboard options on the Desktop
cp /usr/share/applications/xfce-keyboard-settings.desktop /home/${USER}/Desktop/
chmod +x /home/${USER}/Desktop/xfce-keyboard-settings.desktop
chown ${USER}:${USER} /home/${USER}/Desktop/xfce-keyboard-settings.desktop
cp /usr/share/applications/xfce-keyboard-settings.desktop ~/Desktop/
chmod +x ~/Desktop/xfce-keyboard-settings.desktop

# Set a hostname
echo "precicevm" | sudo tee /etc/hostname
21 changes: 10 additions & 11 deletions provisioning/install-calculix.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

USER="vagrant"

# Install dependencies
sudo apt-get install -y libarpack2-dev libspooles-dev libyaml-cpp-dev

# Install CalculiX
cd /home/${USER}/
# Install CalculiX
wget --quiet http://www.dhondt.de/ccx_2.16.src.tar.bz2
tar xvjf ccx_2.16.src.tar.bz2
tar xvjf ccx_2.16.src.tar.bz2

# Get the CalculiX-preCICE adapter
if [ ! -d "calculix-adapter/" ]; then
sudo -u ${USER} git clone --depth=1 --branch master https://github.com/precice/calculix-adapter.git
git clone --depth=1 --branch master https://github.com/precice/calculix-adapter.git
fi
cd calculix-adapter
git pull
sudo -u ${USER} -s bash -c "make -j 2"
(
cd calculix-adapter
git pull
make -j 2
)

# Add the CalculiX adapter to PATH
echo "export PATH=\"/home/${USER}/calculix-adapter/bin:\${PATH}\"" >> /home/${USER}/.bashrc
echo "export PATH=\"~/calculix-adapter/bin:\${PATH}\"" >>~/.bashrc
14 changes: 6 additions & 8 deletions provisioning/install-config-visualizer.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

USER="vagrant"

# Get the config-visualizer from GitHub
if [ ! -d "config-visualizer/" ]; then
sudo -u ${USER} git clone --depth=1 --branch master https://github.com/precice/config-visualizer.git
git clone --depth=1 --branch master https://github.com/precice/config-visualizer.git
fi
sudo -u ${USER} -s bash -c "pip3 install --user -e config-visualizer"
pip3 install --user -e config-visualizer

# Add the config-visualizer to PATH
echo "export PATH=\"/home/${USER}/config-visualizer/bin:${PATH}\"" >> /home/${USER}/.bashrc
echo "export PATH=\"~/config-visualizer/bin:\${PATH}\"" >>~/.bashrc

# By default, there is no `python` executable, there is only `python3`,
# which causes issues to the config-visualizer
apt-get install -y python-is-python3
sudo apt-get install -y python-is-python3

# Install graphviz, which provides dot, an almost required package to make this useful
apt-get install -y graphviz
sudo apt-get install -y graphviz
22 changes: 9 additions & 13 deletions provisioning/install-dealii.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

USER="vagrant"

# Install deal.II from the deal.II 9.2.0 backports PPA
sudo add-apt-repository ppa:ginggs/deal.ii-9.2.0-backports
sudo apt-get update
sudo apt-get install -y libdeal.ii-dev

# Get the deal.II-preCICE adapter
if [ ! -d "dealii-adapter/" ]; then
sudo -u ${USER} git clone --depth=1 --branch master https://github.com/precice/dealii-adapter.git
git clone --depth=1 --branch master https://github.com/precice/dealii-adapter.git
fi
cd dealii-adapter
git pull

# Build the linear elasticity solver
cd linear_elasticity
sudo -u ${USER} -s bash -c "cmake . && make -j 2"
(
cd dealii-adapter
git pull
cmake . && make -j 2
)

# Build the nonlinear elasticity solver
cd ../nonlinear_elasticity
sudo -u ${USER} -s bash -c "cmake . && make -j 2"
# Add the deal.II adapter to PATH
echo "export PATH=\"~/dealii-adapter:\${PATH}\"" >>~/.bashrc
6 changes: 3 additions & 3 deletions provisioning/install-devel.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

sudo apt-get install -y git cmake cmake-curses-gui
sudo apt-get install -y build-essential git cmake cmake-curses-gui

sudo apt-get install -y nano vim gedit
sudo apt-get install -y nano vim gedit
16 changes: 6 additions & 10 deletions provisioning/install-fenics.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

USER="vagrant"

# Install FEniCS from APT
apt-get install -y software-properties-common
add-apt-repository -y ppa:fenics-packages/fenics
apt-get -y update
apt-get -y install --no-install-recommends fenics
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:fenics-packages/fenics
sudo apt-get -y update
sudo apt-get -y install --no-install-recommends fenics

# Install the FEniCS-preCICE adapter from PIP
sudo -u ${USER} pip3 install --user fenicsprecice
# Remove a conflicting with the adapter package
pip3 uninstall -y fenics-ufl
pip3 install --user fenicsprecice
6 changes: 2 additions & 4 deletions provisioning/install-nutils.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

USER="vagrant"

# Install Nutils from PIP (we will also need matplotlib in our examples)
sudo -u ${USER} pip3 install --user matplotlib nutils
pip3 install --user matplotlib nutils
21 changes: 11 additions & 10 deletions provisioning/install-openfoam.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

USER="vagrant"

# Add the signing key, add the repository, update:
wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash

# Install OpenFOAM v2012:
sudo apt-get install -y openfoam2012-dev
openfoam-selector --set openfoam2012 --system
# todo: Somehow the openfoam-selector is not enough - the binaries are discoverable, but the libraries not. Remedy:
echo "source /etc/profile.d/openfoam-selector.sh" >> /home/vagrant/.bashrc
# Enable OpenFOAM by default and apply now:
echo ". /usr/lib/openfoam/openfoam2012/etc/bashrc" >> ~/.bashrc
# shellcheck source=/dev/null
# . /usr/lib/openfoam/openfoam2012/etc/bashrc

# Get the OpenFOAM-preCICE adapter
if [ ! -d "openfoam-adapter/" ]; then
sudo -u ${USER} git clone --depth=1 --branch master https://github.com/precice/openfoam-adapter.git
git clone --depth=1 --branch master https://github.com/precice/openfoam-adapter.git
fi
cd openfoam-adapter
git pull
sudo -u ${USER} -s bash -l ./Allwmake
(
cd openfoam-adapter
git pull
./Allwmake
)
13 changes: 5 additions & 8 deletions provisioning/install-paraview.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

USER="vagrant"

if [ ! -d "paraview" ]; then
mkdir paraview
PARAVIEW_URL="https://www.paraview.org/paraview-downloads/download.php?submit=Download&version=v5.8&type=binary&os=Linux&downloadFile=ParaView-5.8.1-MPI-Linux-Python3.7-64bit.tar.gz"
wget --no-check-certificate --quiet -O - ${PARAVIEW_URL} | tar -xz -C paraview
ln -sf /home/${USER}/paraview/ParaView-5.8.1-MPI-Linux-Python3.7-64bit/bin/paraview /home/${USER}/Desktop/
chown ${USER}:${USER} /home/${USER}/Desktop/paraview
wget --no-check-certificate --quiet -O - "${PARAVIEW_URL}" | tar -xz -C paraview
ln -sf ~/paraview/ParaView-5.8.1-MPI-Linux-Python3.7-64bit/bin/paraview ~/Desktop/
# Add ParaView to PATH
echo "export PATH=\"/home/${USER}/paraview/ParaView-5.8.1-MPI-Linux-Python3.7-64bit/bin:\${PATH}\"" >> /home/${USER}/.bashrc
fi
echo "export PATH=\"~/paraview/ParaView-5.8.1-MPI-Linux-Python3.7-64bit/bin:\${PATH}\"" >>~/.bashrc
fi
50 changes: 25 additions & 25 deletions provisioning/install-precice.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

USER="vagrant"

# Get preCICE dependencies
apt-get install -y build-essential cmake libeigen3-dev libxml2-dev libboost-all-dev petsc-dev python3-dev python3-numpy
sudo apt-get install -y cmake libeigen3-dev libxml2-dev libboost-all-dev petsc-dev python3-dev python3-numpy

# Get preCICE from GitHub:
# - Always get the latest master, no need for versioning
# - Build in Debug mode, so that users can report bugs
if [ ! -d "precice/" ]; then
sudo -u ${USER} git clone --depth=1 --branch master https://github.com/precice/precice.git
git clone --depth=1 --branch master https://github.com/precice/precice.git
fi
(
cd precice
git pull
sudo -u ${USER} -s bash -c "mkdir build && cd build/ && rm -fv *.deb && cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug .. && make -j 2 && make package"
apt-get install -y ./build/libprecice2_*.deb
fi
mkdir -p build && cd build/
cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug -Wno-dev ..
make -j 2
rm -fv ./*.deb && make package
sudo apt-get install -y ./libprecice2_*.deb
)

# Collect examples
cd /home/${USER}/Desktop
sudo -u ${USER} cp -r /usr/share/precice/examples/ .
if [ ! -d "tutorials/" ]; then
sudo -u ${USER} git clone --branch master https://github.com/precice/tutorials.git
fi
cd -
# Collect examples and tutorials
cp -r /usr/share/precice/examples/ ./precice-examples
if [ ! -d "tutorials/" ]; then
git clone --depth=1 --branch master https://github.com/precice/tutorials.git
ln -sf ~/tutorials ~/Desktop/
fi

### OPTIONAL - preCICE Python bindings and Python example
# Get PIP and the preCICE Python bindings
sudo apt-get install -y python3-pip
sudo -u ${USER} pip3 install --upgrade pip
sudo -u ${USER} pip3 install --user pyprecice
pip3 install --upgrade pip
pip3 install --user pyprecice

# Get the Python solverdummy into the examples
cd /home/${USER}/Desktop
if [ ! -d "python-bindings/" ]; then
sudo -u ${USER} git clone --branch master https://github.com/precice/python-bindings.git
fi
sudo -u ${USER} cp -r python-bindings/solverdummy/ examples/solverdummies/python/
sudo rm -r python-bindings
cd -
###
if [ ! -d "python-bindings/" ]; then
git clone --depth=1 --branch master https://github.com/precice/python-bindings.git
fi
cp -r python-bindings/solverdummy/ precice-examples/solverdummies/python/
rm -r python-bindings
###
Loading