2019-06-27 14:37:42 -04:00
|
|
|
#!/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
|
|
|
|
|
2021-10-11 16:41:00 -04:00
|
|
|
KEEP_ARTIFACTS=""
|
|
|
|
if [[ -n ${1} ]]; then
|
|
|
|
for arg in ${@}; do
|
|
|
|
case ${arg} in
|
|
|
|
-k|--keep)
|
|
|
|
KEEP_ARTIFACTS="y"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2021-10-07 11:51:05 -04:00
|
|
|
echo -n "> Linting code for errors... "
|
|
|
|
./lint || exit
|
|
|
|
|
2019-06-27 14:37:42 -04:00
|
|
|
HOSTS=( ${@} )
|
2020-08-26 11:04:58 -04:00
|
|
|
echo "> Deploying to host(s): ${HOSTS[@]}"
|
2019-06-27 14:37:42 -04:00
|
|
|
|
|
|
|
# Build the packages
|
2020-08-26 11:04:58 -04:00
|
|
|
echo -n "Building packages... "
|
|
|
|
version="$( ./build-unstable-deb.sh 2>/dev/null )"
|
|
|
|
echo "done. Package version ${version}."
|
2019-06-27 14:37:42 -04:00
|
|
|
|
|
|
|
# Install the client(s) locally
|
2020-08-26 11:04:58 -04:00
|
|
|
echo -n "Installing client packages locally... "
|
|
|
|
$SUDO dpkg -i ../pvc-client*_${version}*.deb &>/dev/null
|
|
|
|
echo "done".
|
2019-06-27 14:37:42 -04:00
|
|
|
|
|
|
|
for HOST in ${HOSTS[@]}; do
|
2020-08-26 11:04:58 -04:00
|
|
|
echo "> Deploying packages to host ${HOST}"
|
|
|
|
echo -n "Copying packages... "
|
|
|
|
ssh $HOST $SUDO rm -rf /tmp/pvc &>/dev/null
|
|
|
|
ssh $HOST mkdir /tmp/pvc &>/dev/null
|
|
|
|
scp ../pvc-*_${version}*.deb $HOST:/tmp/pvc/ &>/dev/null
|
|
|
|
echo "done."
|
|
|
|
echo -n "Installing packages... "
|
|
|
|
ssh $HOST $SUDO dpkg -i /tmp/pvc/{pvc-client-cli,pvc-daemon-common,pvc-daemon-api,pvc-daemon-node}*.deb &>/dev/null
|
|
|
|
ssh $HOST rm -rf /tmp/pvc &>/dev/null
|
|
|
|
echo "done."
|
|
|
|
echo -n "Restarting PVC daemons... "
|
|
|
|
ssh $HOST $SUDO systemctl restart pvcapid &>/dev/null
|
|
|
|
ssh $HOST $SUDO systemctl restart pvcapid-worker &>/dev/null
|
|
|
|
ssh $HOST $SUDO systemctl restart pvcnoded &>/dev/null
|
|
|
|
echo "done."
|
2021-09-12 19:50:58 -04:00
|
|
|
echo -n "Waiting 30s for host to stabilize... "
|
|
|
|
sleep 30
|
2020-08-26 11:04:58 -04:00
|
|
|
echo "done."
|
2019-06-27 14:37:42 -04:00
|
|
|
done
|
2021-10-11 16:41:00 -04:00
|
|
|
if [[ -z ${KEEP_ARTIFACTS} ]]; then
|
|
|
|
rm ../pvc*_${version}*
|
|
|
|
fi
|