make a maintenance mechanism
This commit is contained in:
33
maintenance.sh
Normal file
33
maintenance.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASEPATH="$(dirname "$0")"
|
||||
source $BASEPATH/.env
|
||||
|
||||
IFS=':' read -ra parts <<< $COMPOSE_FILE
|
||||
|
||||
blacklist=("drpc.yml" "drpc-free.yml" "base.yml" "rpc.yml" "monitoring.yml" "ftp.yml" "backup-http.yml")
|
||||
|
||||
for part in "${parts[@]}"; do
|
||||
include=true
|
||||
for word in "${blacklist[@]}"; do
|
||||
if echo "$part" | grep -qE "$word"; then
|
||||
#echo "The path $path contains a blacklisted word: $word"
|
||||
include=false
|
||||
fi
|
||||
done
|
||||
|
||||
if $include; then
|
||||
file="${part%.yml}.maintenance"
|
||||
if [ -f "$file" ]; then
|
||||
echo "File $file exists. Executing it as a Bash script."
|
||||
# Execute the file as a Bash script
|
||||
bash "$file"
|
||||
else
|
||||
echo "File $file does not exist or is not a regular file."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
13
op-zircuit-mainnet.maintenance
Normal file
13
op-zircuit-mainnet.maintenance
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
PEERS=$(docker exec rpc-op-zircuit-node-1 sh -c "apk add curl > /dev/null; curl -s -X POST -H \"Content-Type: application/json\" --data '{\"jsonrpc\":\"2.0\",\"method\":\"opp2p_peers\",\"params\":[true],\"id\":1}' http://localhost:8545" | jq '.result.peers | keys | length')
|
||||
|
||||
if [ "$PEERS" -eq 0 ]; then
|
||||
# Change to the script directory
|
||||
cd "$script_dir" || exit
|
||||
|
||||
# Run the Docker Compose command
|
||||
docker compose up -d --force-recreate op-zircuit-node
|
||||
fi
|
||||
Reference in New Issue
Block a user