mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
Improve algorithm for determining if a user sync is necessary; Apply salt state in foreground to avoid collisions with setup salt states.
This commit is contained in:
@@ -236,12 +236,12 @@ function syncElastic() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function syncAll() {
|
function syncAll() {
|
||||||
if [[ -f "$databasePath" && -f "$elasticUsersFile" ]]; then
|
if [[ -z "$FORCE_SYNC" && -f "$databasePath" && -f "$elasticUsersFile" ]]; then
|
||||||
usersFileAgeSecs=$((echo $(date +%s) - $(date +%s -r "$elasticUsersFile")))
|
usersFileAgeSecs=$(echo $(($(date +%s) - $(date +%s -r "$elasticUsersFile"))))
|
||||||
staleCount=$(echo "select count(*) from identity_credentials where updated_at >= Datetime('now', '-${usersFileAgeSecs} seconds');" \
|
staleCount=$(echo "select count(*) from identity_credentials where updated_at >= Datetime('now', '-${usersFileAgeSecs} seconds');" \
|
||||||
| sqlite3 "$databasePath")
|
| sqlite3 "$databasePath")
|
||||||
if [[ "$staleCount" == "0" ]]; then
|
if [[ "$staleCount" == "0" ]]; then
|
||||||
return 1
|
fail "Users are already in sync. Run 'FORCE_SYNC=1 $0 sync' to force a full sync anyway."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
syncElastic
|
syncElastic
|
||||||
|
|||||||
Reference in New Issue
Block a user