25 lines
628 B
Bash
Executable File
25 lines
628 B
Bash
Executable File
#!/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
|