Category: Linux

Sagemath

Since Fedora 39 sagemath is not included as a package anymore. There are several possibilities you can use sagemath on Fedora, let’s highlight two:

  • Using the offical docker image
  • Installing it with conda

Podman

sagemath commandline

As our installation provides a fully configured rootless podman configuration, you can for example use the following commands to run the sagemath image:

# connect to a central client
ssh ada-X
# start tmux, alternativly you can use screen
tmux
# create a .sage folder
mkdir $HOME/.sage

# run sage with your home mounted to /home/sage/mydata and a mounted .sage
podman run --user 0 -ti -v $HOME/.sage:/home/sage/.sage -v $HOME:/home/sage/mydata sagemath/sagemath:latest

# to detach from the tmux session use the following keystrokes
#CTRL+B then D

To add a additional folder you can put a other -v parameter, for example:

-v /userdata/username:/home/sage/mydata2
sagemath jupyter notebook

When you want to use the sage jupyter notebook, you can do the following:

# connect to a central client
ssh ada-X
# start tmux, alternativly you can use screen
tmux
# create a .sage folder
mkdir $HOME/.sage

# run sage jupyter on port 8888
podman run --user 0 -p 8888:8888 -v $HOME/.sage:/home/sage/.sage -v $HOME:/home/sage/mydata sagemath/sagemath:latest sage-jupyter --allow-root

# to detach from the tmux session use the following keystrokes
#CTRL+B then D

Then open a second terminal on your local machine and open ssh tunnel to the ada:

# port forward from to ada-X
ssh -t username@ada-X -L 8888:localhost:8888

# Open webbrowser using the url with token shown in the output.

Conda

Please follow the official installation instruction:

Read more

Posted on

Moodle Development Environment

Develop moodle

The following setup can be used to setup a moodle development environment, with rootless podman:

# D-MATH link podman-compose
ln -s /usr/bin/podman-compose ~/bin/docker-compose

# D-MATH clone moodle-docker repo
git clone https://github.com/moodlehq/moodle-docker.git
cd moodle-docker

# D-MATH set variables
export MOODLE_DOCKER_DB_PORT=15432
export MOODLE_DOCKER_APP_VERSION=18080
export MOODLE_DOCKER_SELENIUM_VNC_PORT=15900
export MOODLE_DOCKER_WEB_PORT=18000

# Change ./moodle to your /path/to/moodle if you already have it checked out
export MOODLE_DOCKER_WWWROOT=./moodle

# D-MATH add custom configuration
cat <<EOF > local.yml
services:
  webserver:
    volumes:
      - "${MOODLE_DOCKER_WWWROOT}/../moodledata:/var/www/moodledata"
  db:
    environment:
      PGDATA: /var/lib/postgresql/data/pgdata
    volumes:
      - "${MOODLE_DOCKER_WWWROOT}/../database:/var/lib/postgresql/data"
EOF

# Choose a db server (Currently supported: pgsql, mariadb, mysql, mssql, oracle)
export MOODLE_DOCKER_DB=pgsql

# D-MATH creating files with group access for moodle code
umask 007

# Get Moodle code, you could select another version branch (skip this if you already got the code)
git clone -b MOODLE_404_STABLE git://git.moodle.org/moodle.git $MOODLE_DOCKER_WWWROOT

# D-MATH add folder for moodle data
mkdir moodledata
mkdir database

# D-MATH setgid for automatic setting group permission
chmod 2770 moodle
chmod 2770 moodledata
chmod 2770 database

# Ensure customized config.php for the Docker containers is in place
cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php

# D-MATH set the permission to 33 inside the container for moodle code
podman unshare chown 33 -R moodle
podman unshare chown 33 -R moodledata
podman unshare chown 999 -R database

# Start up containers, choose docker.io to download the images
bin/moodle-docker-compose up -d

# Shut down and destroy containers
#bin/moodle-docker-compose down

Above we set the webserver port to 18000 so this means you now need connect to http://localhost:18000 in your browser to see the application.

Volume Permissions

If you have added new files from outside the container, you need to re-apply the correct permissions. Let’s say you have added files inside the moodle folder, then you need to run the following command:

