mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 09:12:45 +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() {
|
||||
if [[ -f "$databasePath" && -f "$elasticUsersFile" ]]; then
|
||||
usersFileAgeSecs=$((echo $(date +%s) - $(date +%s -r "$elasticUsersFile")))
|
||||
if [[ -z "$FORCE_SYNC" && -f "$databasePath" && -f "$elasticUsersFile" ]]; then
|
||||
usersFileAgeSecs=$(echo $(($(date +%s) - $(date +%s -r "$elasticUsersFile"))))
|
||||
staleCount=$(echo "select count(*) from identity_credentials where updated_at >= Datetime('now', '-${usersFileAgeSecs} seconds');" \
|
||||
| sqlite3 "$databasePath")
|
||||
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
|
||||
syncElastic
|
||||
|
||||
Reference in New Issue
Block a user