Organizes 11 projects for Cerbo GX/Venus OS into a single repository: - axiom-nmea: Raymarine LightHouse protocol decoder - dbus-generator-ramp: Generator current ramp controller - dbus-lightning: Blitzortung lightning monitor - dbus-meteoblue-forecast: Meteoblue weather forecast - dbus-no-foreign-land: noforeignland.com tracking - dbus-tides: Tide prediction from depth + harmonics - dbus-vrm-history: VRM cloud history proxy - dbus-windy-station: Windy.com weather upload - mfd-custom-app: MFD app deployment package - venus-html5-app: Custom Victron HTML5 app fork - watermaker: Watermaker PLC control UI Adds root README, .gitignore, project template, and per-project .gitignore files. Sensitive config files excluded via .gitignore with .example templates provided. Made-with: Cursor
238 lines
7.1 KiB
Bash
Executable File
238 lines
7.1 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Installation script for Raymarine D-Bus Publisher on Venus OS
|
|
#
|
|
# Run this on the Venus OS device after copying files to /data/dbus-raymarine-publisher/
|
|
#
|
|
# Usage:
|
|
# chmod +x install.sh
|
|
# ./install.sh
|
|
#
|
|
|
|
set -e
|
|
|
|
INSTALL_DIR="/data/dbus-raymarine-publisher"
|
|
SERVICE_LINK="dbus-raymarine-publisher"
|
|
|
|
# Find velib_python
|
|
VELIB_DIR=""
|
|
if [ -d "/opt/victronenergy/velib_python" ]; then
|
|
VELIB_DIR="/opt/victronenergy/velib_python"
|
|
else
|
|
for candidate in \
|
|
"/opt/victronenergy/dbus-systemcalc-py/ext/velib_python" \
|
|
"/opt/victronenergy/dbus-generator/ext/velib_python" \
|
|
"/opt/victronenergy/dbus-mqtt/ext/velib_python" \
|
|
"/opt/victronenergy/dbus-digitalinputs/ext/velib_python" \
|
|
"/opt/victronenergy/vrmlogger/ext/velib_python"
|
|
do
|
|
if [ -d "$candidate" ] && [ -f "$candidate/vedbus.py" ]; then
|
|
VELIB_DIR="$candidate"
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
|
|
if [ -z "$VELIB_DIR" ]; then
|
|
VEDBUS_PATH=$(find /opt/victronenergy -name "vedbus.py" -path "*/velib_python/*" 2>/dev/null | head -1)
|
|
if [ -n "$VEDBUS_PATH" ]; then
|
|
VELIB_DIR=$(dirname "$VEDBUS_PATH")
|
|
fi
|
|
fi
|
|
|
|
# Determine service directory
|
|
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 "Raymarine D-Bus Publisher - Installation"
|
|
echo "=================================================="
|
|
|
|
if [ ! -d "$SERVICE_DIR" ]; then
|
|
echo "ERROR: This doesn't appear to be a Venus OS device."
|
|
echo " Service directory not found."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Detected service directory: $SERVICE_DIR"
|
|
|
|
if [ ! -f "$INSTALL_DIR/venus_publisher.py" ]; then
|
|
echo "ERROR: Installation files not found in $INSTALL_DIR"
|
|
echo " Please copy all files to $INSTALL_DIR first."
|
|
exit 1
|
|
fi
|
|
if [ ! -f "$INSTALL_DIR/service/run" ]; then
|
|
echo "ERROR: service/run not found. The package is incomplete."
|
|
exit 1
|
|
fi
|
|
|
|
echo "1. Making scripts executable..."
|
|
chmod +x "$INSTALL_DIR/service/run"
|
|
chmod +x "$INSTALL_DIR/service/log/run"
|
|
chmod +x "$INSTALL_DIR/venus_publisher.py"
|
|
|
|
echo "2. Creating velib_python symlink..."
|
|
if [ -z "$VELIB_DIR" ]; then
|
|
echo "ERROR: Could not find velib_python on this system."
|
|
exit 1
|
|
fi
|
|
echo " Found velib_python at: $VELIB_DIR"
|
|
mkdir -p "$INSTALL_DIR/ext"
|
|
if [ -L "$INSTALL_DIR/ext/velib_python" ]; then
|
|
CURRENT_TARGET=$(readlink "$INSTALL_DIR/ext/velib_python")
|
|
if [ "$CURRENT_TARGET" != "$VELIB_DIR" ]; then
|
|
echo " Updating symlink (was: $CURRENT_TARGET)"
|
|
rm "$INSTALL_DIR/ext/velib_python"
|
|
fi
|
|
fi
|
|
if [ ! -L "$INSTALL_DIR/ext/velib_python" ]; then
|
|
ln -s "$VELIB_DIR" "$INSTALL_DIR/ext/velib_python"
|
|
echo " Symlink created: $INSTALL_DIR/ext/velib_python -> $VELIB_DIR"
|
|
else
|
|
echo " Symlink already exists"
|
|
fi
|
|
|
|
echo "3. Configuring network interface..."
|
|
echo ""
|
|
echo " Available network interfaces:"
|
|
for iface in $(ls /sys/class/net/ 2>/dev/null); do
|
|
ip=$(ip -4 addr show "$iface" 2>/dev/null | grep 'inet ' | awk '{print $2}' | cut -d/ -f1 | head -n 1)
|
|
if [ -n "$ip" ]; then
|
|
echo " $iface: $ip"
|
|
fi
|
|
done
|
|
echo ""
|
|
echo " Select network interface for Raymarine VLAN:"
|
|
echo " 1) eth0 - Ethernet (recommended)"
|
|
echo " 2) wlan0 - WiFi"
|
|
echo " 3) Enter a specific IP address"
|
|
echo ""
|
|
read -p " Choose [1-3]: " -n 1 -r CHOICE
|
|
echo ""
|
|
|
|
case $CHOICE in
|
|
1) INTERFACE="eth0" ;;
|
|
2) INTERFACE="wlan0" ;;
|
|
3)
|
|
read -p " Enter IP address: " INTERFACE
|
|
if ! echo "$INTERFACE" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
|
|
echo " Invalid IP address. Using eth0."
|
|
INTERFACE="eth0"
|
|
fi
|
|
;;
|
|
*) INTERFACE="eth0" ;;
|
|
esac
|
|
|
|
echo " Using interface: $INTERFACE"
|
|
|
|
echo "4. Configuring NMEA TCP server..."
|
|
echo ""
|
|
echo " The service can run an NMEA 0183 TCP server for navigation apps"
|
|
echo " (Navionics, iSailor, OpenCPN, SignalK, etc.)"
|
|
echo ""
|
|
echo " 1) Enable on default port 10110 (recommended)"
|
|
echo " 2) Enable on custom port"
|
|
echo " 3) Disable NMEA TCP server"
|
|
echo ""
|
|
read -p " Choose [1-3]: " -n 1 -r TCP_CHOICE
|
|
echo ""
|
|
|
|
case $TCP_CHOICE in
|
|
1) NMEA_TCP_PORT="10110" ;;
|
|
2)
|
|
read -p " Enter TCP port (1024-65535): " NMEA_TCP_PORT
|
|
if ! echo "$NMEA_TCP_PORT" | grep -qE '^[0-9]+$' || [ "$NMEA_TCP_PORT" -lt 1024 ] || [ "$NMEA_TCP_PORT" -gt 65535 ]; then
|
|
echo " Invalid port. Using default 10110."
|
|
NMEA_TCP_PORT="10110"
|
|
fi
|
|
;;
|
|
3) NMEA_TCP_PORT="disabled" ;;
|
|
*) NMEA_TCP_PORT="10110" ;;
|
|
esac
|
|
|
|
sed -i "s/^INTERFACE=.*/INTERFACE=\"$INTERFACE\"/" "$INSTALL_DIR/service/run"
|
|
sed -i "s/^NMEA_TCP_PORT=.*/NMEA_TCP_PORT=\"$NMEA_TCP_PORT\"/" "$INSTALL_DIR/service/run"
|
|
|
|
echo "5. Creating service symlink..."
|
|
if [ -L "$SERVICE_DIR/$SERVICE_LINK" ]; then
|
|
echo " Service link already exists, removing old link..."
|
|
rm "$SERVICE_DIR/$SERVICE_LINK"
|
|
fi
|
|
if [ -e "$SERVICE_DIR/$SERVICE_LINK" ]; then
|
|
rm -rf "$SERVICE_DIR/$SERVICE_LINK"
|
|
fi
|
|
ln -s "$INSTALL_DIR/service" "$SERVICE_DIR/$SERVICE_LINK"
|
|
|
|
if [ -L "$SERVICE_DIR/$SERVICE_LINK" ]; then
|
|
echo " Symlink created: $SERVICE_DIR/$SERVICE_LINK -> $INSTALL_DIR/service"
|
|
else
|
|
echo "ERROR: Failed to create service symlink"
|
|
exit 1
|
|
fi
|
|
|
|
echo "6. Creating log directory..."
|
|
mkdir -p /var/log/dbus-raymarine-publisher
|
|
|
|
echo "7. Setting up rc.local for persistence..."
|
|
RC_LOCAL="/data/rc.local"
|
|
if [ ! -f "$RC_LOCAL" ]; then
|
|
echo "#!/bin/bash" > "$RC_LOCAL"
|
|
chmod +x "$RC_LOCAL"
|
|
fi
|
|
|
|
if ! grep -q "dbus-raymarine-publisher" "$RC_LOCAL"; then
|
|
echo "" >> "$RC_LOCAL"
|
|
echo "# Raymarine D-Bus Publisher" >> "$RC_LOCAL"
|
|
echo "if [ ! -L $SERVICE_DIR/$SERVICE_LINK ]; then" >> "$RC_LOCAL"
|
|
echo " ln -s /data/dbus-raymarine-publisher/service $SERVICE_DIR/$SERVICE_LINK" >> "$RC_LOCAL"
|
|
echo "fi" >> "$RC_LOCAL"
|
|
echo " Added to rc.local for persistence across firmware updates"
|
|
else
|
|
echo " Already in rc.local"
|
|
fi
|
|
|
|
echo "8. Activating service..."
|
|
sleep 2
|
|
if command -v svstat >/dev/null 2>&1; then
|
|
if svstat "$SERVICE_DIR/$SERVICE_LINK" 2>/dev/null | grep -q "up"; then
|
|
echo " Service is running"
|
|
else
|
|
echo " Waiting for service to start..."
|
|
sleep 3
|
|
fi
|
|
fi
|
|
|
|
echo ""
|
|
echo "=================================================="
|
|
echo "Installation complete!"
|
|
echo "=================================================="
|
|
echo ""
|
|
|
|
if command -v svstat >/dev/null 2>&1; then
|
|
echo "Current status:"
|
|
svstat "$SERVICE_DIR/$SERVICE_LINK" 2>/dev/null || echo " Service not yet detected by svscan"
|
|
echo ""
|
|
fi
|
|
|
|
echo "Configuration:"
|
|
echo " Interface: $INTERFACE"
|
|
if [ "$NMEA_TCP_PORT" != "disabled" ]; then
|
|
echo " NMEA TCP port: $NMEA_TCP_PORT"
|
|
else
|
|
echo " NMEA TCP: disabled"
|
|
fi
|
|
echo ""
|
|
echo "To check status:"
|
|
echo " svstat $SERVICE_DIR/$SERVICE_LINK"
|
|
echo ""
|
|
echo "To view logs:"
|
|
echo " tail -F /var/log/dbus-raymarine-publisher/current | tai64nlocal"
|
|
echo ""
|