|
2 | 2 | # This file is /etc/rc.d/rc.flash_backup |
3 | 3 | # use at queue "f" for flash backup |
4 | 4 | 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 | + |
5 | 9 | QUEUE=" -q f " |
6 | 10 | TASKNAME="/etc/rc.d/rc.flash_backup watch" |
7 | 11 | TASKACTION="/usr/local/emhttp/plugins/dynamix.my.servers/scripts/UpdateFlashBackup update" |
8 | 12 | last=$(date +%s) |
9 | 13 | # set GIT_OPTIONAL_LOCKS=0 globally to reduce/eliminate writes to /boot |
10 | 14 | export GIT_OPTIONAL_LOCKS=0 |
11 | 15 |
|
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 |
14 | 18 | THIRTYMINS=1800 # 30 minutes is 1800 seconds |
15 | 19 | # wait for existing git commands to complete |
16 | 20 | # $1 is the time in seconds to sleep when waiting. SLOW or FAST |
@@ -162,20 +166,22 @@ _enabled() { |
162 | 166 | return 1 |
163 | 167 | } |
164 | 168 | _connected() { |
165 | | - CFG=/var/local/emhttp/myservers.cfg |
| 169 | + CFG=$API_CONFIG_HOME/connect.json |
166 | 170 | [[ ! -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) |
170 | 173 | if [ -z "${username}" ]; then |
171 | 174 | return 1 |
172 | 175 | 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 | + # |
173 | 179 | # 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 |
179 | 185 | return 0 |
180 | 186 | } |
181 | 187 | _haserror() { |
|
0 commit comments