WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: RPI-64 export flags  (Read 6240 times)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: RPI-64 export flags
« Reply #15 on: December 12, 2021, 01:51:09 PM »
Hi Mypresus
Some programs when you run them will automatically create configuration files under the users ~/.config directory, such
as geany, gpicview, libreoffice, mc, wireshark, etc. Some will create hidden directories directly in the users
home directory, such as claws-mail, dillo, fifth, mozilla (Firefox), ssh, etc.

Some extensions conditionally create config directories/files through their tce.installed script, such as bash, grabber
and gtk3.

If you boot an ISO, there is no persistence, and I don't think a backup option is available either.
If Tinycore  is installed,  /home  and  /opt  are backed up when you use the  Exit  icon.
If Tinycore  is installed, and you have persistent  /home  and/or  /opt  directories, those directories should not be backed up.

Offline Mypresus

  • Newbie
  • *
  • Posts: 24
Re: RPI-64 export flags
« Reply #16 on: December 13, 2021, 05:58:03 PM »
Hi Rich,
Sorry for the late reply, other life things have gotten in the way.  Firstly thank you for sharing your scripts with me I haven't had a chance to go over them yet but at a quick look I see some valuable info.  My script was created to get a greater understanding of how TC and Linux works and hope that it may have value to the TC community.  Hope that the following will give content to may earlier questions

The script I have written uses the .cfg file as input to the script the intent is:
1 The script must run on TC out of the box (busybox and ash), I used RPi-64 install for this so far.
1 Only the .cfg file needs to be altered for creating an extension no need to alter the script.
2 The aim is to be able to create most binaries into .tcz with the accompanying files.
3 To easily create .tcz so that the repository will grow and therefore making TC a more valuable OS.

I have attached the script I'm working on, for a better understanding of what I'm trying to achieve.  Please note it works on RPi-64 no other testing has been done, this is a work in progress so beta if you like. If you or anyone else would like to assist, give feedback or test that would much appreciated.

Please note the file is from win .txt (notepad utf-8) and has end of line characters, still need to figure out how to  correct this any help appreciated :)
Cheers Rob

Offline Mypresus

  • Newbie
  • *
  • Posts: 24
Re: RPI-64 export flags
« Reply #17 on: December 13, 2021, 06:43:14 PM »
Hi Juanito,
Thank you for your reply.  As the current extension I'm working on is server/daemon the .cfg file and i presume in most daemon scenarios is that some files need to be available with an altering state (being able to be altered and preserved).  I believe that daemons may not or should not access home directories.  As my current understanding is that home files etc get backed up as compressed files within the tce/mydata.tgz on exit and therefor not available to daemons when loged out .
I understand that some programs can not or should not be run under ISO image (read only format), but under all other read/write formats the tce directory can or is created (such as in RPi-64 on SD card out of box).

Creating a .cfg file through creating a script could be done through tce.installed for ISO but that means recreating the ISO every time a .cfg file needs to be modified this is possible but maybe unpractical.

This then i believe leaves the only option for non read only formats a place somewhere under the tce directory. For read only formats I can see remastering/re-imaging as the only option.  I suppose what I'm asking is there a place for this situation or is the TC community willing to create a place for the daemon scenario?
Cheers Rob

Offline Mypresus

  • Newbie
  • *
  • Posts: 24
Re: RPI-64 export flags
« Reply #18 on: December 13, 2021, 07:12:49 PM »
Hi Rich,
Thank you for for the insight, is this is how you run scripts on login? I don't know if this will help with the daemon scenario as I presume you will still need to be logged in or need to create a .cfg from here to the tce/ directory when logging out.  By looking at the examples of the programs you have given, I believe they are all user based not server/deamon based, sorry still a newbie to Linux. 
Quote
Some programs when you run them will automatically create configuration files under the users ~/.config directory, such
as geany, gpicview, libreoffice, mc, wireshark, etc. Some will create hidden directories directly in the users
home directory, such as claws-mail, dillo, fifth, mozilla (Firefox), ssh, etc.

