Files
cc/alpine/dpush
Oliver dc80dd9522 merge
2025-08-08 16:34:03 -03:00

29 lines
619 B
Bash

#!/bin/bash
set -euo pipefail
if [ $# -ne 2 ]; then
echo "Usage: $0 <local_file> <remote_absolute_path>"
exit 1
fi
LOCAL_FILE="$1"
REMOTE_PATH="$2"
hosts_file="/mnt/encrypted_volume/${HOSTS_FILE:-hosts.txt}"
if [ ! -f "$LOCAL_FILE" ]; then
echo "Error: Local file '$LOCAL_FILE' not found."
exit 1
fi
if [ ! -f "$hosts_file" ]; then
echo "Error: Hosts file '$hosts_file' not found."
exit 1
fi
# Push the file content using tee with doas
echo "Pushing $LOCAL_FILE to $REMOTE_PATH on all hosts in $hosts_file"
pssh -h "$hosts_file" -l "$USER" -i "doas tee \"$REMOTE_PATH\" > /dev/null" < "$LOCAL_FILE"