All checks were successful
continuous-integration/drone/push Build is passing
65 lines
1.4 KiB
Bash
Executable File
65 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
########################################################################
|
|
|
|
# hosts to push
|
|
hosts=(
|
|
'rsync.tier2.de-fra1.burble.dn42'
|
|
'rsync.tier2.ca-bhs2.burble.dn42'
|
|
)
|
|
|
|
dst="apps/nginx/burble.dn42"
|
|
|
|
########################################################################
|
|
|
|
# where am I ?
|
|
SCRIPTPATH="$(cd "$(dirname "$0")" ; pwd -P)"
|
|
pushd "$SCRIPTPATH"
|
|
|
|
function cleanup {
|
|
local tmp="${SCRIPTPATH}/.tmp"
|
|
if [ -d "$tmp" ]
|
|
then
|
|
rm -rf "$tmp" > /dev/null 2>&1
|
|
fi
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
export VAULT_ADDR='https://vault.burble.dn42'
|
|
if [ "$(id -un)" = 'drone' ]
|
|
then
|
|
export HOME=/drone
|
|
fi
|
|
|
|
########################################################################
|
|
# generate one time key for deployment access
|
|
|
|
echo "Generating temporary user key"
|
|
mkdir -m 0700 .tmp
|
|
|
|
key='.tmp/rsync_key'
|
|
ssh-keygen -t ed25519 -a 100 -N '' -f "$key"
|
|
|
|
vault write \
|
|
-field=signed_key \
|
|
burble.dn42/ssh/user/sign/rsync \
|
|
public_key="@${key}.pub" \
|
|
> "${key}-cert.pub"
|
|
# fixup perms
|
|
chmod 0600 .tmp/*
|
|
|
|
########################################################################
|
|
# push to hosts
|
|
|
|
for host in ${hosts[@]}
|
|
do
|
|
echo "Syncing host: $host"
|
|
rsync -avogp --delete -e "ssh -i '${key}'" \
|
|
--chown 81001:81001 --chmod=D2755,F644 \
|
|
site/public/ "root@${host}:${dst}/"
|
|
done
|
|
|
|
|
|
popd
|
|
########################################################################
|
|
# end of file
|