mirror of
https://github.com/TrezOne/docker-mods-uptime-kuma-timeout-fix.git
synced 2026-07-14 07:20:20 -04:00
add version and debug logging
This commit is contained in:
+36
-4
@@ -1,11 +1,28 @@
|
|||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
|
# Version 1
|
||||||
|
# 2024-03-26 - Initial Version
|
||||||
|
PKG_SCRIPT_VER="3.20240326"
|
||||||
|
|
||||||
|
write_mod_info() {
|
||||||
|
local MSG=$*
|
||||||
|
echo "[pkg-install-init] **** $MSG ****"
|
||||||
|
}
|
||||||
|
|
||||||
|
write_mod_debug() {
|
||||||
|
local MSG=$*
|
||||||
|
if [[ ${DOCKER_MODS_DEBUG,,} = "true" ]]; then echo "[pkg-install-init] (DEBUG) $MSG"; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
write_mod_debug "Package install script version ${MOD_SCRIPT_VER}"
|
||||||
|
|
||||||
if [[ -f "/mod-pip-packages-to-install.list" ]]; then
|
if [[ -f "/mod-pip-packages-to-install.list" ]]; then
|
||||||
IFS=' ' read -ra PIP_PACKAGES <<< "$(tr '\n' ' ' < /mod-pip-packages-to-install.list)"
|
IFS=' ' read -ra PIP_PACKAGES <<< "$(tr '\n' ' ' < /mod-pip-packages-to-install.list)"
|
||||||
if [[ ${#PIP_PACKAGES[@]} -ne 0 ]] && [[ ${PIP_PACKAGES[*]} != "" ]]; then
|
if [[ ${#PIP_PACKAGES[@]} -ne 0 ]] && [[ ${PIP_PACKAGES[*]} != "" ]]; then
|
||||||
if [[ ! -e /lsiopy/bin/python3 ]]; then
|
if [[ "$(command -v python3)" != "/lsiopy/bin/python3" ]]; then
|
||||||
CREATE_VENV="true"
|
CREATE_VENV="true"
|
||||||
|
write_mod_debug "Marking venv for creation and adding python os dependencies to install list."
|
||||||
if [[ -f /usr/bin/apt ]]; then
|
if [[ -f /usr/bin/apt ]]; then
|
||||||
echo "python3-venv" >> /mod-repo-packages-to-install.list
|
echo "python3-venv" >> /mod-repo-packages-to-install.list
|
||||||
elif [[ -f /sbin/apk ]]; then
|
elif [[ -f /sbin/apk ]]; then
|
||||||
@@ -15,14 +32,21 @@ if [[ -f "/mod-pip-packages-to-install.list" ]]; then
|
|||||||
elif [[ -f /usr/bin/dnf ]]; then
|
elif [[ -f /usr/bin/dnf ]]; then
|
||||||
echo "python3" >> /mod-repo-packages-to-install.list
|
echo "python3" >> /mod-repo-packages-to-install.list
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
write_mod_debug "Venv at /lsiopy is already active"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
write_mod_debug "No pip packages identified in install list, skipping."
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
write_mod_debug "No pip packages defined for install, skipping."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "/mod-repo-packages-to-install.list" ]]; then
|
if [[ -f "/mod-repo-packages-to-install.list" ]]; then
|
||||||
IFS=' ' read -ra REPO_PACKAGES <<< "$(tr '\n' ' ' < /mod-repo-packages-to-install.list)"
|
IFS=' ' read -ra REPO_PACKAGES <<< "$(tr '\n' ' ' < /mod-repo-packages-to-install.list)"
|
||||||
if [[ ${#REPO_PACKAGES[@]} -ne 0 ]] && [[ ${REPO_PACKAGES[*]} != "" ]]; then
|
if [[ ${#REPO_PACKAGES[@]} -ne 0 ]] && [[ ${REPO_PACKAGES[*]} != "" ]]; then
|
||||||
echo "[mod-init] **** Installing all mod packages ****"
|
write_mod_info "Installing all mod packages"
|
||||||
|
write_mod_debug "Defined packages: ${REPO_PACKAGES[@]}"
|
||||||
if [[ -f /usr/bin/apt ]]; then
|
if [[ -f /usr/bin/apt ]]; then
|
||||||
export DEBIAN_FRONTEND="noninteractive"
|
export DEBIAN_FRONTEND="noninteractive"
|
||||||
apt-get update
|
apt-get update
|
||||||
@@ -38,17 +62,22 @@ if [[ -f "/mod-repo-packages-to-install.list" ]]; then
|
|||||||
dnf install -y --setopt=install_weak_deps=False --best \
|
dnf install -y --setopt=install_weak_deps=False --best \
|
||||||
"${REPO_PACKAGES[@]}"
|
"${REPO_PACKAGES[@]}"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
write_mod_debug "No os packages identified in install list, skipping."
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
write_mod_debug "No os packages defined for install, skipping."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "/mod-pip-packages-to-install.list" ]]; then
|
if [[ -f "/mod-pip-packages-to-install.list" ]]; then
|
||||||
IFS=' ' read -ra PIP_PACKAGES <<< "$(tr '\n' ' ' < /mod-pip-packages-to-install.list)"
|
IFS=' ' read -ra PIP_PACKAGES <<< "$(tr '\n' ' ' < /mod-pip-packages-to-install.list)"
|
||||||
if [[ ${#PIP_PACKAGES[@]} -ne 0 ]] && [[ ${PIP_PACKAGES[*]} != "" ]]; then
|
if [[ ${#PIP_PACKAGES[@]} -ne 0 ]] && [[ ${PIP_PACKAGES[*]} != "" ]]; then
|
||||||
echo "[mod-init] **** Installing all pip packages ****"
|
write_mod_info "Installing all pip packages"
|
||||||
if [[ ${CREATE_VENV} == "true" ]]; then
|
if [[ ${CREATE_VENV} == "true" ]]; then
|
||||||
echo "**** Creating venv ****"
|
write_mod_info "Creating venv"
|
||||||
python3 -m venv /lsiopy
|
python3 -m venv /lsiopy
|
||||||
fi
|
fi
|
||||||
|
write_mod_debug "Updating/installing pip, wheel and setuptools."
|
||||||
python3 -m pip install -U pip wheel setuptools
|
python3 -m pip install -U pip wheel setuptools
|
||||||
PIP_ARGS=()
|
PIP_ARGS=()
|
||||||
if [[ -f /usr/bin/apt ]] && grep -q 'ID=ubuntu' /etc/os-release; then
|
if [[ -f /usr/bin/apt ]] && grep -q 'ID=ubuntu' /etc/os-release; then
|
||||||
@@ -57,12 +86,15 @@ if [[ -f "/mod-pip-packages-to-install.list" ]]; then
|
|||||||
ALPINE_VER=$(grep main /etc/apk/repositories | sed 's|.*alpine/v||' | sed 's|/main.*||')
|
ALPINE_VER=$(grep main /etc/apk/repositories | sed 's|.*alpine/v||' | sed 's|/main.*||')
|
||||||
PIP_ARGS+=("-f" "https://wheel-index.linuxserver.io/alpine-${ALPINE_VER}/")
|
PIP_ARGS+=("-f" "https://wheel-index.linuxserver.io/alpine-${ALPINE_VER}/")
|
||||||
fi
|
fi
|
||||||
|
write_mod_debug "Installing defined pip packages: ${PIP_PACKAGES[@]}"
|
||||||
|
write_mod_debug "Using pip args ${PIP_ARGS[@]}"
|
||||||
python3 -m pip install \
|
python3 -m pip install \
|
||||||
"${PIP_ARGS[@]}" \
|
"${PIP_ARGS[@]}" \
|
||||||
"${PIP_PACKAGES[@]}"
|
"${PIP_PACKAGES[@]}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
write_mod_debug "Deleting temporary install lists for os and pip packages."
|
||||||
rm -rf \
|
rm -rf \
|
||||||
/mod-repo-packages-to-install.list \
|
/mod-repo-packages-to-install.list \
|
||||||
/mod-pip-packages-to-install.list
|
/mod-pip-packages-to-install.list
|
||||||
|
|||||||
Reference in New Issue
Block a user