diff --git a/ct/companion.sh b/ct/companion.sh index 39810015..f0c03115 100644 --- a/ct/companion.sh +++ b/ct/companion.sh @@ -1,19 +1,26 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2026 community-scripts ORG # Author: glabutis # License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE # Source: https://github.com/bitfocus/companion +# App Default Values APP="Companion" var_tags="${var_tags:-automation;media}" +# Tags for Proxmox VE (max 2, no spaces, semicolon-separated) var_cpu="${var_cpu:-2}" +# Number of cores (default: 2) var_ram="${var_ram:-512}" +# RAM in MB (default: 512) var_disk="${var_disk:-8}" +# Disk space in GB (default: 8) var_os="${var_os:-debian}" +# Default OS var_version="${var_version:-12}" +# Default OS version var_unprivileged="${var_unprivileged:-1}" -var_keyctl="${var_keyctl:-1}" +# 1 = unprivileged container, 0 = privileged header_info "$APP" variables @@ -25,35 +32,44 @@ function update_script() { check_container_storage check_container_resources - if [[ ! -d /opt/companion ]]; then + if [[ ! -f /opt/companion/companion_headless.sh ]]; then msg_error "No ${APP} Installation Found!" exit fi - CURRENT="" - [[ -f /opt/companion-config/version.txt ]] && CURRENT=$(cat /opt/companion-config/version.txt) - RELEASE_JSON=$(curl -fsSL "https://api.bitfocus.io/v1/product/companion/packages?limit=20") - LATEST=$(echo "$RELEASE_JSON" | grep -o '"version":"[^"]*","target":"linux-tgz"' | head -1 | awk -F'"' '{print $4}') + RELEASE=$(echo "$RELEASE_JSON" | grep -o '"version":"[^"]*","target":"linux-tgz"' | head -1 | awk -F'"' '{print $4}') - if [[ "$CURRENT" == "$LATEST" ]]; then - msg_ok "Already running Bitfocus Companion ${LATEST} — no update needed." + if [[ "${RELEASE}" == "$(cat /opt/companion_version.txt 2>/dev/null)" ]]; then + msg_ok "No update required. ${APP} is already at v${RELEASE}" exit fi ASSET_URL=$(echo "$RELEASE_JSON" | grep -o '"uri":"[^"]*linux-x64[^"]*"' | head -1 | awk -F'"' '{print $4}') - msg_info "Updating ${APP} to ${LATEST}" + msg_info "Stopping ${APP}" systemctl stop companion + msg_ok "Stopped ${APP}" + + msg_info "Updating ${APP} to v${RELEASE}" rm -rf /opt/companion mkdir -p /opt/companion curl -fsSL "$ASSET_URL" -o /tmp/companion.tar.gz tar -xzf /tmp/companion.tar.gz -C /opt/companion --strip-components=1 rm -f /tmp/companion.tar.gz chown -R companion:companion /opt/companion + msg_ok "Updated ${APP} to v${RELEASE}" + + msg_info "Starting ${APP}" systemctl start companion - echo "${LATEST}" >/opt/companion-config/version.txt - msg_ok "Updated ${APP} to ${LATEST}" + msg_ok "Started ${APP}" + + msg_info "Cleaning Up" + rm -f /tmp/companion.tar.gz + msg_ok "Cleanup Completed" + + echo "${RELEASE}" >/opt/companion_version.txt + msg_ok "Update Successful" exit } @@ -61,7 +77,7 @@ start build_container description -msg_ok "Completed Successfully!\n" +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}:8000${CL}"