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 29, 2024
1 parent 2526284 commit e5998c2
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
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)"
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 "${PMM_DIR} is not writable. \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 files to ${PMM_DIR}"
fi

cd "${CURRENT_DIR}" || true

0 comments on commit e5998c2

Please sign in to comment.