WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Add profile=xyz Bootcode?  (Read 1782 times)

Offline helasz

  • Newbie
  • *
  • Posts: 36
Add profile=xyz Bootcode?
« on: September 19, 2012, 06:18:38 AM »
I would find it useful to have a bootcode like "profile=xyz" which should export $profile variable in order to use it for example in bootlocal.sh for differentiating general settings (most importantly network settings [ip,netmask,gateway,proxy,etc.]). In bootlocal a 'case "$profile" in ... esac' structure could handle the different settings.

Reason: I am preparing a bootable TC ISO image in order to use it in more than one OS environment as the bootmedia of a (portable) virtual machine (virtualbox). All the settings are the same except the network environment. I would void storing more than once almost the same mydata.tgz which contain several files (not neccessarily small ones).

[Alternatively tc-config script could (try to) export all the variables found among bootcodes in the form VARIABLE_NAME=xyz which do not match any existing bootcode of that form.]



Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Add profile=xyz Bootcode?
« Reply #1 on: September 19, 2012, 06:35:11 AM »
If you want to precess your own boot codes just read /proc/cmdline to get actual boot codes (as long as they are not conflicting with existing codes).
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Lee

  • Hero Member
  • *****
  • Posts: 645
    • My Core wiki user page
Re: Add profile=xyz Bootcode?
« Reply #2 on: September 19, 2012, 06:42:12 AM »
/etc/init.d/tc-functions defines a function called getbootpram which works nicely for this:
Code: [Select]
tc@apollo:~$ . /etc/init.d/tc-functions
tc@apollo:~$ getbootparam host
cruzr0
tc@apollo:~$
(my boot loader config includes the bootcode host=cruzr0)

Works just as well for my own home made boot codes, too.
32 bit core4.7.7, Xprogs, Xorg-7.6, wbar, jwm  |  - Testing -
PPR, data persistence through filetool.sh          |  32 bit core 8.0 alpha 1
USB Flash drive, one partition, ext2, grub4dos  | Otherwise similar

Offline helasz

  • Newbie
  • *
  • Posts: 36
Re: Add profile=xyz Bootcode?
« Reply #3 on: September 19, 2012, 08:55:10 AM »
Thanks for both replies. That works for me.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Add profile=xyz Bootcode?
« Reply #4 on: September 19, 2012, 09:23:35 AM »
Technically init does do that, but the variables only exist until login. Login clears the environment.

I'm not sure if that behavior is given in any standard though, so you should be better off using /proc/cmdline (via the getbootparam function or otherwise).


Bootlocal and -sync happen before login, so the variables are seen there:


Test command line was "quiet newcode=56".
But as mentioned, not sure how portable it is to rely on that behavior.

edit: Of course it has other downsides, like ignoring single words, and multiple bootcodes (blacklist=a blacklist=b).
« Last Edit: September 19, 2012, 09:26:54 AM by curaga »
The only barriers that can stop you are the ones you create yourself.