tools: improve deploy-openstack script

Check first parameter and check for a dirty git repo before deploying
This commit is contained in:
Diaa Sami 2021-09-21 21:34:55 +02:00 committed by Tom Gundersen
parent e92424b5e3
commit 4ea758a8bb

View file

@ -25,6 +25,20 @@ scriptdir=$(dirname "$0")
config=$1
userdata=$2
if [ ! -f "$config" ]; then
echo "first parameter should be a file"
exit 1
fi
if [ -d "$(dirname "$config")/../.git" ]; then
if [ "$(git status --porcelain -uno | wc -l)" -gt 0 ] || [ "$(git branch --show-current)" != "main" ]; then
read -p "Are you sure you want to deploy from git repo with non-main branch or dirty files ? " -n 1 -r
if [[ $REPLY =~ ^[Nn]$ ]]; then
exit 1
fi
fi
fi
# Verify that an openstackrc file has been sourced. This will fail when the
# variables do not exist.
printenv OS_PROJECT_NAME OS_USERNAME > /dev/null