mirror of
https://github.com/unraid/api.git
synced 2025-12-31 13:39:52 -06:00
fix: flash backup integration with Unraid Connect config (#1448)
read `username` from connect.json & drop minigraphConnected check --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1210592838407162 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved reliability of configuration file handling for backup and API features. * Resolved potential false negatives when checking connection status by updating connection verification logic. * **Chores** * Centralized configuration paths for easier future updates. * Minor formatting improvements for better readability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
# This file is /etc/rc.d/rc.flash_backup
|
||||
# use at queue "f" for flash backup
|
||||
scripts_dir="/usr/local/share/dynamix.unraid.net/scripts"
|
||||
# This loads the API_CONFIG_HOME variable
|
||||
# shellcheck source=../usr/local/share/dynamix.unraid.net/scripts/api_utils.sh
|
||||
source "$scripts_dir/api_utils.sh"
|
||||
|
||||
QUEUE=" -q f "
|
||||
TASKNAME="/etc/rc.d/rc.flash_backup watch"
|
||||
TASKACTION="/usr/local/emhttp/plugins/dynamix.my.servers/scripts/UpdateFlashBackup update"
|
||||
@@ -9,8 +13,8 @@ last=$(date +%s)
|
||||
# set GIT_OPTIONAL_LOCKS=0 globally to reduce/eliminate writes to /boot
|
||||
export GIT_OPTIONAL_LOCKS=0
|
||||
|
||||
FAST=1 # 1 second delay when waiting for git
|
||||
SLOW=10 # 10 second delay when waiting for git
|
||||
FAST=1 # 1 second delay when waiting for git
|
||||
SLOW=10 # 10 second delay when waiting for git
|
||||
THIRTYMINS=1800 # 30 minutes is 1800 seconds
|
||||
# wait for existing git commands to complete
|
||||
# $1 is the time in seconds to sleep when waiting. SLOW or FAST
|
||||
@@ -162,20 +166,22 @@ _enabled() {
|
||||
return 1
|
||||
}
|
||||
_connected() {
|
||||
CFG=/var/local/emhttp/myservers.cfg
|
||||
CFG=$API_CONFIG_HOME/connect.json
|
||||
[[ ! -f "${CFG}" ]] && return 1
|
||||
# shellcheck disable=SC1090
|
||||
source <(sed -nr '/\[remote\]/,/\[/{/username/p}' "${CFG}" 2>/dev/null)
|
||||
# ensure signed in
|
||||
|
||||
username=$(jq -r '.username // empty' "${CFG}" 2>/dev/null)
|
||||
if [ -z "${username}" ]; then
|
||||
return 1
|
||||
fi
|
||||
# the minigraph status is no longer synced to the connect config file
|
||||
# to avoid a false negative, we'll omit this check for now.
|
||||
#
|
||||
# shellcheck disable=SC1090
|
||||
source <(sed -nr '/\[connectionStatus\]/,/\[/{/minigraph/p}' "${CFG}" 2>/dev/null)
|
||||
# ensure connected
|
||||
if [[ -z "${minigraph}" || "${minigraph}" != "CONNECTED" ]]; then
|
||||
return 1
|
||||
fi
|
||||
# source <(sed -nr '/\[connectionStatus\]/,/\[/{/minigraph/p}' "${CFG}" 2>/dev/null)
|
||||
# # ensure connected
|
||||
# if [[ -z "${minigraph}" || "${minigraph}" != "CONNECTED" ]]; then
|
||||
# return 1
|
||||
# fi
|
||||
return 0
|
||||
}
|
||||
_haserror() {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
# Default paths
|
||||
CONFIG_FILE="/usr/local/share/dynamix.unraid.net/config/vendor_archive.json"
|
||||
API_CONFIG_HOME="/boot/config/plugins/dynamix.my.servers/configs"
|
||||
|
||||
# Get API version from config file
|
||||
# Returns the API version string or empty if not found
|
||||
@@ -66,7 +67,7 @@ get_archive_information() {
|
||||
# Returns 0 if enabled, 1 if not enabled or error
|
||||
is_api_plugin_enabled() {
|
||||
local plugin_name="$1"
|
||||
local api_config_path="/boot/config/plugins/dynamix.my.servers/configs/api.json"
|
||||
local api_config_path="$API_CONFIG_HOME/api.json"
|
||||
|
||||
# Check if plugin name is provided
|
||||
if [ -z "$plugin_name" ]; then
|
||||
|
||||
Reference in New Issue
Block a user