Skip to content

Commit 4bfc9a9

Browse files
authored
Add backing up of ir.json to wled-tools
1 parent 4d39dd0 commit 4bfc9a9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tools/wled-tools

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,15 @@ backup_one() {
115115

116116
local cfg_url="http://$address:$port/cfg.json"
117117
local presets_url="http://$address:$port/presets.json"
118+
local ir_url="http://$address:$port/ir.json"
118119
local cfg_dest="${backup_dir}/${hostname}.cfg.json"
119120
local presets_dest="${backup_dir}/${hostname}.presets.json"
121+
local ir_dest="${backup_dir}/${hostname}.ir.json"
120122

121123
# Write to ".tmp" files first, then move when success, to ensure we don't write partial files
122124
local curl_command_cfg="curl -s "$cfg_url" -o "$cfg_dest.tmp""
123125
local curl_command_presets="curl -s "$presets_url" -o "$presets_dest.tmp""
126+
local curl_command_ir="curl -s "$ir_url" -o "$ir_dest.tmp""
124127

125128
if ! curl_handler "$curl_command_cfg" "$hostname"; then
126129
log "ERROR" "$RED" "Failed to backup configuration for $hostname"
@@ -132,10 +135,18 @@ backup_one() {
132135
log "ERROR" "$RED" "Failed to backup presets for $hostname"
133136
rm -f "$presets_dest.tmp"
134137
return 1
135-
fi
138+
fi
136139

137140
mv "$cfg_dest.tmp" "$cfg_dest"
138141
mv "$presets_dest.tmp" "$presets_dest"
142+
143+
if curl_handler "$curl_command_ir" "$hostname"; then
144+
mv "$ir_dest.tmp" "$ir_dest"
145+
else
146+
rm -f "$ir_dest.tmp"
147+
log "WARN" "$YELLOW" "No ir.json found for $hostname (skipping)"
148+
fi
149+
139150
log "INFO" "$GREEN" "Successfully backed up config and presets for $hostname"
140151
return 0
141152
}

0 commit comments

Comments
 (0)