Files
screendump/screendump/layout/DEBIAN/postinst

40 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# Setup passwordless SSH for root to localhost (required for screendumpd performance)
SSH_DIR="/var/jb/var/root/.ssh"
KEY_FILE="$SSH_DIR/id_ed25519"
AUTH_KEYS="$SSH_DIR/authorized_keys"
# Create .ssh directory if it doesn't exist
if [ ! -d "$SSH_DIR" ]; then
mkdir -p "$SSH_DIR"
chmod 700 "$SSH_DIR"
fi
# Generate ed25519 key if it doesn't exist
if [ ! -f "$KEY_FILE" ]; then
ssh-keygen -t ed25519 -N "" -f "$KEY_FILE" -q
chmod 600 "$KEY_FILE"
chmod 644 "${KEY_FILE}.pub"
fi
# Add public key to authorized_keys if not already present
if [ -f "${KEY_FILE}.pub" ]; then
PUB_KEY=$(cat "${KEY_FILE}.pub")
# Create authorized_keys if it doesn't exist
if [ ! -f "$AUTH_KEYS" ]; then
touch "$AUTH_KEYS"
chmod 600 "$AUTH_KEYS"
fi
# Check if key is already in authorized_keys
if ! grep -qF "$PUB_KEY" "$AUTH_KEYS" 2>/dev/null; then
echo "$PUB_KEY" >> "$AUTH_KEYS"
fi
fi
# Load the launch daemon
launchctl load /var/jb/Library/LaunchDaemons/com.mousen.screendumpd.plist 2> /dev/null
exit 0