# set the permission to 33 
podman unshare chown 33 -R moodle

Visual Studio Code

To prevent the above Volume Permission problem, you can connect your locally installed Visual Studio Code to the running container:

  • Open Visual Studio Code
  • Hit F1
  • Search for Attach to Running Container
  • Choose the webserver container
  • Now open the folder /var/www/html

If you need to run some commands in the container:

  • After being connected to the container
  • Hit Ctrl+`

Read more

Posted on

minikube (Kubernetes Development)

If you want to develop something for kubernetes, you may need to run minikube. This can be done on our linux installations, the following commands should start a working “kubernetes cluster” on your installation:

mkdir ~/bin/

wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O ~/bin/minikube
chmod 755 ~/bin/minikube

cd ~/bin/
./minikube config set rootless true
./minikube config set driver podman
./minikube config set container-runtime containerd

./minikube start --cni calico

After minikube has started you can check all running pods with the following:

minikube kubectl -- get pods -A

You can also install kubectl and helm in your ~/bin if you like:

cd ~/bin/

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

export HELM_INSTALL_DIR=~/bin; export USE_SUDO=false; curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

Read more

Posted on

Linux (Evolution) local mail archive

This describes how to create a local folder in which you can move emails, which will still be available in the evolution mail client. So the mails will be removed from the mailserver and saved into a folder, which you have to backup.

Requirements:

  • You already use evolution as your mail client
  • You make backups of your local files and folders

First create a folder in the filesystem, which will hold your mails:

Now open evolution and start adding a new mail account:

This account will be your local archive, so you can give it a meaningfull name, ex. “Local Archive”. As for the email address you can type in a non existing one, i suggest “archive@local”, this names will help to identify it in evolution later:

After hitting “Next” choose “Standard Unix mbox spool directory” as Server type:

For the “Spool Directory” choose the folder you have created above:

On the next page activate the following:

Choose “None” as the “Server Type”:

“Next” it will ask you for the name which will appear in evolution:

Now you have the new account:

You need to create a folder now to put your mails into:

For example you can create a new one each year:

Now you can move mails from your account into this folder, they will be saved on your filesystem, so don’t forget to regulary make a backup.

Read more

Posted on

Howto use docker at D-MATH

To use docker at D-MATH is to use podman -> https://podman.io/

With podman you can use all docker commands just write podman instead of docker in the command, all the parameter stay the same.

With podman we are able to provide a possibility that a user without administrative rights can download and run docker images.

Example 1

The following example will run the latest docker image of alpine linux (https://hub.docker.com/_/alpine).

podman run -ti -v $(pwd):/home/test alpine:latest

The parameter

  • -v $(pwd):/home/test

is very helpful, this will add the current folder you are in now, to the container at /home/test. If you have seLinux activated you need to add a Z:

  • -v $(pwd):/home/test:Z

Example 2

The following example shows howto run a more complicated docker image named fenics and transfer files.

First open a terminal and go into the folder which you want to have accessable in the docker image.

mkdir -p ~/Documents/mydata
cd ~/Documents/mydata

Now run the container with the following parameters:

podman run -ti -p 127.0.0.1:8000:8000 -v $(pwd):/home/fenics/shared -w /home/fenics/shared quay.io/fenicsproject/stable:current

This will connect you to the container.

But the docker image of the fenicsproject will log you in a user fenics, this user will not have access to the data in ~/Documents/mydata.

With podman the user root in the container will have access to your files.

So you need to become root inside the container to have access:

sudo su -

Read more

Posted on

Linux Environment Modules at the D-MATH

With Environment Modules or simply called Modules it is possible to dynamically expand the active user environment and to remove it again without closing the shell.

Read more

Posted on ,

Tensorflow

On our Linux devices we are providing a Python Tensorflow Module ready to use that is accessible trough a Linux Environment Module. With the command “module” you have the possibility to add Tensorflow in many different versions. By default the newest is chosen. Read more

Posted on , 2 Comments

PROTECT YOUR BRAINWORK.

An IT Security Initiative
https://itsecurity.ethz.ch

Trending

Categories

Recent Posts