Skip to content

Commit 80f72b0

Browse files
committed
read username from connect.json & drop minigraphConnected check
1 parent e539d7f commit 80f72b0

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

plugin/source/dynamix.unraid.net/etc/rc.d/rc.flash_backup

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22
# This file is /etc/rc.d/rc.flash_backup
33
# use at queue "f" for flash backup
44
scripts_dir="/usr/local/share/dynamix.unraid.net/scripts"
5+
# This loads the API_CONFIG_HOME variable
6+
# shellcheck source=../usr/local/share/dynamix.unraid.net/scripts/api_utils.sh
7+
source "$scripts_dir/api_utils.sh"
8+
59
QUEUE=" -q f "
610
TASKNAME="/etc/rc.d/rc.flash_backup watch"
711
TASKACTION="/usr/local/emhttp/plugins/dynamix.my.servers/scripts/UpdateFlashBackup update"
812
last=$(date +%s)
913
# set GIT_OPTIONAL_LOCKS=0 globally to reduce/eliminate writes to /boot
1014
export GIT_OPTIONAL_LOCKS=0
1115

12-
FAST=1 # 1 second delay when waiting for git
13-
SLOW=10 # 10 second delay when waiting for git
16+
FAST=1 # 1 second delay when waiting for git
17+
SLOW=10 # 10 second delay when waiting for git
1418
THIRTYMINS=1800 # 30 minutes is 1800 seconds
1519
# wait for existing git commands to complete
1620
# $1 is the time in seconds to sleep when waiting. SLOW or FAST
@@ -162,20 +166,22 @@ _enabled() {
162166
return 1
163167
}
164168
_connected() {
165-
CFG=/var/local/emhttp/myservers.cfg
169+
CFG=$API_CONFIG_HOME/connect.json
166170
[[ ! -f "${CFG}" ]] && return 1
167-
# shellcheck disable=SC1090
168-
source <(sed -nr '/\[remote\]/,/\[/{/username/p}' "${CFG}" 2>/dev/null)
169-
# ensure signed in
171+
172+
username=$(jq -r '.username // empty' "${CFG}" 2>/dev/null)
170173
if [ -z "${username}" ]; then
171174
return 1
172175
fi
176+
# the minigraph status is no longer synced to the connect config file
177+
# to avoid a false negative, we'll omit this check for now.
178+
#
173179
# shellcheck disable=SC1090
174-
source <(sed -nr '/\[connectionStatus\]/,/\[/{/minigraph/p}' "${CFG}" 2>/dev/null)
175-
# ensure connected
176-
if [[ -z "${minigraph}" || "${minigraph}" != "CONNECTED" ]]; then
177-
return 1
178-
fi
180+
# source <(sed -nr '/\[connectionStatus\]/,/\[/{/minigraph/p}' "${CFG}" 2>/dev/null)
181+
# # ensure connected
182+
# if [[ -z "${minigraph}" || "${minigraph}" != "CONNECTED" ]]; then
183+
# return 1
184+
# fi
179185
return 0
180186
}
181187
_haserror() {

plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/scripts/api_utils.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Default paths
66
CONFIG_FILE="/usr/local/share/dynamix.unraid.net/config/vendor_archive.json"
7+
API_CONFIG_HOME="/boot/config/plugins/dynamix.my.servers/configs"
78

89
# Get API version from config file
910
# Returns the API version string or empty if not found
@@ -66,7 +67,7 @@ get_archive_information() {
6667
# Returns 0 if enabled, 1 if not enabled or error
6768
is_api_plugin_enabled() {
6869
local plugin_name="$1"
69-
local api_config_path="/boot/config/plugins/dynamix.my.servers/configs/api.json"
70+
local api_config_path="$API_CONFIG_HOME/api.json"
7071

7172
# Check if plugin name is provided
7273
if [ -z "$plugin_name" ]; then

0 commit comments

Comments
 (0)