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 Mar 4, 2024
1 parent ab718dd commit 4add624
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions build/scripts/install_tarball
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

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
To install PMM tarball - $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)"
WORKING_DIR="$(dirname "${0}")"
cd "${WORKING_DIR}" || exit 2
Expand All @@ -17,7 +42,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 "Cannot write to ${PMM_DIR}. \nPlease make sure the user $(id -un) has permissions to write to this directory\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 +97,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 Client to ${PMM_DIR}"
fi

cd "${CURRENT_DIR}" || true

0 comments on commit 4add624

Please sign in to comment.