Skip to content

Commit

Permalink
Improve and fix install script, fix issue #360 (#370)
Browse files Browse the repository at this point in the history
* Fix invalid reference to deprecated Revov. Issue #364

* Improve install script and fix issue #360

* Removed rc.local to prevent overwriting existing files from other drivers. Fixes #360

Co-authored-by: Louis Van Der Walt <[email protected]>
  • Loading branch information
chaerle and Louisvdw authored Dec 29, 2022
1 parent e8c84aa commit dd27c05
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 36 deletions.
53 changes: 19 additions & 34 deletions etc/dbus-serialbattery/reinstalllocal.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,27 @@
#!/bin/sh

DRIVER=/opt/victronenergy/dbus-serialbattery
RUN=/opt/victronenergy/service-templates/dbus-serialbattery
OLD=/opt/victronenergy/service/dbus-serialbattery
DRIVERNAME=dbus-serialbattery

#handle read only mounts
sh /opt/victronenergy/swupdate-scripts/remount-rw.sh

if [ -d "$DRIVER" ]; then
if [ -L "$DRIVER" ]; then
# Remove old SymLink.
rm "$DRIVER"
# Create as folder
mkdir "$DRIVER"
fi
else
# Create folder
mkdir "$DRIVER"
fi
if [ -d "$RUN" ]; then
if [ -L "$RUN" ]; then
# Remove old SymLink.
rm "$RUN"
# Create as folder
mkdir "$RUN"
fi
else
# Create folder
mkdir "$RUN"
fi
if [ -d "$OLD" ]; then
if [ -L "$OLD" ]; then
# Remove old SymLink.
rm "$RUN"
fi
fi
#install
rm -rf /opt/victronenergy/service/$DRIVERNAME
rm -rf /opt/victronenergy/service-templates/$DRIVERNAME
rm -rf /opt/victronenergy/$DRIVERNAME
mkdir /opt/victronenergy/$DRIVERNAME
cp -f /data/etc/$DRIVERNAME/* /opt/victronenergy/$DRIVERNAME &>/dev/null
cp -rf /data/etc/$DRIVERNAME/service /opt/victronenergy/service-templates/$DRIVERNAME
sh /data/etc/$DRIVERNAME/installqml.sh

cp -f /data/etc/dbus-serialbattery/* /opt/victronenergy/dbus-serialbattery &>/dev/null
cp -rf /data/etc/dbus-serialbattery/service/* /opt/victronenergy/service-templates/dbus-serialbattery
#restart if running
pkill -f "python .*/$DRIVERNAME.py"

# add install-script to rc.local to be ready for firmware update
filename=/data/rc.local
if [ ! -f $filename ]; then
echo "#!/bin/bash" >> $filename
chmod 755 $filename
fi
grep -qxF "sh /data/etc/$DRIVERNAME/reinstalllocal.sh" $filename || echo "sh /data/etc/$DRIVERNAME/reinstalllocal.sh" >> $filename

sh /data/etc/dbus-serialbattery/installqml.sh
2 changes: 0 additions & 2 deletions rc.local

This file was deleted.

0 comments on commit dd27c05

Please sign in to comment.