From 6d3532bc16ef15b1ca1d979f1e958c28d9625442 Mon Sep 17 00:00:00 2001 From: Robert Perce Date: Mon, 25 Aug 2025 15:13:10 -0500 Subject: [PATCH] docs: add recipes --- lxc-metrics.nix | 2 -- recipes/borg-auth.bash | 18 ++++++++++++++++++ recipes/minecraft-admin.md | 25 +++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100755 recipes/borg-auth.bash create mode 100644 recipes/minecraft-admin.md diff --git a/lxc-metrics.nix b/lxc-metrics.nix index f57e7fe..af0943a 100644 --- a/lxc-metrics.nix +++ b/lxc-metrics.nix @@ -1,6 +1,4 @@ { - config, - inputs, pkgs, lib, ... diff --git a/recipes/borg-auth.bash b/recipes/borg-auth.bash new file mode 100755 index 0000000..ea9dbd8 --- /dev/null +++ b/recipes/borg-auth.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +get_key() { + hostname=$1 + ip=$2 + ssh "admin@$ip" -- 'if [ ! -f /home/admin/.ssh/id_ed25519.pub ]; then ssh-keygen -t ed25519; fi' + pubkey=$(ssh "admin@$ip" cat '$HOME/.ssh/id*.pub') + echo 'command="mkdir -p /borg/'"$hostname"'; cd /borg/'"$hostname"'; borg serve --restrict-to-path /borg/'"$hostname"'", restrict '"$pubkey" +} + +put_key() { + hostname=$1 + ip=$2 + line=$(get_key "$hostname" "$ip") + ssh -t robert@xalicas "sudo -u backup mkdir -p ~backup/.ssh; echo '$line' | sudo -u backup tee -a ~backup/.ssh/authorized_keys" +} + +"$@" diff --git a/recipes/minecraft-admin.md b/recipes/minecraft-admin.md new file mode 100644 index 0000000..b3fa18a --- /dev/null +++ b/recipes/minecraft-admin.md @@ -0,0 +1,25 @@ +# Minecraft admin + +On the server (`./Taskfile ssh majcraft`), + +## run server commands + +``` +echo say hello > /run/minecraft/majcraft.stdin +``` + +## view server output + +``` +journalctl -xeau minecraft-server-majcraft +``` + +## shutdown server + +``` +echo stop > /run/minecraft/majcraft.stdin +``` +or +``` +sudo systemctl stop minecraft-server-majcraft +```