Files
venus/_template/install.sh
dev 9756538f16 Initial commit: Venus OS boat addons monorepo
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
2026-03-16 17:04:16 +00:00

116 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
#
# Installation script for Venus OS D-Bus service template
#
# Usage:
# chmod +x install.sh
# ./install.sh
#
set -e
SERVICE_NAME="dbus-template"
INSTALL_DIR="/data/$SERVICE_NAME"
MAIN_SCRIPT="dbus-template.py"
# 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 "$SERVICE_NAME - Installation"
echo "=================================================="
if [ ! -d "$SERVICE_DIR" ]; then
echo "ERROR: This doesn't appear to be a Venus OS device."
exit 1
fi
if [ ! -f "$INSTALL_DIR/$MAIN_SCRIPT" ]; then
echo "ERROR: Installation files not found in $INSTALL_DIR"
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/$MAIN_SCRIPT"
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
rm "$INSTALL_DIR/ext/velib_python"
fi
ln -s "$VELIB_DIR" "$INSTALL_DIR/ext/velib_python"
echo "3. Creating service symlink..."
if [ -L "$SERVICE_DIR/$SERVICE_NAME" ] || [ -e "$SERVICE_DIR/$SERVICE_NAME" ]; then
rm -rf "$SERVICE_DIR/$SERVICE_NAME"
fi
ln -s "$INSTALL_DIR/service" "$SERVICE_DIR/$SERVICE_NAME"
echo "4. Creating log directory..."
mkdir -p "/var/log/$SERVICE_NAME"
echo "5. 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 "$SERVICE_NAME" "$RC_LOCAL"; then
echo "" >> "$RC_LOCAL"
echo "# $SERVICE_NAME" >> "$RC_LOCAL"
echo "if [ ! -L $SERVICE_DIR/$SERVICE_NAME ]; then" >> "$RC_LOCAL"
echo " ln -s /data/$SERVICE_NAME/service $SERVICE_DIR/$SERVICE_NAME" >> "$RC_LOCAL"
echo "fi" >> "$RC_LOCAL"
fi
echo ""
echo "=================================================="
echo "Installation complete!"
echo "=================================================="
echo ""
echo "To check status: svstat $SERVICE_DIR/$SERVICE_NAME"
echo "To view logs: tail -F /var/log/$SERVICE_NAME/current | tai64nlocal"
echo ""