Opyrator instant python web function

How to test opyrator in linux Introduction With opyrator you can create a web function from any python function, it used fastapi, streamlit and pydantic. For this example i just wanted to test what is posible also using pydantic to change some input and output field Setup Start by creating your python virtual environment and activating it python3 -m venv opyrator cd opyrator source bin/activate After that you can install opyrator and what is more needed
One minute to read

loop device mount partitions

If you have a disk image with multiple partitions, this type of image is used a lot for the raspberry pi, you can easily mount them using kpartx, you can install kpartx as follows

arch linux / manjaro sudo pacman -S multipath-tools # ubuntu 24.04 sudo apt install kpartx # centos 8 / oracle sudo yum install kpartx Maybe you need to insert the loop module, if so you can do that like this

One minute to read

Selinux Short

I few shorts remarks about selinux, more like a reminder for myself Restore directory permissions, exmple authorized keys files that doesn’t work restorecon -R -v ~/.ssh How to temporarily disable selinux, i use this for debugging to see if the problem is selinux echo 0 >/selinux/enforce # or setenforce 0 And to enable them again use echo 1 >/selinux/enforce # or setenforce 1
One minute to read

Split a mysql dump in databases

Hello, I once needed to split a mysql dump in to multiple files, one per database so i used this awk one liner. awk -F'`' '{if ($0 ~ /^– Current Database:/) db=$2; print >> db"-split.sql"}' mysql_dump.sql If you need to split one table from one database you can try the following bash scripts !/bin/bash export DATABASE="$1" export TABLE="$2" echo $DATABASE echo $TABLE awk '/Table structure for table .'$TABLE'.$/,/UNLOCK TABLES/{print}' $DATABASE-split.sql
One minute to read

Control cec_client as daemon on pi4

I wanted to control the my television and blu ray player/receiver from my pi, so i installed the client on my raspbian pi installation. Everytime cec_client start it’s does some initializing, so i wanted to run is as some kind of daemon, i thought about a fire options, like maybe some expect kind of script without daemoniziing or a python with python expect to run it and control it, with mayne a socket.
2 minutes to read

reattach ssh or script to new tty

Once in a will you need you have a lang running script that you started into a shell but you want to transfer it to a screen. For this i am using the reptyr program which i installed with sudo pacman -S reptyr or sudo apt-get install reptyr find pid ps ax | grep ssh # find pid 34177 (for example) # start a screen screen -S my_screen_name # in de screen start reptyr reptyr 34177 if you get a issue with ptrace scope just change this value echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
One minute to read

Screen or Daemontools

If you want to start some daemon in the background you can install daemontools and user supervise, but i like to use screen to start daemons in the background, so that i can easily see the output.

check screen if ! /usr/bin/screen -ls | awk '{print $1}' | grep ".${SCREEN_NAME}$" >/dev/null; then echo "starting $SCREEN_NAME" screen -S "${SCREEN_NAME}" -d -m "$COMMAND_SCRIPT" fi I use this snippet, to check of a screen with a given name exists and if not start it up, i run a script i call screen-ls.

4 minutes to read

Boot Raspberry Pi over NFS

The Raspberry Pi is typically booted from an SD card which contains the bootloader and the root partition. This can be limiting from a space and speed perspective,and writes to the card will slowly cause it’s death. SD media doesn’t typically use the same wear leveling technology that goes into a solid state drive. Today I’ll take a quick look at how you can boot your Pi from an NFS server.
One minute to read

On-demand activation of Docker containers with systemd

On-demand activation of Docker containers with systemd One of the features of systemd is its ability to defer the start-up of networked applications until their services are actually requested, a process referred to as socket activation. This isn’t really a new an idea; systemd borrowed the idea from launchd which has been in OS X since Tiger’s release in 2005, and the venerable Unix inetd has implemented a simpler version of it since the 1980s.
One minute to read

bash locking in script

Bash locking Intro Once in a while i want to start a bash script and make sure it one at a time. So searching for solution for creating a lock file in bash, you want to have a solution that doesn’t create a race condition. Explanation Start defining which lockfile you want to use export lockfile=/tmp/lockfile.txt Get pid from lockfile, return empty string if file doesn’t exists or is empty For added protection removed character from the file that isn’t a number
3 minutes to read