Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions plugin/source/dynamix.unraid.net/etc/rc.d/rc.flash_backup
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
# 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"
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
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading