Skip to content

Commit

Permalink
Merge pull request #217 from jsrc27/TOR-3743
Browse files Browse the repository at this point in the history
auto-provisioning: improve behavior with power cuts
  • Loading branch information
rborn-tx authored Feb 5, 2025
2 parents 15f361c + 1f2c87f commit a88fec4
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,24 @@ register_device() {
}

write_credentials() {
local temp_dir

log "Updating device credentials"

rm -Rf $SOTA_CRED_DIR && mkdir -p $SOTA_CRED_DIR
if ! unzip device.zip -d $SOTA_CRED_DIR >/dev/null; then
temp_dir="${SOTA_CRED_DIR}.tmp"
rm -Rf ${temp_dir} && mkdir -p ${temp_dir}
if ! unzip device.zip -d ${temp_dir} >/dev/null; then
rm -rf ${temp_dir}
exit_error "Failed extracting credentials file"
fi
sync

rm -rf $SOTA_BASE_DIR/sql.db
rm -rf ${SOTA_CRED_DIR}
mv -f ${temp_dir} ${SOTA_CRED_DIR}

rm -rf $CONFIG_FILE
rm -rf ${SOTA_BASE_DIR}/sql.db
rm -rf ${CONFIG_FILE}
sync
}

restart_services() {
Expand Down

0 comments on commit a88fec4

Please sign in to comment.