-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdisable.sh
More file actions
56 lines (44 loc) · 1.71 KB
/
disable.sh
File metadata and controls
56 lines (44 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
#
# Disable script for victron-seelevel-python (dbus-seelevel service)
# Cleanly stops and removes the service and all its settings
#
# remove comment for easier troubleshooting
#set -x
INSTALL_DIR="/data/apps/victron-seelevel-python"
SERVICE_NAME="dbus-seelevel"
echo
echo "Disabling $SERVICE_NAME..."
# Remove service symlink
rm -rf "/service/$SERVICE_NAME" 2>/dev/null || true
# Kill any remaining processes
pkill -f "supervise $SERVICE_NAME" 2>/dev/null || true
pkill -f "multilog .* /var/log/$SERVICE_NAME" 2>/dev/null || true
pkill -f "python.*seelevel" 2>/dev/null || true
# Remove enable script from rc.local
sed -i "/.*victron-seelevel-python.*/d" /data/rc.local 2>/dev/null || true
sed -i "/.*dbus-seelevel.*/d" /data/rc.local 2>/dev/null || true
echo "Service stopped and rc.local cleaned"
# Clean up D-Bus settings
echo "Cleaning up D-Bus settings..."
# Function to delete a settings path
delete_setting() {
local path="$1"
dbus -y com.victronenergy.settings "$path" SetValue "" 2>/dev/null || true
}
# Clean up current settings paths
for path in $(dbus -y com.victronenergy.settings / GetValue 2>/dev/null | grep -oE "Settings/Devices/seelevel/[^']*" | sort -u); do
echo " Removing /$path"
delete_setting "/$path"
done
# Clean up old settings paths (from previous naming conventions)
for path in $(dbus -y com.victronenergy.settings / GetValue 2>/dev/null | grep -oE "Settings/Devices/seelevel_monitor/[^']*" | sort -u); do
echo " Removing old /$path"
delete_setting "/$path"
done
echo
echo "$SERVICE_NAME disabled and settings cleaned"
echo
echo "Note: To completely remove, also delete: $INSTALL_DIR"
echo " You may also want to remove old install dir: /data/apps/dbus-seelevel"
echo