Added copy script to share environment

This commit is contained in:
Patrick Verschuer
2026-02-27 19:53:01 +01:00
parent 382f62d43e
commit 474cfd65b2
2 changed files with 27 additions and 0 deletions

24
copy_to_servers.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
WHEREAMI="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
#Get all the target servers
SERVERLIST=$(grep -v '#' "${WHEREAMI}/copy_to_servers.ini")
#Find some tmpfs
TMP=""
if [ -e /dev/shm/ ] && [ "$(findmnt -n -o FSTYPE --target /dev/shm)" == "tmpfs" ]; then
TMP="$(mktemp -d -p /dev/shm/)/fun_with_env"
else
TMP="$(mktemp -d)/fun_with_env"
fi
#Prepare the files to copy over
mkdir "${TMP}"
cd "${WHEREAMI}" \
&& git archive --format=tar HEAD | tar xf - -C "${TMP}"
#Copy it
for host in ${SERVERLIST}; do
rsync -az "${TMP}/" ${host}:~/.fun_with_env
done