Added copy script to share environment
This commit is contained in:
24
copy_to_servers.sh
Executable file
24
copy_to_servers.sh
Executable 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
|
||||
Reference in New Issue
Block a user