From 66ee0cdddd9b2d131639b99181499a33fa2c892d Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Fri, 30 Apr 2021 17:52:53 +0200 Subject: [PATCH] Update main, v202104.1.0 (#22) * Make provisioning scripts run in unprivileged mode + more (#17) * Move install-vscode to home * Enable object files clean-up by default * Move cleanup steps to cleanup.sh * Add GitHub action to lint shell scripts (#18) * Add GitHub action for vagrant up + a few fixes (#19) * Add code_aster (#20) * Disable screensaver and screen lock (#21) * Update README, add instructions for testing * Add alias for config-visualizer --- .github/workflows/build.yml | 38 +++++++++++ .github/workflows/check-shell.yml | 12 ++++ README.md | 47 +++++++++++--- Vagrantfile | 31 +++++---- provisioning/.alias | 12 ++++ provisioning/cleanup.sh | 8 +++ provisioning/get-started.desktop | 6 ++ provisioning/install-basics.sh | 16 ++--- provisioning/install-calculix.sh | 22 +++---- provisioning/install-code_aster.sh | 77 +++++++++++++++++++++++ provisioning/install-config-visualizer.sh | 14 ++--- provisioning/install-dealii.sh | 22 +++---- provisioning/install-devel.sh | 6 +- provisioning/install-fenics.sh | 16 ++--- provisioning/install-nutils.sh | 6 +- provisioning/install-openfoam.sh | 19 +++--- provisioning/install-paraview.sh | 13 ++-- provisioning/install-precice.sh | 49 ++++++++------- provisioning/install-su2.sh | 48 +++++++++----- provisioning/install-vscode.sh | 2 +- provisioning/post-install.sh | 15 +++-- 21 files changed, 333 insertions(+), 146 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/check-shell.yml create mode 100644 provisioning/.alias create mode 100644 provisioning/cleanup.sh create mode 100755 provisioning/get-started.desktop create mode 100644 provisioning/install-code_aster.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..2039489 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,38 @@ +name: Build and package +on: + pull_request: + types: [ready_for_review] +jobs: + vagrant-up: + runs-on: macos-10.15 + + steps: + - uses: actions/checkout@v2 + + - name: Cache Vagrant boxes + uses: actions/cache@v2 + with: + path: ~/.vagrant.d/boxes + key: ${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }} + restore-keys: | + ${{ runner.os }}-vagrant- + + - name: Show Vagrant version + run: vagrant --version + + - name: Run vagrant up + run: vagrant up + + - name: Package Vagrant box + run: vagrant package --base "preCICE-VM" --output preCICE.box + + - name: Generate Vagrant box SHA256 hash + run: shasum -a 256 preCICE.box + + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: precice-vagrant-box + path: preCICE.box + retention-days: 7 + diff --git a/.github/workflows/check-shell.yml b/.github/workflows/check-shell.yml new file mode 100644 index 0000000..aec0f80 --- /dev/null +++ b/.github/workflows/check-shell.yml @@ -0,0 +1,12 @@ +name: Lint scripts +on: [push, pull_request] +jobs: + check_shell: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v2 + - name: Lint shell scripts (shellcheck) + uses: ludeeus/action-shellcheck@master + with: + ignore: Vagrantfile diff --git a/README.md b/README.md index 7163797..91e778a 100644 --- a/README.md +++ b/README.md @@ -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`. @@ -40,27 +41,33 @@ 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`) - Git, CMake, ccmake - Editors: nano, vim, gedit - preCICE latest for the master branch -- 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) -- CalculiX 2.16 from source and the CalculiX-preCICE adapter -- FEniCS latest from the FEniCS PPA and the FEniCS-preCICE adapter +- preCICE config visualizer (master) +- preCICE Python bindings (PIP) +- OpenFOAM v2012 and the OpenFOAM-preCICE adapter (master) +- deal.II 9.2 from the official backports and the deal.II-preCICE adapter (master) +- CalculiX 2.16 from source and the CalculiX-preCICE adapter (master) +- FEniCS latest from the FEniCS PPA and the FEniCS-preCICE adapter (PIP) - Nutils latest from PIP -- SU2 6.0.0 and the SU2-preCICE adapter from source +- SU2 6.0.0 and the SU2-preCICE adapter (master) +- code_aster 14.6 and the code_aster-preCICE adapter (master) - Paraview from the official binaries +- Gnuplot + +It then adds to the `/home/vagrant/`: -It then adds on the `/home/vagrant/Desktop`: - The preCICE examples (solverdummies), including a copy of the Python solverdummy. - The preCICE tutorials from the `precice/tutorials` The adapter repositories remain in `/home/vagrant/`. +It also adds a few shortcuts on the Desktop (see `post-install.sh`). +At the end, it cleans up all object files and the APT cache (see `cleanup.sh`). ## Troubleshooting @@ -77,3 +84,27 @@ Usually running again (e.g. with `vagrant up --provision`) helps. ### There is no GUI In case you killed the session before provisioning finished, the setup of your VM might be incomplete. You might still be able to interact with the VM without the GUI. In that case, run `vagrant up --provision`. + +## Testing before publishing + +We now have a GitHub action that can build the Vagrant box. This workflow only runs for pull requests that are marked as "ready for review" (i.e. not "draft"), as it takes significant time to complete (~1.5h). If you already submitted a normal PR but the workflow is not triggered, convert the PR to draft and then to "ready for review" again. + +The workflow uploads the resulting box as an artifact and it also prints its SHA256 checksum before that. Download the job artifact and unzip it. Then run add the box to Vagrant: + +```bash +vagrant box add test-box precice-vagrant-box/preCICE.box +``` + +You can then start a VM by going into an empty directory and executing: + +```bash +vagrant init test-box +vagrant up +``` + +Afterwards, you probably want to destroy everything to save storage space: + +```bash +vagrant destroy +vagrant box remove test-box +``` diff --git a/Vagrantfile b/Vagrantfile index e2b11a5..06dd3b1 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -26,32 +26,37 @@ 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-code_aster.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" + config.vm.provision "file", source: "provisioning/.alias", destination: "~/.alias" # 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 diff --git a/provisioning/.alias b/provisioning/.alias new file mode 100644 index 0000000..c480e17 --- /dev/null +++ b/provisioning/.alias @@ -0,0 +1,12 @@ +# preCICE config visualizer +function config-visualizer-pdf(){ + cat $1 | precice-config-visualizer | dot -Tpdf > precice-config.pdf +} + +function config-visualizer-svg(){ + cat $1 | precice-config-visualizer | dot -Tsvg > precice-config.svg +} + +function config-visualizer(){ + cat $1 | precice-config-visualizer | dot -Tpng > precice-config.png +} diff --git a/provisioning/cleanup.sh b/provisioning/cleanup.sh new file mode 100644 index 0000000..91dccf0 --- /dev/null +++ b/provisioning/cleanup.sh @@ -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}" -type f -name '*.o' -exec rm -fv {} \; diff --git a/provisioning/get-started.desktop b/provisioning/get-started.desktop new file mode 100755 index 0000000..c00d80a --- /dev/null +++ b/provisioning/get-started.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Get started +Type=Link +URL=https://precice.org/installation-vm.html +Icon=text-html diff --git a/provisioning/install-basics.sh b/provisioning/install-basics.sh index 97cf3e0..76fda55 100644 --- a/provisioning/install-basics.sh +++ b/provisioning/install-basics.sh @@ -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 @@ -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 diff --git a/provisioning/install-calculix.sh b/provisioning/install-calculix.sh index 2e4a265..e75730b 100644 --- a/provisioning/install-calculix.sh +++ b/provisioning/install-calculix.sh @@ -1,23 +1,23 @@ -#!/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 +rm -fv 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 \ No newline at end of file +echo "export PATH=\"\${HOME}/calculix-adapter/bin:\${PATH}\"" >>~/.bashrc diff --git a/provisioning/install-code_aster.sh b/provisioning/install-code_aster.sh new file mode 100644 index 0000000..cede151 --- /dev/null +++ b/provisioning/install-code_aster.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +set -ex + +# Install dependencies +sudo apt-get install -y bison cmake make flex g++ gcc gfortran \ + grace liblapack-dev libblas-dev \ + libboost-numpy-dev libboost-python-dev \ + python3 python3-dev python3-numpy \ + tk zlib1g-dev + +# Install code_aster 14.6 - skip to save time if target dir exists +if [ ! -d "code_aster/" ]; then + wget --quiet https://www.code-aster.org/FICHIERS/aster-full-src-14.6.0-1.noarch.tar.gz + tar xvzf aster-full-src-14.6.0-1.noarch.tar.gz && rm -fv aster-full-src-14.6.0-1.noarch.tar.gz + ( + cd aster-full-src-14.6.0 + yes | python3 setup.py install --prefix="${HOME}/code_aster" + ) + echo ". ${HOME}/code_aster/etc/codeaster/profile.sh" >>~/.bashrc + rm -rf ./aster-full-src-14.6.0/ +fi + +# Get the code_aster-preCICE adapter +if [ ! -d "code_aster-adapter/" ]; then + git clone --depth=1 --branch master https://github.com/precice/code_aster-adapter.git +fi +( + cd "${HOME}/code_aster/14.6/lib/aster/Execution" + ln -sf "${HOME}/code_aster-adapter/cht/adapter.py" . +) + +# Optional: Update the tutorials exchange directory (needs to be absolute) and generate the export file. +( + cd "${HOME}/tutorials/flow-over-heated-plate-steady-state" + + sed -i "s|exchange-directory=\"..\"|exchange-directory=\"$(pwd)\"|g" precice-config.xml + + cd ./solid-codeaster + if [ ! -f "solid.export" ]; then + { + echo "P actions make_etude" + echo "P aster_root /code_aster" + echo "P consbtc oui" + echo "P debug nodebug" + echo "P display precicevm:0" + echo "P follow_output yes" + echo "P mclient precicevm" + echo "P memjob 524288" + echo "P memory_limit 512.0" + echo "P mode interactif" + echo "P ncpus 1" + echo "P nomjob linear-thermic" + echo "P origine salomemeca_asrun 1.10.0" + echo "P protocol_copyfrom asrun.plugins.server.SCPServer" + echo "P protocol_copyto asrun.plugins.server.SCPServer" + echo "P protocol_exec asrun.plugins.server.SSHServer" + echo "P rep_trav /tmp/root-23129e00f0db-interactif_4800" + echo "P serveur localhost" + echo "P soumbtc oui" + echo "P time_limit 600.0" + echo "P tpsjob 11" + echo "P uclient precicevm" + echo "P username precicevm" + echo "P version stable" + echo "A memjeveux 64.0" + echo "A tpmax 600.0" + echo "F comm ${HOME}/code_aster-adapter/cht/adapter.comm D 1" + echo "F libr $(pwd)/config.comm D 90" + echo "F libr $(pwd)/def.comm D 91" + echo "F mmed $(pwd)/solid.mmed D 20" + echo "R repe $(pwd)/REPE_OUT D 0" + echo "R repe $(pwd)/REPE_OUT R 0" + echo "F mess $(pwd)/solid.mess R 6" + echo "F resu $(pwd)/solid.resu R 8" + } >>solid.export + fi +) diff --git a/provisioning/install-config-visualizer.sh b/provisioning/install-config-visualizer.sh index 68cc9a9..06359ac 100644 --- a/provisioning/install-config-visualizer.sh +++ b/provisioning/install-config-visualizer.sh @@ -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=\"\${HOME}/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 diff --git a/provisioning/install-dealii.sh b/provisioning/install-dealii.sh index 65e7a4c..ea3ce00 100644 --- a/provisioning/install-dealii.sh +++ b/provisioning/install-dealii.sh @@ -1,8 +1,6 @@ -#!/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 @@ -10,15 +8,13 @@ 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=\"\${HOME}/dealii-adapter:\${PATH}\"" >>~/.bashrc diff --git a/provisioning/install-devel.sh b/provisioning/install-devel.sh index 36a15a6..b4f8397 100644 --- a/provisioning/install-devel.sh +++ b/provisioning/install-devel.sh @@ -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 \ No newline at end of file +sudo apt-get install -y nano vim gedit diff --git a/provisioning/install-fenics.sh b/provisioning/install-fenics.sh index 4d59a26..8348604 100644 --- a/provisioning/install-fenics.sh +++ b/provisioning/install-fenics.sh @@ -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 \ No newline at end of file +pip3 install --user fenicsprecice diff --git a/provisioning/install-nutils.sh b/provisioning/install-nutils.sh index 591d3d8..7438ef2 100644 --- a/provisioning/install-nutils.sh +++ b/provisioning/install-nutils.sh @@ -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 diff --git a/provisioning/install-openfoam.sh b/provisioning/install-openfoam.sh index 2e8dd46..64c6a5f 100644 --- a/provisioning/install-openfoam.sh +++ b/provisioning/install-openfoam.sh @@ -1,21 +1,20 @@ -#!/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: +echo ". /usr/lib/openfoam/openfoam2012/etc/bashrc" >> ~/.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 + openfoam2012 ./Allwmake +) diff --git a/provisioning/install-paraview.sh b/provisioning/install-paraview.sh index c9e3125..2d07842 100644 --- a/provisioning/install-paraview.sh +++ b/provisioning/install-paraview.sh @@ -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 \ No newline at end of file + echo "export PATH=\"\${HOME}/paraview/ParaView-5.8.1-MPI-Linux-Python3.7-64bit/bin:\${PATH}\"" >>~/.bashrc +fi diff --git a/provisioning/install-precice.sh b/provisioning/install-precice.sh index f7c49a4..32768d3 100644 --- a/provisioning/install-precice.sh +++ b/provisioning/install-precice.sh @@ -1,43 +1,44 @@ -#!/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 + 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 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 +sudo apt-get -y install gnuplot # needed for watchpoint scripts of tutorials -# 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 - -apt-get -y install gnuplot # needed for watchpoint scripts of tutorials ### 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 ### diff --git a/provisioning/install-su2.sh b/provisioning/install-su2.sh index e92ed88..006eca7 100644 --- a/provisioning/install-su2.sh +++ b/provisioning/install-su2.sh @@ -1,27 +1,41 @@ -#!/bin/sh +#!/usr/bin/env bash set -ex -USER="vagrant" - # Get SU2 6.0.0 from GitHub -cd /home/${USER} -sudo -u ${USER} -s bash -c "wget --quiet https://github.com/su2code/SU2/archive/v6.0.0.tar.gz && tar -xzf v6.0.0.tar.gz" +wget --quiet https://github.com/su2code/SU2/archive/v6.0.0.tar.gz +tar -xzf v6.0.0.tar.gz +rm -fv v6.0.0.tar.gz + +# Add SU2 to PATH and apply. +# We first export to a separate script, so that we can load it here (non-interactive shell). +{ + echo "export SU2_HOME=\"\${HOME}/SU2-6.0.0\"" + echo "export SU2_RUN=\"\${SU2_HOME}/SU2_CFD/bin\"" + echo "export PATH=\"\${SU2_RUN}:\${PATH}\"" + echo "export PYTHONPATH=\"\${SU2_RUN}:\${PYTHONPATH}\"" +} >> ~/.su2-bashrc -# Add SU2 to PATH -echo "export PATH=\"/home/${USER}/SU2-6.0.0-bin/bin:\${PATH}\"" >> /home/${USER}/.bashrc -echo "export PYTHONPATH=\"/home/${USER}/SU2-6.0.0-bin/bin:\${PYTHONPATH}\"" >> /home/${USER}/.bashrc +echo ". \${HOME}/.su2-bashrc" >> ~/.bashrc +# shellcheck source=/dev/null +. ~/.su2-bashrc # Get the SU2-preCICE adapter if [ ! -d "su2-adapter/" ]; then - sudo -u ${USER} git clone --depth=1 --branch master https://github.com/precice/su2-adapter.git + git clone --depth=1 --branch master https://github.com/precice/su2-adapter.git fi -cd su2-adapter -git pull -sudo -u ${USER} -s bash -c "SU2_HOME=\"/home/${USER}/SU2-6.0.0\" ./su2AdapterInstall" +( + cd su2-adapter + git pull + ./su2AdapterInstall +) # Configure and build the SU2 adapter -cd /home/${USER}/SU2-6.0.0 -sudo -u ${USER} -s bash -c "./configure --disable-metis --disable-parmetis --disable-cgns --disable-DOT \ - --disable-MSH --disable-DEF --disable-SOL --disable-GEO \ - --prefix=\"/home/${USER}/SU2-6.0.0-bin\" CXXFLAGS='-std=c++11' && make -j 2" -sudo make install && find . -type f -name '*.o' -exec rm {} \; +( + cd "${SU2_HOME}" + ./configure --disable-metis --disable-parmetis --disable-cgns --disable-DOT \ + --disable-MSH --disable-DEF --disable-SOL --disable-GEO \ + --prefix="${SU2_RUN}" CXXFLAGS='-std=c++11' + make -j 2 + # We still need sudo for whatever reason + sudo make install +) diff --git a/provisioning/install-vscode.sh b/provisioning/install-vscode.sh index 1705156..a1b5f88 100755 --- a/provisioning/install-vscode.sh +++ b/provisioning/install-vscode.sh @@ -5,4 +5,4 @@ sudo snap install code --classic # Install C++ extension code --install-extension ms-vscode.cpptools -code --install-extension austin.code-gnu-global \ No newline at end of file +code --install-extension austin.code-gnu-global diff --git a/provisioning/post-install.sh b/provisioning/post-install.sh index 49d93ea..d37fb74 100644 --- a/provisioning/post-install.sh +++ b/provisioning/post-install.sh @@ -1,10 +1,13 @@ -#!/bin/sh +#!/usr/bin/env bash set -ex # Create a link to the default shared folder -ln -sf /vagrant/ /home/vagrant/Desktop/ -mv /home/vagrant/Desktop/vagrant /home/vagrant/Desktop/shared -chown vagrant:vagrant /home/vagrant/Desktop/shared +ln -sf /vagrant/ ~/Desktop/shared -# Cleanup the APT cache to save space -apt-get clean \ No newline at end of file +# Disable the screensaver and automatic screen lock +{ + echo "xset s off -dpms" + echo "gsettings set org.gnome.desktop.screensaver lock-enabled false" +} >> ~/.bashrc + +echo "source ${HOME}/.alias" >>~/.bashrc