cloud-init/tools/read-version
Scott Moser 09285a4f6f tools: fix [some] shell quoting problems
There were problems with these tools if the path had a space.  This should
make these tools safe.  There are others that still have problems.
2013-04-09 17:57:41 -04:00

32 lines
659 B
Bash
Executable File

#!/bin/sh
set -e
find_root() {
local topd
if [ -z "${CLOUD_INIT_TOP_D}" ]; then
topd=$(cd "$(dirname "${0}")" && cd .. && pwd)
else
topd=$(cd "${CLOUD_INIT_TOP_D}" && pwd)
fi
[ $? -eq 0 -a -f "${topd}/setup.py" ] || return
ROOT_DIR="$topd"
}
if ! find_root; then
echo "Unable to locate 'setup.py' file that should" \
"exist in the cloud-init root directory." 1>&2
exit 1;
fi
CHNG_LOG="$ROOT_DIR/ChangeLog"
if [ ! -e "$CHNG_LOG" ]
then
echo "Unable to find 'ChangeLog' file located at $CHNG_LOG"
exit 1
fi
VERSION=$(grep -P "\d+.\d+.\d+:" "$CHNG_LOG" | cut -f1 -d ":" | head -n 1)
echo "$VERSION"