From e208b571b92c7f127ff00f2b255998c9a543cf2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Sun, 26 Oct 2025 12:18:38 +0100 Subject: [PATCH] Refactor: Mylar3 (#8642) * Refactor * Update mylar3.sh --- ct/mylar3.sh | 16 +++++----------- install/mylar3-install.sh | 22 ++++++++-------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/ct/mylar3.sh b/ct/mylar3.sh index 55983b62f8..f3036ee00e 100644 --- a/ct/mylar3.sh +++ b/ct/mylar3.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG -# Author: davalanche +# Author: davalanche | Co-Author: Slaviša Arežina (tremor021) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://github.com/mylar3/mylar3 @@ -25,16 +25,10 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - RELEASE=$(curl -fsSL https://api.github.com/repos/mylar3/mylar3/releases/latest | jq -r '.tag_name') - if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then - msg_info "Updating ${APP} to ${RELEASE}" - rm -rf /opt/mylar3/* /opt/mylar3/.* -curl -fsSL "https://github.com/mylar3/mylar3/archive/refs/tags/${RELEASE}.tar.gz" | tar -xz --strip-components=1 -C /opt/mylar3 + + if check_for_gh_release "mylar3" "mylar3/mylar3"; then + fetch_and_deploy_gh_release "mylar3" "mylar3/mylar3" "tarball" systemctl restart mylar3 - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Updated ${APP} to ${RELEASE}" - else - msg_ok "No update required. ${APP} is already at ${RELEASE}" fi exit } @@ -46,4 +40,4 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8090${CL}" \ No newline at end of file +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8090${CL}" diff --git a/install/mylar3-install.sh b/install/mylar3-install.sh index 66917f1d51..bcb866894b 100644 --- a/install/mylar3-install.sh +++ b/install/mylar3-install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Copyright (c) 2021-2025 community-scripts ORG -# Author: davalanche +# Author: davalanche | Co-Author: Slaviša Arežina (tremor021) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://github.com/mylar3/mylar3 @@ -14,7 +14,6 @@ network_check update_os msg_info "Installing Dependencies" -$STD apt install -y jq cat </etc/apt/sources.list.d/non-free.sources Types: deb URIs: http://deb.debian.org/debian @@ -23,22 +22,17 @@ Components: non-free non-free-firmware EOF $STD apt update $STD apt install -y unrar -rm /etc/apt/sources.list.d/non-free.sources msg_ok "Installed Dependencies" -msg_info "Setup Python3" -$STD apt install -y python3-pip -rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED -$STD pip install -U --no-cache-dir pip -msg_ok "Setup Python3" +PYTHON_VERSION="3.12" setup_uv +fetch_and_deploy_gh_release "mylar3" "mylar3/mylar3" "tarball" msg_info "Installing ${APPLICATION}" -mkdir -p /opt/mylar3 mkdir -p /opt/mylar3-data -RELEASE=$(curl -fsSL https://api.github.com/repos/mylar3/mylar3/releases/latest | jq -r '.tag_name') -curl -fsSL "https://github.com/mylar3/mylar3/archive/refs/tags/${RELEASE}.tar.gz" | tar -xz --strip-components=1 -C /opt/mylar3 -$STD pip install --no-cache-dir -r /opt/mylar3/requirements.txt -echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +$STD uv venv /opt/mylar3/.venv +$STD /opt/mylar3/.venv/bin/python -m ensurepip --upgrade +$STD /opt/mylar3/.venv/bin/python -m pip install --upgrade pip +$STD /opt/mylar3/.venv/bin/python -m pip install --no-cache-dir -r /opt/mylar3/requirements.txt msg_ok "Installed ${APPLICATION}" msg_info "Creating Service" @@ -48,7 +42,7 @@ Description=Mylar3 Service After=network-online.target [Service] -ExecStart=/usr/bin/python3 /opt/mylar3/Mylar.py --daemon --nolaunch --datadir=/opt/mylar3-data +ExecStart=/opt/mylar3/.venv/bin/python /opt/mylar3/Mylar.py --daemon --nolaunch --datadir=/opt/mylar3-data GuessMainPID=no Type=forking Restart=on-failure