Some extensions conditionally create config directories/files through their tce.installed script, such as bash, grabber
and gtk3.

If you boot an ISO, there is no persistence, and I don't think a backup option is available either.
If Tinycore  is installed,  /home  and  /opt  are backed up when you use the  Exit  icon.
If Tinycore  is installed, and you have persistent  /home  and/or  /opt  directories, those directories should not be backed up.

Offline Mypresus

  • Newbie
  • *
  • Posts: 24
Re: RPI-64 export flags
« Reply #19 on: December 13, 2021, 07:23:51 PM »
Please ignore previous attachments these attachments should better.  Please also note there are no comments in the script if there is any interest I will document the script.  Oops sorry double .cfg attachments.

    [EDIT]: Removed duplicate attachment.  Rich
« Last Edit: December 13, 2021, 07:53:21 PM by Rich »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: RPI-64 export flags
« Reply #20 on: December 13, 2021, 08:07:43 PM »
Hi Mypresus
... Please note the file is from win .txt (notepad utf-8) and has end of line characters, still need to figure out how to  correct this any help appreciated :)
Try this:
Code: [Select]
dos2unix buid.cfg
When it comes to automatically starting programs, scripts, daemons, etc., the basic rules of thumb are:
1. Things that need to run before a GUI are started (like kmaps) should go into  /opt/bootsync.sh.
2. Things that need to run after a GUI are started (like starting a GUI app) should go into  ~/.X.d.
3. Things that are not sensitive to when they are started can go into  /opt/bootlocal.sh  which runs in the background.

When starting something from numbers 1 or 3, you need to specify a full path. They run before any user is logged in.

Item 2 is unique to each user.


Offline Mypresus

  • Newbie
  • *
  • Posts: 24
Re: RPI-64 export flags
« Reply #21 on: December 13, 2021, 10:50:50 PM »
Hi Rich,
Thank you for dos2unix buid.cfg will give this a try.

For creating extensions for the repository and locating .cfg files I think I have got it, lets see if I'm correct.

Don't write anything in the tce/ directory  structure such as tce/.config/sample unless for personal use.

Write a tce.installed script on tce-load -i sample.tcz (so everytime the program is run the link would be created else the .tcz would need to be recreated every time a change is made to the script) the scripted symlink is created either for the ~/.config or ~/.X.d for a .cfg file. The other option is to create a script in tce.installed to copy a .cfg file or run another script that will copy/create the .cfg from ~/.config or ~/.X.d to the place where the program will find it and if a change is made upload new .cfg or restart program or backup and reboot. The problem is any program commands used to alter a .cfg file is written to (RAM) and will not be saved unless a exit script is written to save the information to ~/.config/... or ~/.X.d/... before backup and exit.
 
When there is a change made to the .cfg, run the backup (this means a backup must be run on exit otherwise the .cfg changes will be lost).

The /opt/ files can be altered (but presumably not advised to do so) as a backup/restore will be performed on those files in mydata.tgz?

If the pc is rebooted say by power outage it must have an automated login (and Onboot entry) else the software is not started (or can a tce-load be done before login ?) and there will be no script as ~/.config will not be created.

The system should be single user sign in, the danger is if another user logs on, their .cfg file in that users ~/.config will be used.

Just a little note, there is no .config file in RPi-64 13.0.0 on a clean install is this an oversite or is the ~/.config being phased out? 

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: RPI-64 export flags
« Reply #22 on: December 14, 2021, 12:56:13 AM »
Hi Mypresus
When you make an extension, you create a directory structure to package, for example:
Code: [Select]
mkdir -p pkg/usr/local/bin
Code: [Select]
mkdir -p pkg/usr/local/etc/haproxyIt then gets packaged using  squashfs-tools.tcz:
Code: [Select]
mksquashfs pkg haproxy.tcz -noappendWhen  tce-load  installs the extension, it mounts it under  /tmp/tcloop/  and links the files to the  /usr/local  file system.
It then runs the  tce.installed  script if it exists.

