wallarm/remove.sh

26 lines
734 B
Bash
Executable file

#!/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