#bash

bkoehn@diaspora.koehn.com

Today I produced the following script, that receives as input an email containing a DMARC XML report as an attachment, extracts the attachment, decompresses it, and queries the report to see if there are failures coming from any of the IPs that I use to send mail (ignoring those I don’t use/control), and sends an error message and the decompressed file to a room on my Matrix server for any failures it finds.

#!/bin/bash

TMP=$(mktemp -d)

SOURCE_IPS=$(host mail.koehn.com | grep address | awk '{print "\""$(NF)"\","}' | tr '\n' ' ' | sed 's/, $//')

cd "$TMP" || exit 1

function cleanup {
  rm -rf "$TMP"
}

trap cleanup EXIT

FILES=$(munpack -f 2>/dev/null | awk '{print $1}')

for file in $FILES ; do
    if 7z e -so "$file" | xidel --data - --xquery './/row[source_ip=('"$SOURCE_IPS"') and (policy_evaluated/dkim="fail" or policy_evaluated/spf="fail")]' 2> >(grep -v "Processing: stdin") | grep . ; then
    mc -m "🔴 Received DMARC report containing failures: $file"
    mc -f "$file"
  fi
done

#bash #mpack #xquery #email #dmarc #matrix #chatops

bkoehn@diaspora.koehn.com

I worked quite hard to solve this problem, and I’m happy with its (eventual) simplicity. When you have (for example) two Kubernetes containers in a pod (or two processes that can share a named pipe) and you need to run a process on one of them from the other one, I have just the tool for you. It’s basically ssh without all the pesky networking, using named pipes instead of TCP streams.

https://unix.stackexchange.com/a/735642/157130

#linux #kubernetes #docker #fifo #bash

danie10@squeet.me

Four simple steps to make Linux’s Bash prettier and more functional for non-expert users

Bild/Foto
Many remote (and even local) commands can executed so much quicker when using Bash instead of graphical user interfaces, but for newer users, Bash can be an unfriendly and cumbersome environment.

In this video I show how, with the installation of just three applications and some alias commands, we can make working with Bash much faster, easier, and prettier!

See https://youtu.be/OR2G9OSlmVI

#technology #Linux #Bash #tips #productivity
#Blog, ##bash, ##linux, ##productivity, ##technology, ##tips

paulkater@diasp.org

I rebuilt a system for keeping electronic notes for other programs, and moved that from a flat text file to a MySql database table, fixing the script and the 2 programs that use that information.

The name, in English, is a bit like ‘rubbish’, which holds dear memories of my first job, where we had a similar system to keep pointers, last-used-dates and other unrelated stuff together.

#MySQL #Bash #Python

federatica_bot@federatica.space

Full Circle Magazine #184

image

This month: * Command & Conquer * How-To : Bash to Python, Migrating from VAX/VMS and Latex * Graphics : Inkscape * Everyday Ubuntu: Diagramming with Dia * Review : Xubuntu 22.04 * Review : Void Linux * Ubuntu Games : Crystal Caves HD plus: News, My Opinion, The Daily Waddle, Q&A, and more. Get it while it's

#magazine #bash #crystalcaves #dia #diagram #inkscape #latex #python #qa #vax #vaxvms #vms #void #voidlinux #waddle #xubuntu #fullcirclemagazine #ubuntu #linux

paulkater@diasp.org

Wrote a #bash script and #python program to keep a max of 5 backups / generations of changed writing projects. Nothing fancy. And yet, each time when I see it worked and did its job, I'm happy.

canoodle@nerdpol.ch

GNU Linux bash - the ultimate (LTE) modem debugging one-liner

currently wrestling with a LTE modem, that used to work under Ubuntu, but refuses to work under Debian 11.

<span style="color: #00ffff;">while true; do echo "=== show modem status:"; mmcli -m 1|grep -e model -e primary -e state -e signal; echo -e "\n=== show routing table:"; route -n; echo -e "\n=== show arp table:"; arp -an; echo -e "\n=== ping a host 3x times:"; ip -c a; ping -c3 1.1.1.1; sleep 1; clear; done</span>


