pvc/build-and-deploy.sh

39 lines
986 B
Bash
Raw Permalink Normal View History

#!/bin/bash
# A useful script for testing out changes to PVC by building the debs and deploying them out to a
# set of hosts automatically, including restarting the daemon (with a pause between) on the remote
# side. Mostly just useful for quickly testing/debugging changes as Ansible should be used for
# production upgrades.
# Check if we're root, or not
if [[ $( id -u ) -eq 0 ]]; then
SUDO=""
else
SUDO="sudo"
fi
HOSTS=( ${@} )
echo "${HOSTS[@]}"
# Build the packages
2019-09-07 12:32:21 -04:00
$SUDO ./build-deb.sh
# Install the client(s) locally
$SUDO dpkg -i ../pvc-client*.deb
for HOST in ${HOSTS[@]}; do
2019-12-14 16:56:33 -05:00
echo "****"
echo "Deploying to host ${HOST}"
echo "****"
2020-01-06 16:52:25 -05:00
ssh $HOST $SUDO rm -rf /tmp/pvc
ssh $HOST mkdir /tmp/pvc
scp ../*.deb $HOST:/tmp/pvc/
ssh $HOST $SUDO dpkg -i /tmp/pvc/*.deb
ssh $HOST $SUDO systemctl restart pvcd
ssh $HOST rm -rf /tmp/pvc
2019-12-14 16:56:33 -05:00
echo "****"
2019-12-18 11:56:32 -05:00
echo "Waiting 10s for host ${HOST} to stabilize"
2019-12-14 16:56:33 -05:00
echo "****"
2019-12-18 11:56:32 -05:00
sleep 10
done