#!/usr/bin/env bash # import-remnux-cheatsheets.sh # Wrapper to import a consolidated markdown cheatsheet (remnux-tldr-cheatsheet.md) # and generate missing cheat sheets (/opt/cheatsheets/personal/) and # tldr pages (/home/remnux/.local/share/tldr/pages/common/.md) inside the container. # # Usage (inside container): # import-remnux-cheatsheets.sh /data/remnux-tldr-cheatsheet.md # Or from host: # docker run --rm -v "$(pwd):/data" tabledevil/file-analysis:streamlined \ # bash -lc "/usr/local/bin/import-remnux-cheatsheets.sh /data/remnux-tldr-cheatsheet.md && fhelp examples" set -euo pipefail SCRIPT_DIR="/usr/local/bin" CONVERTER="$SCRIPT_DIR/convert-remnux-cheats.py" if [[ $# -lt 1 ]]; then echo "Usage: $0 [--dry-run]" >&2 exit 2 fi INPUT_MD="$1"; shift || true EXTRA_ARGS=("$@") if [[ ! -f "$INPUT_MD" ]]; then echo "Input file not found: $INPUT_MD" >&2 exit 2 fi # Ensure directories exist mkdir -p /opt/cheatsheets/personal mkdir -p /home/remnux/.local/share/tldr/pages/common # Run the converter python3 "$CONVERTER" --in "$INPUT_MD" \ --cheat-dir /opt/cheatsheets/personal \ --tldr-dir /home/remnux/.local/share/tldr/pages/common \ --only-missing "${EXTRA_ARGS[@]}" # Fix ownership for remnux user chown -R remnux:remnux /opt/cheatsheets /home/remnux/.local/share/tldr || true echo "✅ Import complete. Try: fhelp examples"