# info about the system
<span style="color: #00ffff;">lsb_release -d</span>
Description:    Debian GNU/Linux 11 (bullseye)

<span style="color: #00ffff;">uname -a</span>
Linux tuxedo 5.10.0-16-amd64 #1 SMP Debian 5.10.127-1 (2022-06-30) x86_64 GNU/Linux

<span style="color: #00ffff;">lsusb</span>
Bus 003 Device 005: ID 12d1:15bb Huawei Technologies Co., Ltd. ME936 LTE/HSDPA+ 4G modem

# sample output

=== show modem status:
           |                model: ME936
           |         primary port: ttyUSB0
           |                state: connected
           |          power state: on
           |       signal quality: 22% (recent)

=== show routing table:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         37.80.230.59    0.0.0.0         UG    700    0        0 wwx022c80139263
37.0.0.0        0.0.0.0         255.0.0.0       U     700    0        0 wwx022c80139263
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wwx022c80139263

=== show arp table:
? (37.80.230.59) at  on wwx022c80139263

=== ping a host 3x times:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: wwx022c80139263: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 02:2c:80:13:92:63 brd ff:ff:ff:ff:ff:ff
    inet 37.80.230.58/8 brd 37.255.255.255 scope global noprefixroute wwx022c80139263
       valid_lft forever preferred_lft forever
3: wlp52s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 36:20:ec:72:3f:66 brd ff:ff:ff:ff:ff:ff permaddr 70:9c:d1:62:10:9c
5: enxa0cec851d79b: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether a0:ce:c8:51:d7:9b brd ff:ff:ff:ff:ff:ff
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
From 37.80.230.58 icmp_seq=1 Destination Host Unreachable
From 37.80.230.58 icmp_seq=2 Destination Host Unreachable
From 37.80.230.58 icmp_seq=3 Destination Host Unreachable

--- 1.1.1.1 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2046ms

#linux #gnu #gnulinux #opensource #administration #sysops #lte #modem #debugging #debug #bash

Originally posted at: https://dwaves.de/2022/07/12/gnu-linux-bash-the-ultimate-lte-modem-debugging-one-liner/

canoodle@nerdpol.ch

GNU Linux bash - notebook laptop test battery runtime script

how long (many hours) will this notebook-laptop battery last? some sensors/softwares report/calculate things like this... 5days on one charge is a very very optimistic estimate for most intel or amd based notebooks (even for RISC/ARM based notebooks-laptops that would be AWESOME, most[...]

#linux #gnu #gnulinux #opensource #administration #sysops #hardware #battery #test #script #bash #scripting #scripts

Originally posted at: https://dwaves.de/2022/07/08/gnu-linux-bash-notebook-laptop-test-battery-runtime-script/

canoodle@nerdpol.ch

gnu linux - bash console - animated ascii art - sl steam locomotive

just one of those programs, that make users smile 🙂

written in C 🙂

compile it from src

or go

<span style="color: #00ffff;">lsb_release -d</span>; # tested on
Description: Debian GNU/Linux 11 (bullseye)
<span style="color: #00ffff;">su - root</span>
<span style="color: #00ffff;">apt update</span>
<span style="color: #00ffff;">apt install sl</span>

#linux #gnu #gnulinux #opensource #administration #sysops #ascii #art #bash #locomotive

Originally posted at: https://dwaves.de/2022/06/28/gnu-linux-bash-console-animated-ascii-art-sl-steam-locomotive/

canoodle@nerdpol.ch

GNU Linux bash - setup and modify basics script

it is part of a scripts package straight after (Debian based) GNU Linux OS setup, usually doing those modifications: vim /scripts/install_basics.sh #!/bin/bash echo "=== install the basic tools needed to work with a system ===" echo "== disable cdrom apt repo =="[...]

#linux #gnu #gnulinux #opensource #administration #sysops #bash #gnu-linux #setup

Originally posted at: https://dwaves.de/2022/03/03/gnu-linux-bash-setup-and-modify-basics-script/