From 22ec9d3c31b0c41f935b0d5ccfd19cf993b172f4 Mon Sep 17 00:00:00 2001 From: davalanche Date: Sat, 30 Nov 2024 01:32:05 -0600 Subject: [PATCH] Additional changes based on the code review --- ct/mylar3.sh | 15 ++++++++++++--- install/mylar3-install.sh | 20 ++++++++++---------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ct/mylar3.sh b/ct/mylar3.sh index 0d2e4833..82b66663 100644 --- a/ct/mylar3.sh +++ b/ct/mylar3.sh @@ -1,12 +1,11 @@ #!/usr/bin/env bash - +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) # Copyright (c) 2021-2024 community-scripts ORG # Author: davalanche # License: MIT # https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://github.com/mylar3/mylar3 -source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) function header_info { clear cat <<"EOF" @@ -57,7 +56,17 @@ function default_settings() { function update_script() { header_info if [[ ! -d /opt/mylar3 ]]; then msg_error "No ${APP} Installation Found!"; exit; fi -msg_error "${APP} should be updated via the user interface." +RELEASE=$(curl -s 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/.* + wget -qO- https://github.com/mylar3/mylar3/archive/refs/tags/${RELEASE}.tar.gz | tar -xz --strip-components=1 -C /opt/mylar3 + 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 } diff --git a/install/mylar3-install.sh b/install/mylar3-install.sh index 8352127e..eebb3b52 100644 --- a/install/mylar3-install.sh +++ b/install/mylar3-install.sh @@ -19,20 +19,26 @@ $STD apt-get install -y \ curl \ sudo \ mc \ - git \ - python3-pip + jq echo "deb http://deb.debian.org/debian bookworm non-free non-free-firmware" > /etc/apt/sources.list.d/non-free.list $STD apt-get update $STD apt-get install -y unrar rm /etc/apt/sources.list.d/non-free.list msg_ok "Installed Dependencies" +msg_info "Updating Python3" +$STD apt-get install -y python3-pip +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED +$STD pip install -U --no-cache-dir pip +msg_ok "Updated Python3" + msg_info "Installing ${APPLICATION}" mkdir -p /opt/mylar3 mkdir -p /opt/mylar3-data -$STD git clone -b master https://github.com/mylar3/mylar3.git /opt/mylar3 -$STD pip install -U --no-cache-dir pip +RELEASE=$(curl -s https://api.github.com/repos/mylar3/mylar3/releases/latest | jq -r '.tag_name') +wget -qO- 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 msg_ok "Installed ${APPLICATION}" msg_info "Creating Service" @@ -53,12 +59,6 @@ EOF systemctl enable -q --now mylar3.service msg_ok "Created Service" -msg_info "Updating ${APPLICATION} configuration" -# version detection and updates through the user interface do not currently work unless "check_github_on_startup = True" -sed -i -e 's/check_github_on_startup = False/check_github_on_startup = True/' -e 's/check_github = False/check_github = True/' /opt/mylar3-data/config.ini -systemctl restart mylar3 -msg_ok "${APPLICATION} configuration updated" - motd_ssh customize