opencpn.conf gets randomly emptied WALKED AROUND - Printable Version +- OpenMarine (https://forum.openmarine.net) +-- Forum: OpenPlotter (https://forum.openmarine.net/forumdisplay.php?fid=1) +--- Forum: Bug Reports (https://forum.openmarine.net/forumdisplay.php?fid=4) +--- Thread: opencpn.conf gets randomly emptied WALKED AROUND (/showthread.php?tid=1821) |
opencpn.conf gets randomly emptied WALKED AROUND - Didier B - 2019-05-29 Rather than duplicate the info, I have posted a new thread on cruisers forum regarding an issue with opencpn.conf file getting corrupted. So far, the issue doesn't seem to be addressed by the OpenCPN team ... The walk around I mention makes use of 2 bash scrips, one to create a backup of opencpn.conf, to be run when everything is going nicely, and the second one to restore the opencpn.conf when the catastrophe happened ! Not so elegant, but please consider these are my very first bash scripts ! here they are : Backup : # this script backs up the opencpn.conf file in the # directory : ~/Sauvegardes #OpenCPNshould be stooped 1st (CTRL+Q) and # the content of opencpn.conf checked non empty) cp /home/pi/.opencpn/opencpn.conf /home/pi/Sauvegardes/opencpn.conf Restore : # this script replaces the file /.opencpn/opencpn.conf, # when corrpted with he file formerly saved in the directory : ~/Sauvegardes # Save the corrupted file, target of the pocedure, for forensic analysis : cp /home/pi/.opencpn/opencpn.conf /home/pi/.opencpn/garbage.ocpn.txt # delete the corrupted file : rm -f /home/pi/.opencpn/opencpn.conf # replace the corrupted file by its backup : cp /home/pi/Sauvegardes/opencpn.conf /home/pi/.opencpn/opencpn.conf Edit : see improved script later in this thread 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 ? I am opened to any suggestion to automate the process as much as possible ! RE: opencpn.conf gets randomly emptied - Sailoog - 2019-05-29 I think opencpn team is right. This is a difficult issue to solve. But, let's turn a problem into an advantage... Following your idea I think we should have an option in OP interface to manage a kind of "templates" to save/import not only opencpn settings but all important programs. This "save/import templates" button should open a new window to choose what settings you want to save/import: All - OpenPlotter - kplex - Signal K and plugins - OpenCPN and plugins - SDR receiver. Am I forgetting any app? RE: opencpn.conf gets randomly emptied - Didier B - 2019-05-29 (2019-05-29, 08:32 PM)Sailoog Wrote: I think opencpn team is right. This is a difficult issue to solve. But, let's turn a problem into an advantage...Agreed with you Sailoog ! (Some people in front of an issue beyond their competencies, forget to stay simply correct, isn't it ?) Our both approaches have there pros and cons. On one hand, I would like, for inexperienced users, to kiss it (Keep It Short & Simple !) : when the initial OCPN message shows up, stop it and push the restore button ! On the other hand, what you are suggesting could be so usefull fore more experienced user, allowing to backup/restore complete OP configuration ...A new OP tab, maybe ? What I dislike in my 1st approach (2 bash scripts) is that, if you push the 'backup' button after a corruption, you will kill the only restore possibility ... Practically, if the conf file has a zero byte lenght, it would be wise to abort the backup script ! But that is far beyond my knowledge of bash scripts ... Ideally the backup should be 100% automatic, at OP startup, testing opencpn.conf length, and if lenght > 0 back it up in the appropriate dir. If not abort the backup process ! Then only a 'restore' button will be needed. RE: opencpn.conf gets randomly emptied - Didier B - 2019-05-30 Sailoog, Maybe it would be interesting to display a warning message : "Always close OpenCPN (Ctrl + Q) before system shutdown !"
RE: opencpn.conf gets randomly emptied - Sailoog - 2019-05-30 We have already an "startup" script that runs the first OP window every start. We could do something there. We could check the conf file and if it is >0 we make a backup copy and if its content is 0 we load the latest backup file. Are you sure the file is 0 when this happens? RE: opencpn.conf gets randomly emptied - Didier B - 2019-05-30 I have reported to element14, see here, of course for them it is an Application problem... I suggested adding a time out before the power down in the Pi desktop software, and proposed to participate in the validation of the solution ... if s'thing happens I will report here RE: opencpn.conf gets randomly emptied - Didier B - 2019-05-31 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 : Code: # This script tests the opencpn.conf file length. If NOT 0 it will consider Still to find how make OP run this script at startup ! Any suggestion warmly welcomed RE: opencpn.conf gets randomly emptied SOLVED - Didier B - 2019-05-31 KeepOCPN_conf_Tidy.pdf (Size: 11.17 KB / Downloads: 207) next and final step : I have added, as ROOT, that line to /etc/RC.locale : Code: /home/pi/KeepOCPN_conf_Tidy Code: #!/bin/sh -e Let us control its perfect operational condition :
The only drawback in case of corruption is you will have the configuration of your previous session ..., which is much better than no configuration at all ! I have stamped my desktop with this GOLD rule : Always quit OpenCPN before stopping the system !
To summarize :
EDIT : see next post RE: opencpn.conf gets randomly emptied SOLVED - Didier B - 2019-06-01 I coud eventually attach a file ! to use it you should copy/paste its content in a text file, save it with the proper name, no extension. KeepOCPN_conf_Tidy.pdf (Size: 11.17 KB / Downloads: 254) |