mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-04-25 14:07:49 +02:00
Merge pull request #2825 from Security-Onion-Solutions/foxtrot
Setup: dpkg retry, whiptail changes, fix zeek state condition
This commit is contained in:
@@ -229,7 +229,7 @@ retry() {
|
||||
while [[ $attempt -lt $maxAttempts ]]; do
|
||||
attempt=$((attempt+1))
|
||||
echo "Executing command with retry support: $cmd"
|
||||
output=$($cmd)
|
||||
output=$(eval "$cmd")
|
||||
exitcode=$?
|
||||
echo "Results: $output ($exitcode)"
|
||||
if [ -n "$expectedOutput" ]; then
|
||||
@@ -248,51 +248,6 @@ retry() {
|
||||
return 1
|
||||
}
|
||||
|
||||
wait_for_apt() {
|
||||
local progress_callback=$1
|
||||
|
||||
local retry_count=30
|
||||
local retry_timeout='10s'
|
||||
local lock_msg="Could not acquire dpkg lock, waiting $retry_timeout for lock to release."
|
||||
if [[ -z $progress_callback ]]; then
|
||||
if [[ -z $progress_bar_text ]]; then
|
||||
local old_text="Installing..."
|
||||
else
|
||||
local old_text="$progress_bar_text"
|
||||
fi
|
||||
fi
|
||||
local count=0
|
||||
while [[ "$count" -lt "$retry_count" ]]; do
|
||||
((count++))
|
||||
[[ -z $progress_callback ]] && echo "Attempting to acquire dpkg lock to run apt command... (Attempt $count/$retry_count)"
|
||||
if __check_apt_lock; then
|
||||
if [[ -z $progress_callback ]]; then
|
||||
echo " $lock_msg" | tee -a "$setup_log"
|
||||
else
|
||||
$progress_callback "Could not acquire dpkg lock, waiting $retry_timeout ($count/$retry_count)"
|
||||
fi
|
||||
else
|
||||
[[ -z $progress_callback ]] || $progress_callback "$old_text"
|
||||
return 0
|
||||
fi
|
||||
sleep "$retry_timeout"
|
||||
done
|
||||
|
||||
if __check_apt_lock; then
|
||||
[[ -z $progress_callback ]] && echo "Could not acquire lock after $retry_count attempts, aborting."
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
__check_apt_lock() {
|
||||
lsof /var/lib/dpkg/lock &> /dev/null
|
||||
local lock=$?
|
||||
|
||||
return $lock
|
||||
}
|
||||
|
||||
valid_cidr() {
|
||||
# Verify there is a backslash in the string
|
||||
echo "$1" | grep -qP "^[^/]+/[^/]+$" || return 1
|
||||
|
||||
Reference in New Issue
Block a user