remove docker binaries from git, add remove.sh
This commit is contained in:
parent
ebde840b28
commit
e9e9b2976e
3 changed files with 27 additions and 0 deletions
27
remove.sh
Executable file
27
remove.sh
Executable file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# remove.sh — uninstall a Wallarm node
|
||||||
|
set -e
|
||||||
|
NAME="${1:-}"
|
||||||
|
if [ -z "$NAME" ]; then
|
||||||
|
echo "Usage: $0 <node-name>"
|
||||||
|
echo " $0 --all"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$NAME" = "--all" ]; then
|
||||||
|
docker ps --filter 'name=wallarm-' -q | xargs -r docker rm -f
|
||||||
|
rm -rf /opt/fw/app/state.json
|
||||||
|
echo "All nodes removed."
|
||||||
|
else
|
||||||
|
docker rm -f "wallarm-${NAME}" 2>/dev/null
|
||||||
|
# Clean state
|
||||||
|
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
|
||||||
|
echo "Node ${NAME} removed."
|
||||||
|
fi
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue