fixup
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
40ae3fc6fe
commit
6d5cbcaa14
|
|
@ -1,64 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Function to process diffs and check ignores
|
||||
process_container() {
|
||||
local container_id=$1
|
||||
local mode=$2
|
||||
|
||||
# Get the container labels
|
||||
labels=$(docker inspect --format '{{json .Config.Labels}}' "$container_id")
|
||||
cname=$(echo "$labels" | jq -r '.["oculus.cname"]')
|
||||
ignores=$(echo "$labels" | jq -r '.["oculus.ignores"]')
|
||||
|
||||
# Get the diff
|
||||
diff_output=$(docker diff "$container_id")
|
||||
|
||||
# Process ignores
|
||||
if [ "$ignores" != "null" ]; then
|
||||
IFS=',' read -ra ignore_array <<< "$ignores"
|
||||
for ignore in "${ignore_array[@]}"; do
|
||||
diff_output=$(echo "$diff_output" | grep -v "$ignore")
|
||||
done
|
||||
fi
|
||||
|
||||
# Write the diff output to a file
|
||||
echo "$diff_output" > "${cname}.diff"
|
||||
|
||||
if [ "$mode" == "monitor" ]; then
|
||||
# Check if there are any changes left after applying ignores
|
||||
if [ -n "$diff_output" ]; then
|
||||
# Send notification using go-glitch
|
||||
echo "$diff_output" | go-glitch
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
export -f process_container
|
||||
|
||||
# Get the list of running containers
|
||||
containers=$(docker ps -q)
|
||||
|
||||
# Check if there are no running containers
|
||||
if [ -z "$containers" ]; then
|
||||
echo "No running containers found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Iterate over each container and process based on labels
|
||||
for container in $containers; do
|
||||
labels=$(docker inspect --format '{{json .Config.Labels}}' "$container")
|
||||
enable=$(echo "$labels" | jq -r '.["oculus.enable"]')
|
||||
|
||||
if [ "$enable" == "monitor" ]; then
|
||||
frequency=$(echo "$labels" | jq -r '.["oculus.frequency"]')
|
||||
if [ "$frequency" == "null" ]; then
|
||||
frequency="300s" # Default frequency if not set
|
||||
fi
|
||||
# Run the process_container function with monitor mode
|
||||
echo "$container monitor" | parallel process_container
|
||||
sleep "${frequency}"
|
||||
elif [ "$enable" == "profile" ]; then
|
||||
# Run the process_container function with profile mode
|
||||
echo "$container profile" | parallel process_container
|
||||
fi
|
||||
done
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,34 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Function to process diffs and check ignores
|
||||
process_diff() {
|
||||
local container_id=$1
|
||||
local cname=$2
|
||||
local ignores=$3
|
||||
|
||||
# Get the diff
|
||||
diff_output=$(docker diff $container_id)
|
||||
|
||||
# Process ignores
|
||||
if [ -n "$ignores" ]; then
|
||||
IFS=',' read -ra ignore_array <<< "$ignores"
|
||||
for ignore in "${ignore_array[@]}"; do
|
||||
diff_output=$(echo "$diff_output" | grep -v "$ignore")
|
||||
done
|
||||
fi
|
||||
|
||||
# Write the diff output to a file
|
||||
echo "$diff_output" > "${cname}.diff"
|
||||
|
||||
# Check if there are any changes left after applying ignores
|
||||
if [ -n "$diff_output" ]; then
|
||||
# Send notification using go-glitch
|
||||
echo "$diff_output" | go-glitch
|
||||
fi
|
||||
}
|
||||
|
||||
export -f process_diff
|
||||
|
||||
# Read containers.txt and process each line in parallel
|
||||
cat containers.txt | parallel --colsep ' ' 'process_diff {1} {2} {3}'
|
||||
./
|
||||
Loading…
Reference in New Issue