Typically what you would do is place a default configuration file in:
Code: [Select]
pkg/usr/local/etc/haproxy/haproxy.cfgIf the location of the .cfg is hardcoded to /etc, have the tce.installed script create a link to  /usr/local/etc/haproxy.
If the end user wants to customize the  .cfg  file, they can make it editable by:
Code: [Select]
sudo busybox cp /usr/local/etc/haproxy/haproxy.cfg /usr/local/etc/haproxy/Then make their changes, add  usr/local/etc/haproxy/haproxy.cfg  to  /opt/.filetool.lst , and run a backup.

... When there is a change made to the .cfg, run the backup (this means a backup must be run on exit otherwise the .cfg changes will be lost). ...
Use the ControlPanel to call up the  Backup/Restore  application.

Quote
... The /opt/ files can be altered (but presumably not advised to do so) as a backup/restore will be performed on those files in mydata.tgz? ...
If something needs to be altered in  /opt/ , that should be mentioned in the  Comments:  section of the  .info  file.

Quote
... If the pc is rebooted say by power outage it must have an automated login ...
The default user is  tc  and is logged in automatically when booting.

Quote
... (and Onboot entry) else the software is not started (or can a tce-load be done before login ?) and there will be no script as ~/.config will not be created. ...
When the system boots, It checks the  tce  directory for  onboot.lst  and loads all of the extensions listed in there. It
then runs all of the  tce.installed  scripts.

Quote
... Just a little note, there is no .config file in RPi-64 13.0.0 on a clean install is this an oversite or is the ~/.config being phased out?
I don't think that directory gets created until something actually needs it.

    [EDIT]: Corrected path information in backup description.  Rich
« Last Edit: December 14, 2021, 10:30:02 AM by Rich »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694

Offline Mypresus

  • Newbie
  • *
  • Posts: 24
Re: RPI-64 export flags
« Reply #24 on: December 14, 2021, 01:44:35 AM »
Hi rich,
Thank you very much for your feedback, the penny just dropped, the missing link to my evolution  :) was not knowing the /opt/filetool.lst backup process so that changes can be saved. Now the pieces fit  :)

Quote
Typically what you would do is place a default configuration file in:
Code: [Select]
pkg/usr/local/etc/haproxy/haproxy.cfg
If the location of the .cfg is hardcoded to /etc, have the tce.installed script create a link to  /usr/local/etc/haproxy.
If the end user wants to customize the  .cfg  file, they can make it editable by:
Code: [Select]
sudo busybox cp /usr/local/etc/haproxy/haproxy.cfg /usr/local/etc/haproxy/
Then make their changes, add  /usr/local/etc/haproxy/haproxy.cfg  to  /opt/filetool.lst , and run a backup.

Now some simple editing and should be sorted.  :) Also just noticed you have different area for scripting in the forum so sorry for raising it here and will post scripting questions there in the future.  Cheers Rob

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: RPI-64 export flags
« Reply #25 on: December 14, 2021, 10:26:58 AM »
Hi Mypresus
Thank you very much for your feedback,  ...
You are welcome.

Quote
Typically what you would do is place a default configuration file in:

 ----- SNIP -----

add  /usr/local/etc/haproxy/haproxy.cfg  to  /opt/filetool.lst , and run a backup.
Correction, that should have said:
add  usr/local/etc/haproxy/haproxy.cfg  to  /opt/.filetool.lst , and run a backup.
Just wanted to mention that in case someone decides to make the changes manually rather than using the app.

Quote
... Also just noticed you have different area for scripting in the forum so sorry for raising it here ...
Since this was less of a scripting issue and more of a  "How Tinycore works"  issue I think it is fine over here.