73 lines
2.4 KiB
Bash
Executable File
73 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Uninstallation script for Generator Current Ramp Controller
|
|
#
|
|
# Usage:
|
|
# chmod +x uninstall.sh
|
|
# ./uninstall.sh
|
|
#
|
|
|
|
set -e
|
|
|
|
INSTALL_DIR="/data/dbus-generator-ramp"
|
|
|
|
# Determine the correct service directory (same logic as install.sh)
|
|
if [ -d "/service" ] && [ ! -L "/service" ]; then
|
|
SERVICE_DIR="/service"
|
|
elif [ -d "/opt/victronenergy/service" ]; then
|
|
SERVICE_DIR="/opt/victronenergy/service"
|
|
elif [ -L "/service" ]; then
|
|
SERVICE_DIR=$(readlink -f /service)
|
|
else
|
|
SERVICE_DIR="/opt/victronenergy/service"
|
|
fi
|
|
|
|
echo "=================================================="
|
|
echo "Generator Current Ramp Controller - Uninstallation"
|
|
echo "=================================================="
|
|
echo "Using service directory: $SERVICE_DIR"
|
|
|
|
echo "1. Stopping service and supervise..."
|
|
# Try svc if service directory exists
|
|
if [ -d "$SERVICE_DIR/dbus-generator-ramp" ] || [ -L "$SERVICE_DIR/dbus-generator-ramp" ]; then
|
|
# -d = down (stop service), -x = exit (stop supervise)
|
|
svc -dx "$SERVICE_DIR/dbus-generator-ramp" 2>/dev/null || true
|
|
sleep 2
|
|
echo " Sent stop signal via svc"
|
|
fi
|
|
|
|
# Kill any remaining processes (in case symlink was already removed or svc failed)
|
|
# Kill the python script first
|
|
pkill -f "python.*dbus-generator-ramp.py" 2>/dev/null && echo " Killed python process" || true
|
|
# Kill the supervise process
|
|
pkill -f "supervise dbus-generator-ramp$" 2>/dev/null && echo " Killed supervise process" || true
|
|
# Kill multilog for this service (use simple pattern - busybox pkill has limited regex)
|
|
pkill -f "/var/log/dbus-generator-ramp" 2>/dev/null && echo " Killed multilog process" || true
|
|
sleep 1
|
|
|
|
echo "2. Removing service symlink..."
|
|
if [ -L "$SERVICE_DIR/dbus-generator-ramp" ]; then
|
|
rm "$SERVICE_DIR/dbus-generator-ramp"
|
|
echo " Removed service link"
|
|
elif [ -d "$SERVICE_DIR/dbus-generator-ramp" ]; then
|
|
rm -rf "$SERVICE_DIR/dbus-generator-ramp"
|
|
echo " Removed service directory"
|
|
else
|
|
echo " Service link not found"
|
|
fi
|
|
|
|
echo "3. Note: Not removing files from $INSTALL_DIR"
|
|
echo " To fully remove, run: rm -rf $INSTALL_DIR"
|
|
|
|
echo "4. Note: rc.local entry not removed"
|
|
echo " Edit /data/rc.local manually if desired"
|
|
|
|
echo ""
|
|
echo "=================================================="
|
|
echo "Uninstallation complete!"
|
|
echo "=================================================="
|
|
echo ""
|
|
echo "The service has been stopped and disabled."
|
|
echo "Files remain in $INSTALL_DIR"
|
|
echo ""
|