#!/bin/bash

mount -o remount,rw /

# Source directory
source_dir="/data/dbus-fzsonick-48tl"

# Destination directory
destination_dir_upper="/opt/victronenergy/"
destination_dir="/opt/victronenergy/dbus-fzsonick-48tl/"

# Check if the destination directory exists
if [ -d "$destination_dir" ]; then
    # Remove the destination directory
    rm -r "$destination_dir"
fi

# Copy the contents of the source directory to the destination directory
cp -r "$source_dir" "$destination_dir_upper"

# Set MPPT network mode to 0
# sed -i "s|('/Link/NetworkMode', [^)]*)|('/Link/NetworkMode', 0)|g" /opt/victronenergy/dbus-systemcalc-py/delegates/dvcc.py
#sed -i "s|self._get_path('/Settings/BmsPresent') == 1|0|g" /opt/victronenergy/dbus-systemcalc-py/delegates/dvcc.py
sed -i "s/self._set_path('\/Link\/NetworkMode', v)/self._set_path('\/Link\/NetworkMode', 0)\n self._set_path('\/Settings\/BmsPresent',0)/" /opt/victronenergy/dbus-systemcalc-py/delegates/dvcc.py

exit 0