Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-12333 Make pmm-client tarball installation more user-friendly #2856

Merged
merged 5 commits into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -65,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 Client to ${PMM_DIR}"
fi

cd "${CURRENT_DIR}" || true
Loading