Posts

DMARC, SPF, DKIM for sendmail on linux

To create DMARC, SPF, and DKIM records for your domain, you'll need to configure the DNS TXT entries for each. Here's how to do it: 1. SPF Record The SPF record helps to identify which mail servers are allowed to send email on behalf of your domain. Step-by-Step: Login to your DNS provider's management panel. Add a new DNS TXT record with the following value: v=spf1 a mx ip4:< myserver.net > -all 2. DMARC Record DMARC tells mail servers how to handle emails that fail SPF or DKIM checks. Step-by-Step: Add a DNS TXT record with the following value: v=DMARC1; p=none; rua=mailto:postmaster@myserver.net; ruf=mailto:postmaster@myserver.net; sp=none; aspf=r; This record means that DMARC is set to "none" (no enforcement). You can change p=none to p=quarantine or p=reject once you are confident your setup is working. 3. DKIM If you haven't installed OpenDKIM, do so: sudo apt-get update sudo apt-get install opendkim opendkim-tools Next, generate your DKIM key p

Enable Anydesk on Linux

 By default, Anydesk doesn't work on Ubuntu as it uses a different display server than what is expected by Anydesk (it expects the traditional X11 rather than Wayland). Dump this into a file, say, "fix_anydesk.sh", and then run it with sudo bash fix_anydesk.sh The script: #!/bin/bash # Check if the user has root privileges if [[ $EUID -ne 0 ]]; then    echo "This script must be run as root"     exit 1 fi # Backup the GDM configuration file GDM_CONFIG="/etc/gdm3/custom.conf" if [[ -f "$GDM_CONFIG" ]]; then     cp "$GDM_CONFIG" "$GDM_CONFIG.bak"     echo "Backup of custom.conf created." else     echo "GDM configuration file not found."     exit 1 fi # Disable Wayland by uncommenting and setting the 'WaylandEnable' option to false sed -i 's/#WaylandEnable=false/WaylandEnable=false/' "$GDM_CONFIG" # Inform the user echo "Wayland has been disabled. The system will use X11 inste

folderizer

 This script moves large numbers of files into subfolders sorted alphabetically. #!/bin/bash # Create folders for letters and numbers for letter in {A..Z}; do   mkdir -p "$letter" done for num in {1..9}; do   mkdir -p "$num" done # Create a folder for punctuation-based files mkdir -p "M" # Function to handle files starting with a punctuation mark handle_punctuation() {   for file in *; do     if [[ -f $file ]]; then       first_char="${file:0:1}"       if [[ $first_char =~ [[:punct:]] ]]; then         new_name="_${file}"         mv "$file" "$new_name"         first_char="${new_name:0:1}"         if [[ $first_char =~ [[:digit:]] ]]; then           mv "$new_name" "$first_char/"         elif [[ $first_char =~ [A-Za-z] ]]; then           # Normalize to uppercase for letter folders           first_char=$(echo "$first_char" | tr '[:lower:]' '[:upper:]')           mv &

A script to turn unencrypted epub files into plain text, bash

 #!/bin/bash # Check if a directory is provided if [ "$#" -ne 1 ]; then     echo "Usage: $0 <path-to-directory>"     exit 1 fi DIRECTORY="$1" # Check if the provided argument is a directory if [ ! -d "$DIRECTORY" ]; then     echo "The specified path is not a directory."     exit 1 fi # Process each EPUB file in the directory find "$DIRECTORY" -type f -name "*.epub" | while IFS= read -r EPUB_FILE; do     # Extract the base name without the extension     BASE_NAME=$(basename "$EPUB_FILE" .epub)     TEXT_FILE="$DIRECTORY/${BASE_NAME}.txt"     echo "Processing $EPUB_FILE"          # Create a temporary directory to extract the EPUB file     TEMP_DIR=$(mktemp -d)     echo "Extracting EPUB file to $TEMP_DIR"          # Unzip the EPUB file into the temporary directory     unzip -q "$EPUB_FILE" -d "$TEMP_DIR"          # Find the content directory (OEBPS, EPUB,

apt produces errors relating to python

 If you get these errors: produces this error again: Fetched 1,363 kB in 9s (153 kB/s) (Reading database ... 195577 files and directories currently installed.) Preparing to unpack .../archives/apt_2.4.12_amd64.deb ... Unpacking apt (2.4.12) over (2.4.12) ... Setting up apt (2.4.12) ... Setting up python3 (3.10.6-1~22.04.1) ... running python rtupdate hooks for python3.10... Traceback (most recent call last): File "/usr/bin/py3clean", line 210, in <module> main() File "/usr/bin/py3clean", line 196, in main pfiles = set(dpf.from_package(options.package)) File "/usr/share/python3/debpython/files.py", line 55, in from_package raise Exception("cannot get content of %s" % package_name) Exception: cannot get content of gdebi-core error running python rtupdate hook gdebi-core Traceback (most recent call last): File "/usr/bin/py3clean", line 210, in <module> main()

Docker incantations

 I find docker a bit obscure so I will list a short list of commands here to jog my memory. Build the docker container: docker compose up  or docker-compose up See what docker containers are running to get their IDs docker ps -a Login to a container using bash: (while running): docker exec -it d762049858c7 bash See what the password/s are including for mysql for a docker container: docker inspect d762049858c7 | grep -i password Nuke the container to edit it to rebuild: docker compose down Copy a local file to a running container: docker cp /path/to/local/file d762049858c7:/path/inside/container/ See what is going on: docker logs d762049858c7 Get the container IP address: docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' d762049858c7

Convert MKV to MOV or MP4 to MOV

# MKV to MP4      ffmpeg -i movie-file.mkv  -codec copy movie-file.mp4 # MKV to MOV (compressed)      ffmpeg -i movie-file.mkv  -f mov movie-file.mov # MP4 to MOV (compressed)      ffmpeg -i movie-file.mp4  -f mov movie-file.mov # MKV to MOV (raw/uncompressed: warning huge file):      ffmpeg -i movie-file.mkv -c:v prores_ks -profile:v 3 -c:a pcm_s24le movie-file.mov