diff --git a/copy_to_servers.ini b/copy_to_servers.ini new file mode 100644 index 0000000..d35e5e0 --- /dev/null +++ b/copy_to_servers.ini @@ -0,0 +1,3 @@ +#Place all the target servers in this file, one per line +#server1 +#server2 diff --git a/copy_to_servers.sh b/copy_to_servers.sh new file mode 100755 index 0000000..e403994 --- /dev/null +++ b/copy_to_servers.sh @@ -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