Skip to content

Commit

Permalink
PMM-12333 Make pmm-client tarball installation more user-friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
surbhat1595 committed Feb 28, 2024
1 parent 2526284 commit af75a8f
Showing 1 changed file with 40 additions and 11 deletions.
51 changes: 40 additions & 11 deletions build/scripts/install_tarball
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,33 @@

set -eu

# Usage instruction for the install_tarball script
usage () {
cat <<EOF
Usage: $0 [OPTIONS]
The following options may be given :
-u Update PMM-Agent
-help) usage ;;
Example:
For help command - $0 -help
For PMM tarball installation - $0
To update the installed PMM tarball - $0 -u
EOF
exit 1
}

UPDATE=0
for arg in "$@"
do
case "$arg" in
"-u") UPDATE=1 ;;
"-help") usage ;;
*) echo "Invalid option:$arg"; usage;;
esac
done

CURRENT_DIR="$(pwd)"
PMM_VER=$(echo "$CURRENT_DIR" | cut -d'-' -f3)
WORKING_DIR="$(dirname "${0}")"
cd "${WORKING_DIR}" || exit 2

Expand All @@ -17,7 +43,15 @@ else
INSTALL_COMMAND="install -o ${PMM_USER} -g ${PMM_GROUP}"
fi

echo "Installing into ${PMM_DIR}..."
# Check if PMM_DIR has the right permission to install files into it
mkdir -p "${PMM_DIR}" || true
if [ -w ${PMM_DIR} ]; then
echo "Installing into ${PMM_DIR}...";
else
echo -e "${PMM_DIR} is not writable. \nPlease use a directory with the right permissions\n\n"
usage;
exit 1;
fi

${INSTALL_COMMAND} -m 0755 -d "${PMM_DIR}"
${INSTALL_COMMAND} -m 0755 -d "${PMM_DIR}"/bin
Expand Down Expand Up @@ -64,19 +98,14 @@ for FILE in example.prom queries-mysqld.yml example-queries-postgres.yml; do
done
done

update=0
while getopts :u flag
do
case "${flag}" in
u) update=1;;
*) echo "Invalid option: -$flag" ;;
esac
done

if [ "${update}" = "1" ]; then
if [ "${UPDATE}" = "1" ]; then
echo "Config file was not removed!"
else
${INSTALL_COMMAND} -m 0660 /dev/null "${PMM_DIR}"/config/pmm-agent.yaml
fi

if [ $? -eq 0 ]; then
echo "Successfully installed PMM ${PMM_VER} to ${PMM_DIR}"
fi

cd "${CURRENT_DIR}" || true

0 comments on commit af75a8f

Please sign in to comment.