# Tasks ## Compilation in containers > 📍 : This task should be done on the Contabo server after connecting with SSH to the user that you did create yesterday on the server (not admin). We want to practice compilation and containers, so lets compile in a container! In this task, we want to compile the program `tmate`. 1. Start an Ubuntu container with `podman run -it --rm --name tmate-compiler ubuntu:latest bash`. 1. Go to the [website of `tmate`](https://tmate.io/) and find out how to compile from source (there are intructions for compiling on Ubuntu). 1. Follow the compilation instructions in the container. 1. After compilation, you will find the binary `tmate` in the directory of the git repository. 1. Don't exit the container yet, otherwise you will lose what you have done in it. Now open a new terminal (tab) and copy the binary `tmate` from the container to the directory `bin` in your home directory. Use the command `podman cp CONTAINERNAME:SRC_PATH DESTINATION_PATH`. 1. Verify that the binary `tmate` was copied to `DESTINATION_PATH` and then exit the container in the first terminal (tab). Now write a script called `compile_tmate.sh` that automates what you have done in the container to compile `tmate`. Just copy all the commands that you used in the container to a script. Add to the end of the script `mv PATH_TO_TMATE_BINARY_IN_CONTAINER /volumes/bin` to copy the binary to the directory `/volumes/bin` after compilation. Create a directory called `scripts` and put the script in it. Now write a second script in the parent directory of the directory `scripts`. The second script should automate creating the container that runs the first script. Do the following in the second script: 1. Check if `scripts/compile_tmate.sh` does NOT exist. In this case you should print a useful message that explains why the script terminates and then exit with error code 1. 1. Make sure that `scripts/compile_tmate.sh` is executable for the user. 1. Create a directory called `bin` (next to the directory `scripts`) if it does not already exist. 1. Use the following snippet: ```bash podman run -it --rm \ --name tmate-compiler \ -v ./scripts:/volumes/scripts:Z,ro \ -v ./bin:/volumes/bin:Z \ docker.io/library/ubuntu:latest \ /volumes/scripts/compile_tmate.sh ``` It creates a container that runs the script `compile_tmate.sh` and is removed afterwards (because of `--rm`). The `scripts` directory is mounted to be able to give the container access to the script `compile_tmate.sh`. The directory is mounted as _read only_ (`ro`) because it will not be modified. The `bin` directory is mounted to be able to trasfer the binary into it before the container exits. After running the second script, you should see the container compiling and then exiting. At the end, you should find the binary `tmate` in the `bin` directory. Now that you have the program `tmate`, find out what it does! Try it with a second person. ##### Tipps: - On debain based distributions like Ubuntu, the package manager is `apt`. Before that you can install any packages with `apt`, you have to run `apt update`. This does not run system updates like `dnf upgrade`. `apt update` does only synchronize the repositories which is needed before installations. - Test if a file exists in bash: ```bash if [ -f FILE_PATH ] then (...) fi ``` Replace `(...)` with your code. For more information on the option `-f` and other useful options for bash conditions, read the man page of the program `test`: `man test`. To test if a file does NOT exist, replace `-f` with `! -f`. - Exit a bash script with error code 1: ```bash exit 1 ``` ## Task: Static website > 📍 : In this task, you should connect as the user `admin` to the Contabo server. **Don't do this task as the user that you did create on the server!** ⚠️ > 📍 : Starting with this task: Asking you to replace `N` means to enter the number that you are using in the URL `ttydN.mo8it.xyz`. In this task, you will host a static website which is a website that does not have a backend. A static website is just a set of HTML, CSS (and optionally JavaScript) files. To host the website, we need a web server. In this task, we will use the Nginx web server. Create a directory `~/nginxN` (replace `N`) with two directories in it: `website` and `conf`. Place these two files: 1. `~/nginxN/conf/nginxN.jinext.xyz.conf` (replace `N`): ``` server { listen 80; server_name nginx0.jinext.xyz; location / { root /volumes/website; index index.html; } } ``` 1. `~/nginxN/website/index.html` (replace `N`): ```