add remove.sh for uninstalling running nodes
This commit is contained in:
parent
d7a1d790be
commit
676202f625
1 changed files with 26 additions and 0 deletions
26
remove.sh
Executable file
26
remove.sh
Executable file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# remove.sh — uninstall a running Wallarm node
|
||||||
|
set -e
|
||||||
|
NAME="${1:-}"
|
||||||
|
if [ -z "$NAME" ]; then
|
||||||
|
echo "Usage: $0 <node-name>"
|
||||||
|
echo " $0 --all Remove all nodes"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$NAME" = "--all" ]; then
|
||||||
|
docker ps -q --filter 'name=wallarm-' | xargs -r docker rm -f
|
||||||
|
rm -f /opt/fw/app/state.json
|
||||||
|
echo "All nodes removed."
|
||||||
|
else
|
||||||
|
docker rm -f "wallarm-${NAME}" 2>/dev/null
|
||||||
|
python3 -c "
|
||||||
|
import json
|
||||||
|
try:
|
||||||
|
with open('/opt/fw/app/state.json') as f: s = json.load(f)
|
||||||
|
s['nodes'] = [n for n in s.get('nodes',[]) if n['name'] != '${NAME}']
|
||||||
|
with open('/opt/fw/app/state.json','w') as f: json.dump(s, f, indent=2)
|
||||||
|
except: pass
|
||||||
|
" 2>/dev/null || true
|
||||||
|
echo "Node ${NAME} removed."
|
||||||
|
fi
|
||||||
Loading…
Reference in a new issue