From 8e09af10a4d3f0d942e51509c0975e7954355d3c Mon Sep 17 00:00:00 2001 From: xbl Date: Mon, 31 Aug 2026 22:14:51 +0200 Subject: [PATCH] modified: beem.bash new file: raiden-cold.sh new file: raiden-hot.sh new file: raiden-synk.sh modified: xsetroot --- beem.bash | 4 +- raiden-cold.sh | 121 +++++++++++++++++++++++++++++++++++++++++++++++++ raiden-hot.sh | 121 +++++++++++++++++++++++++++++++++++++++++++++++++ raiden-synk.sh | 48 ++++++++++++++++++++ xsetroot | 41 +++++++++++++---- 5 files changed, 324 insertions(+), 11 deletions(-) create mode 100755 raiden-cold.sh create mode 100755 raiden-hot.sh create mode 100755 raiden-synk.sh diff --git a/beem.bash b/beem.bash index ab61304..464c1e6 100755 --- a/beem.bash +++ b/beem.bash @@ -6,7 +6,6 @@ then xrandr \ --output HDMI-0 \ --mode 1280x800 \ - --scale 1 \ --rate 60 \ --pos 2160x0 \ --rotate normal \ @@ -56,7 +55,6 @@ then --off \ --output HDMI-0 \ --mode 1280x800 \ - --scale 1 \ --rate 60 \ --pos 2160x0 \ --rotate normal @@ -94,7 +92,7 @@ then xrandr \ --output HDMI-0 \ --mode 1280x800 \ - --scale 1.75\ + --scale 2\ --rate 60 \ --pos 2160x2240 \ --output HDMI-1 \ diff --git a/raiden-cold.sh b/raiden-cold.sh new file mode 100755 index 0000000..64d7f37 --- /dev/null +++ b/raiden-cold.sh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash +# raiden-cold.sh — open/close/status encrypted container +# Usage: raiden-cold.sh open | close | status + +IMG="/mnt/sektor/.local/raiden-cold.img" +MAP_NAME="raiden-cold" +MOUNT_POINT="/mnt/raiden/cold" + +# ── colors ────────────────────────────────────────────────────────────────── +RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' +info() { echo -e "${GREEN}[✔]${NC} $*"; } +warn() { echo -e "${YELLOW}[!]${NC} $*"; } +error() { echo -e "${RED}[✘]${NC} $*"; exit 1; } + +# ── helpers ─────────────────────────────────────────────────────────────────── +is_mounted() { mountpoint -q "$MOUNT_POINT"; } +is_mapped() { [ -e "/dev/mapper/$MAP_NAME" ]; } +find_loop() { losetup -j "$IMG" | awk -F: '{print $1}'; } # find loop already attached to image + +# ── open ────────────────────────────────────────────────────────────────────── +cmd_open() { + [ -f "$IMG" ] || error "Image not found: $IMG — is the NFS share mounted?" + + # Auto-pick a free loop device, reuse if image already attached + local LOOP + LOOP=$(find_loop) + if [ -n "$LOOP" ]; then + warn "Image already attached as $LOOP — reusing" + else + info "Attaching loop device..." + LOOP=$(losetup -fP --show "$IMG") || error "losetup failed" + info "Loop device attached: $LOOP" + fi + + if is_mapped; then + warn "/dev/mapper/$MAP_NAME already exists — skipping cryptsetup" + else + info "Opening LUKS container (enter passphrase)..." + cryptsetup open "$LOOP" "$MAP_NAME" || error "cryptsetup open failed" + info "LUKS container open: /dev/mapper/$MAP_NAME" + fi + + if is_mounted; then + warn "$MOUNT_POINT already mounted — skipping" + else + mkdir -p "$MOUNT_POINT" + mount "/dev/mapper/$MAP_NAME" "$MOUNT_POINT" || error "mount failed" + info "Mounted at $MOUNT_POINT" + fi + + echo "" + df -h "$MOUNT_POINT" +} + +# ── close ───────────────────────────────────────────────────────────────────── +cmd_close() { + # Resolve loop device before closing LUKS (after close it's gone) + local LOOP + LOOP=$(cryptsetup status "$MAP_NAME" 2>/dev/null | awk '/device:/{print $2}') + + if is_mounted; then + info "Unmounting $MOUNT_POINT..." + umount "$MOUNT_POINT" || error "umount failed — files still open?" + info "Unmounted" + else + warn "$MOUNT_POINT not mounted — skipping" + fi + + if is_mapped; then + info "Closing LUKS container..." + cryptsetup close "$MAP_NAME" || error "cryptsetup close failed" + info "LUKS container closed" + else + warn "/dev/mapper/$MAP_NAME not found — skipping" + fi + + if [ -n "$LOOP" ] && losetup "$LOOP" &>/dev/null; then + info "Detaching loop device $LOOP..." + losetup -d "$LOOP" || error "losetup detach failed" + info "Loop device detached" + else + warn "No loop device to detach — skipping" + fi + + info "Vault closed." +} + +# ── status ──────────────────────────────────────────────────────────────────── +cmd_status() { + local LOOP + LOOP=$(find_loop) + + echo -e "\n Image : $IMG" + [ -f "$IMG" ] && echo -e " NFS share : ${GREEN}reachable${NC}" \ + || echo -e " NFS share : ${RED}not reachable${NC}" + + [ -n "$LOOP" ] && echo -e " Loop dev : ${GREEN}$LOOP${NC}" \ + || echo -e " Loop dev : ${RED}not attached${NC}" + + is_mapped && echo -e " LUKS : ${GREEN}open${NC}" \ + || echo -e " LUKS : ${RED}closed${NC}" + + is_mounted && echo -e " Mounted : ${GREEN}$MOUNT_POINT${NC}" \ + || echo -e " Mounted : ${RED}no${NC}" + + is_mounted && { echo ""; df -h "$MOUNT_POINT"; } + echo "" +} + +# ── main ────────────────────────────────────────────────────────────────────── +[ "$EUID" -eq 0 ] || error "Run as root" + +case "$1" in + open) cmd_open ;; + close) cmd_close ;; + status) cmd_status ;; + *) + echo "Usage: $(basename "$0") open | close | status" + exit 1 + ;; +esac diff --git a/raiden-hot.sh b/raiden-hot.sh new file mode 100755 index 0000000..a094a9d --- /dev/null +++ b/raiden-hot.sh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash +# raiden-hot.sh — open/close/status encrypted container +# Usage: raiden-hot.sh open | close | status + +IMG="/mnt/sektor/.local/raiden-hot.img" +MAP_NAME="raiden-hot" +MOUNT_POINT="/mnt/raiden/hot" + +# ── colors ────────────────────────────────────────────────────────────────── +RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' +info() { echo -e "${GREEN}[✔]${NC} $*"; } +warn() { echo -e "${YELLOW}[!]${NC} $*"; } +error() { echo -e "${RED}[✘]${NC} $*"; exit 1; } + +# ── helpers ─────────────────────────────────────────────────────────────────── +is_mounted() { mountpoint -q "$MOUNT_POINT"; } +is_mapped() { [ -e "/dev/mapper/$MAP_NAME" ]; } +find_loop() { losetup -j "$IMG" | awk -F: '{print $1}'; } # find loop already attached to image + +# ── open ────────────────────────────────────────────────────────────────────── +cmd_open() { + [ -f "$IMG" ] || error "Image not found: $IMG — is the NFS share mounted?" + + # Auto-pick a free loop device, reuse if image already attached + local LOOP + LOOP=$(find_loop) + if [ -n "$LOOP" ]; then + warn "Image already attached as $LOOP — reusing" + else + info "Attaching loop device..." + LOOP=$(losetup -fP --show "$IMG") || error "losetup failed" + info "Loop device attached: $LOOP" + fi + + if is_mapped; then + warn "/dev/mapper/$MAP_NAME already exists — skipping cryptsetup" + else + info "Opening LUKS container (enter passphrase)..." + cryptsetup open "$LOOP" "$MAP_NAME" || error "cryptsetup open failed" + info "LUKS container open: /dev/mapper/$MAP_NAME" + fi + + if is_mounted; then + warn "$MOUNT_POINT already mounted — skipping" + else + mkdir -p "$MOUNT_POINT" + mount "/dev/mapper/$MAP_NAME" "$MOUNT_POINT" || error "mount failed" + info "Mounted at $MOUNT_POINT" + fi + + echo "" + df -h "$MOUNT_POINT" +} + +# ── close ───────────────────────────────────────────────────────────────────── +cmd_close() { + # Resolve loop device before closing LUKS (after close it's gone) + local LOOP + LOOP=$(cryptsetup status "$MAP_NAME" 2>/dev/null | awk '/device:/{print $2}') + + if is_mounted; then + info "Unmounting $MOUNT_POINT..." + umount "$MOUNT_POINT" || error "umount failed — files still open?" + info "Unmounted" + else + warn "$MOUNT_POINT not mounted — skipping" + fi + + if is_mapped; then + info "Closing LUKS container..." + cryptsetup close "$MAP_NAME" || error "cryptsetup close failed" + info "LUKS container closed" + else + warn "/dev/mapper/$MAP_NAME not found — skipping" + fi + + if [ -n "$LOOP" ] && losetup "$LOOP" &>/dev/null; then + info "Detaching loop device $LOOP..." + losetup -d "$LOOP" || error "losetup detach failed" + info "Loop device detached" + else + warn "No loop device to detach — skipping" + fi + + info "Vault closed." +} + +# ── status ──────────────────────────────────────────────────────────────────── +cmd_status() { + local LOOP + LOOP=$(find_loop) + + echo -e "\n Image : $IMG" + [ -f "$IMG" ] && echo -e " NFS share : ${GREEN}reachable${NC}" \ + || echo -e " NFS share : ${RED}not reachable${NC}" + + [ -n "$LOOP" ] && echo -e " Loop dev : ${GREEN}$LOOP${NC}" \ + || echo -e " Loop dev : ${RED}not attached${NC}" + + is_mapped && echo -e " LUKS : ${GREEN}open${NC}" \ + || echo -e " LUKS : ${RED}closed${NC}" + + is_mounted && echo -e " Mounted : ${GREEN}$MOUNT_POINT${NC}" \ + || echo -e " Mounted : ${RED}no${NC}" + + is_mounted && { echo ""; df -h "$MOUNT_POINT"; } + echo "" +} + +# ── main ────────────────────────────────────────────────────────────────────── +[ "$EUID" -eq 0 ] || error "Run as root" + +case "$1" in + open) cmd_open ;; + close) cmd_close ;; + status) cmd_status ;; + *) + echo "Usage: $(basename "$0") open | close | status" + exit 1 + ;; +esac diff --git a/raiden-synk.sh b/raiden-synk.sh new file mode 100755 index 0000000..5c422b3 --- /dev/null +++ b/raiden-synk.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# raiden-synk.sh — rsynk /mnt/raiden/hot to /mnt/raiden/cold +# Usage: raiden-synk.sh [--dry-run] + +SRC="/mnt/raiden/hot/" +DST="/mnt/raiden/cold/" +LOG="/mnt/raiden/cold/raiden-synk.log" + +# ── colours ─────────────────────────────────────────────────────────────────── +RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m' +info() { echo -e "${GREEN}[✔]${NC} $*" | tee -a "$LOG"; } +warn() { echo -e "${YELLOW}[!]${NC} $*" | tee -a "$LOG"; } +error() { echo -e "${RED}[✘]${NC} $*" | tee -a "$LOG"; exit 1; } + +# ── preflight checks ────────────────────────────────────────────────────────── +echo "" | tee -a "$LOG" +info "$(date '+%Y-%m-%d %H:%M:%S') — raiden-synk starting" + +# Vaults mounted? +mountpoint -q "$SRC" || error "Hot vault not mounted at $SRC — open it first" +mountpoint -q "$DST" || error "Cold vault not mounted at $DST — open it first" + +info "Source : $SRC" +info "Dest : $DST" + +# ── dry run? ────────────────────────────────────────────────────────────────── +DRYRUN="" +if [ "$1" = "--dry-run" ]; then + DRYRUN="--dry-run" + warn "Dry run mode — no files will be written" +fi + +# ── rsync ───────────────────────────────────────────────────────────────────── +rsync -avh --progress --delete --exclude=Thumbs.db:encryptable --exclude=Thumbs.db --exclude=debug.log \ + $DRYRUN \ + "$SRC" "$DST" \ + | tee -a "$LOG" + +STATUS=${PIPESTATUS[0]} + +# ── result ──────────────────────────────────────────────────────────────────── +if [ "$STATUS" -eq 0 ]; then + info "Sync complete." +elif [ "$STATUS" -eq 24 ]; then + warn "Sync complete with warnings (some files vanished during transfer — usually harmless)." +else + error "rsync failed with exit code $STATUS" +fi diff --git a/xsetroot b/xsetroot index df79caf..99878f2 100755 --- a/xsetroot +++ b/xsetroot @@ -1,17 +1,42 @@ #!/bin/bash # dwm status bar - ipl=$(ip addr show dev enp7s0 | grep -F 'inet ' | cut -f1 -d/ | awk '{print $2}') - ipw=$(curl -s ipinfo.io/ip) +ipw=$(curl -s ipinfo.io/ip) +moon=$(/home/xbl/scripts/moon.bash) + +bat="" +vol="" +cpu="" +dte="" +tmp="" +dsk="" +ram="" +gpu="" +vol="" + +counter=0 + while true do + if (( counter % 50 == 0 )); then + cpu=$(mpstat | grep -F all | awk '{print $13}') + tmp=$(sensors | grep Tctl | awk '{print $2}' | sed 's/+//') + dsk=$(df -h / | awk '{print $4}' | grep -E '[0-9]') + ram=$(free -h | grep -F Mem: | awk '{print $7}') + gpu=$(nvidia-smi | head -n 10 | tail -n 1 | grep W | awk '{print $5}') + ipl=$(ip addr show dev enp7s0 | grep -F 'inet ' | cut -f1 -d/ | awk '{print $2}') + fi + + if (( counter % 600 == 0 )); then + bat=$(gwolves-battery | awk '{print $3}' | sed ':a;N;$!ba;s/\n/ /') + fi + + dte=$(LC_TIME=wae_CH.UTF-8 date '+%A, %d %B %Y - %H:%M:%S %Z ') vol=$(volctl) - cpu=$(mpstat | grep -F all | awk '{print $13}') - tmp=$(sensors | grep Tctl | awk '{print $2}' | sed 's/+//') - dsk=$(df -h / | awk '{print $4}' | grep -E '[0-9]') - ram=$(free -h | grep -F Mem: | awk '{print $7}') - gpu=$(nvidia-smi | head -n 10 | tail -n 1 | grep W | awk '{print $5}') - xsetroot -name " 📢 $vol | 🔌 $gpu | 🛠 $cpu | 🌡$tmp | 🧠 $ram | 💾 $dsk | 🏡 $ipl | 🌎 $ipw | 🗓 $(date '+%A, %d %B %Y - %H:%M:%S %Z ' ) " + + xsetroot -name " 🐭 $bat | 📢 $vol | 🔌 $gpu | 🛠 $cpu | 🌡$tmp | 🧠 $ram | 💾 $dsk | 🏡 $ipl | 🌎 $ipw | $moon $dte " + + counter=$((counter + 1)) sleep 0.1 done # EOF