Higher in this script I wrote : Being a complete newbie in the art of bash/Linux, I am sure these scripts can be condensed, and then improved, maybe merged in a single script which would run automaticaly at startup ?
Well, with little inspiration and a lot of transpiration, its done now and here is the new KeepOCPN_conf_Tidy script :
What is not addressed is the case where the opencpn.conf file is corrupted AND its length is not ZERO ! But I had dozens of corruptions, and length was always zero !
Still to find how make OP run this script at startup ! Any suggestion warmly welcomed
Well, with little inspiration and a lot of transpiration, its done now and here is the new KeepOCPN_conf_Tidy script :
Code:
# This script tests the opencpn.conf file length. If NOT 0 it will consider
# the file as valid and copy it as the new backup version.
# Else It will restore it with the former backup version.
if [ -s /home/pi/.opencpn/opencpn.conf ]; then cp /home/pi/.opencpn/opencpn.conf /home/pi/Sauvegardes/opencpn.conf;
else
# Copy corrupted file for forensic investigations
cp /home/pi/.opencpn/opencpn.conf /home/pi/.opencpn/garbage.ocpn.txt
# delete corrupted file
rm -f /home/pi/.opencpn/opencpn.conf
# restore opencpn.conf using former backup :
cp /home/pi/Sauvegardes/opencpn.conf /home/pi/.opencpn/opencpn.conf;
fi
Still to find how make OP run this script at startup ! Any suggestion warmly welcomed
Cordialement
Didier B
Pi4, SSD USB3, OP 3.0 Touch SK 3.2.1 OpenCPN 5.8.4 : Thank you Thank you Thank you
Didier B
Pi4, SSD USB3, OP 3.0 Touch SK 3.2.1 OpenCPN 5.8.4 : Thank you Thank you Thank you