Scripts: Update install-devops-tools.sh, add install-proxysql-admin.sh

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-11-04 08:57:28 +01:00
parent 06df64281d
commit 28ad040402
3 changed files with 149 additions and 28 deletions

View File

@@ -31,26 +31,24 @@ case "$(uname -m)" in
;;
esac
# Ensure installation runs non-interactively.
export DEBIAN_FRONTEND="noninteractive"
BIN_DIR="${BIN_DIR:-/usr/local/bin}"
TMPDIR="$(mktemp -d)"
trap 'rm -rf "${TMPDIR}"' EXIT
export PIPX_HOME="${PIPX_HOME:-/opt/pipx}"
export PIPX_BIN_DIR="${PIPX_BIN_DIR:-/usr/local/bin}"
$SUDO install -d -m 0755 "${PIPX_HOME}" "${PIPX_BIN_DIR}"
install_apt_packages() {
local packages=(
bash-completion
dnsutils
iperf3
jq
mariadb-client
mysql-shell
netcat-openbsd
nfs-common
percona-toolkit
pipx
python3-venv
socat
yq
)
@@ -197,26 +195,7 @@ install_kubectl_neat() {
$SUDO install -m 0755 "${TMPDIR}/kubectl-neat" "${BIN_DIR}/kubectl-neat"
}
install_proxysql_admin() {
if command -v pipx >/dev/null 2>&1; then
if ! pipx ensurepath --force >/dev/null 2>&1; then
echo "pipx ensurepath failed; continuing with existing PATH." >&2
fi
if ! pipx list 2>/dev/null | grep -q "proxysql-admin-tool"; then
if ! pipx install proxysql-admin-tool >/dev/null 2>&1; then
echo "pipx install proxysql-admin-tool from PyPI failed; trying GitHub source." >&2
if ! pipx install "git+https://github.com/sysown/proxysql-admin-tool.git@master" >/dev/null 2>&1; then
echo "pipx install proxysql-admin-tool failed; skipping proxysql-admin-tool installation." >&2
fi
fi
fi
else
echo "pipx not available; skipping proxysql-admin-tool installation." >&2
fi
}
install_apt_packages
install_kubectl
install_helm
install_rancher_cli
@@ -225,7 +204,6 @@ install_k9s
install_stern
install_longhornctl
install_kubectl_neat
install_proxysql_admin
cat <<'EOF'
@@ -238,7 +216,6 @@ DevOps tooling installation completed:
- stern
- longhornctl
- kubectl-neat
- proxysql-admin-tool (via pipx)
- Supporting utilities installed via apt
EOF

144
scripts/dist/install-proxysql-admin.sh vendored Executable file
View File

@@ -0,0 +1,144 @@
#!/usr/bin/env bash
set -euo pipefail
PROXYSQL_VERSION="3.0.1"
PROXYSQL_REVISION="1.1"
ARCH_RAW="$(uname -m)"
case "${ARCH_RAW}" in
x86_64|amd64)
DEB_DIR="x86_64"
DEB_ARCH="amd64"
RPM_ARCH="x86_64"
TAR_ARCH="x86_64"
;;
aarch64|arm64)
DEB_DIR="arm64"
DEB_ARCH="arm64"
RPM_ARCH="aarch64"
TAR_ARCH="aarch64"
;;
*)
echo "proxysql-admin tooling is only provided for x86_64/arm64; detected ${ARCH_RAW}." >&2
exit 1
;;
esac
if command -v proxysql-admin >/dev/null 2>&1; then
echo "proxysql-admin is already installed ("$(command -v proxysql-admin)")."
exit 0
fi
if [[ ! -r /etc/os-release ]]; then
echo "Cannot detect operating system (missing /etc/os-release)." >&2
exit 1
fi
. /etc/os-release
SUDO=${SUDO:-sudo}
TMPDIR=$(mktemp -d)
trap 'rm -rf "${TMPDIR}"' EXIT
# Ensure installation runs non-interactively.
if [[ "${ID_LIKE:-}" =~ (debian|ubuntu) ]] || [[ "${ID:-}" =~ (debian|ubuntu) ]]; then
export DEBIAN_FRONTEND="noninteractive"
fi
stop_disable_service() {
command -v systemctl >/dev/null 2>&1 || return
local svc
for svc in proxysql proxysql-initial; do
${SUDO} systemctl stop "${svc}.service" >/dev/null 2>&1 || true
${SUDO} systemctl disable "${svc}.service" --now >/dev/null 2>&1 || true
${SUDO} systemctl mask "${svc}.service" >/dev/null 2>&1 || true
done
}
install_from_deb() {
local codename pkg url deb_arch
codename=${VERSION_CODENAME:-}
codename=${codename,,}
if [[ ! ${codename} =~ ^[a-z]+$ ]]; then
codename=""
fi
if [[ ${codename} != "jammy" && ${codename} != "noble" ]]; then
codename="noble"
fi
case "${codename}" in
jammy|noble) ;; # supported
*) codename=noble ;;
esac
deb_arch=${DEB_ARCH}
pkg="proxysql3_${PROXYSQL_VERSION}-${PROXYSQL_REVISION}.${codename}_${deb_arch}.deb"
url="https://downloads.percona.com/downloads/proxysql3/proxysql3-${PROXYSQL_VERSION}/binary/debian/${codename}/${DEB_DIR}/${pkg}"
echo "Downloading ${pkg}..."
curl -fsSL "${url}" -o "${TMPDIR}/${pkg}"
echo "Installing ${pkg}..."
${SUDO} DEBIAN_FRONTEND=noninteractive apt-get update -y >/dev/null
( cd "${TMPDIR}" && ${SUDO} DEBIAN_FRONTEND=noninteractive apt-get install -y "./${pkg}" )
stop_disable_service
}
install_from_rpm() {
local major pkg url rpm_arch
major=${VERSION_ID%%.*}
[[ -z "${major}" ]] && major=${PROXYSQL_VERSION%%.*}
rpm_arch=${RPM_ARCH}
pkg="proxysql3-${PROXYSQL_VERSION}-${PROXYSQL_REVISION}.el${major}.${rpm_arch}.rpm"
url="https://downloads.percona.com/downloads/proxysql3/proxysql3-${PROXYSQL_VERSION}/binary/redhat/${major}/${rpm_arch}/${pkg}"
echo "Downloading ${pkg}..."
curl -fsSL "${url}" -o "${TMPDIR}/${pkg}"
echo "Installing ${pkg}..."
if command -v dnf >/dev/null 2>&1; then
${SUDO} dnf install -y "${TMPDIR}/${pkg}"
else
${SUDO} yum install -y "${TMPDIR}/${pkg}"
fi
stop_disable_service
}
install_from_tarball() {
local glibc ver tarball url target_dir arch
ver=$(ldd --version | head -n1 | awk '{print $NF}')
arch=${TAR_ARCH}
tarball="proxysql-${PROXYSQL_VERSION}-Linux-${arch}.glibc${ver}.tar.gz"
url="https://downloads.percona.com/downloads/proxysql3/proxysql3-${PROXYSQL_VERSION}/binary/tarball/${tarball}"
echo "Downloading ${tarball}..."
curl -fsSL "${url}" -o "${TMPDIR}/${tarball}" || {
echo "Falling back to glibc2.34 build." >&2
tarball="proxysql-${PROXYSQL_VERSION}-Linux-${arch}.glibc2.34.tar.gz"
url="https://downloads.percona.com/downloads/proxysql3/proxysql3-${PROXYSQL_VERSION}/binary/tarball/${tarball}"
curl -fsSL "${url}" -o "${TMPDIR}/${tarball}"
}
target_dir="/usr/local/proxysql-${PROXYSQL_VERSION}"
echo "Extracting ${tarball} to ${target_dir}..."
${SUDO} rm -rf "${target_dir}"
${SUDO} mkdir -p "${target_dir}"
${SUDO} tar -xzf "${TMPDIR}/${tarball}" -C "${target_dir}" --strip-components=1
for bin in proxysql-admin proxysql-admin-common percona-scheduler-admin; do
if [[ -f "${target_dir}/usr/bin/${bin}" ]]; then
${SUDO} install -m 0755 "${target_dir}/usr/bin/${bin}" "/usr/local/bin/${bin}"
fi
done
if [[ -f "${target_dir}/etc/proxysql-admin.cnf" ]]; then
${SUDO} install -d /usr/local/share/proxysql-admin
${SUDO} install -m 0644 "${target_dir}/etc/proxysql-admin.cnf" /usr/local/share/proxysql-admin/proxysql-admin.cnf.sample
fi
}
if [[ "${ID_LIKE:-}" =~ (debian|ubuntu) ]] || [[ "${ID:-}" =~ (debian|ubuntu) ]]; then
install_from_deb
elif [[ "${ID_LIKE:-}" =~ (rhel|centos|rocky|fedora) ]] || [[ "${ID:-}" =~ (rhel|centos|rocky|fedora) ]]; then
install_from_rpm
else
echo "Unknown distribution (${ID}); installing from generic tarball." >&2
install_from_tarball
fi
if ! command -v proxysql-admin >/dev/null 2>&1; then
echo "proxysql-admin installation did not place the binary on PATH." >&2
exit 1
fi
echo "proxysql-admin installed at $(command -v proxysql-admin)."

View File

@@ -21,7 +21,7 @@ if [ -n "$(command -v yum)" ]; then
yum update -y
yum clean all
elif [ -n "$(command -v apt-get)" ]; then
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_FRONTEND="noninteractive"
apt-get -y update
apt-get -o Dpkg::Options::="--force-confold" upgrade -q -y --force-yes
apt-get -y autoremove