Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Selecting Runlevel at boot (good for laptops)
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
twiggy
n00b
n00b


Joined: 25 Nov 2003
Posts: 65
Location: Sweden

PostPosted: Tue Dec 23, 2003 4:21 pm    Post subject: Re: net.eth0 timeout Reply with quote

optilude wrote:
twiggy wrote:
Isn't there someway you can make net.eth0 timeout after 5seconds if the cable is not plugged in?
i used dhcpcd -t 5 before when i had slackware on my laptop. can i just edit net.eth0 to do that? 8O


The /etc/init.d/net.* scripts read the file /etc/conf.d/net. You can set dhcpcd options here by doing something like

Code:
dhcpcd_eth0="-t 5"


Martin


thank you! :wink:
_________________
Bite my shiny metal ass!
Back to top
View user's profile Send private message
k-dub
n00b
n00b


Joined: 18 Feb 2003
Posts: 67
Location: Frederick, CO

PostPosted: Wed Jan 07, 2004 7:45 pm    Post subject: Reply with quote

optilude wrote:
k-dub, how did you find quickswitch integrating with the gentoo boot scripts in /etc/init.d/net.*? I tried it briefly and got frustrated as it seemed to start dhcpcd etc. on its own accord.


I set quickswitch to replace the /etc/conf.d/net file and then restart the service. I had to try a few configurations before I understood what quickswitch was doing and what it was capable of, but I haven't needed to look elsewhere since.
Back to top
View user's profile Send private message
qeldroma
Guru
Guru


Joined: 17 Oct 2002
Posts: 370

PostPosted: Sun Jan 25, 2004 1:31 pm    Post subject: Reply with quote

Another, perhaps easier, way would be, to write a specific initrd-image.

You'ld just have to put some copies of inittab in it, then it can startup via rc-script in the initrd. The inittabs will then be copied over /etc/inittab in the rood-device.

This script includes a timeout for the default runlevel, or keypress for another.

Have no time in the moment to prove, but did similar things before, so it should do like this...
Back to top
View user's profile Send private message
yamakawa
Guru
Guru


Joined: 28 Jul 2003
Posts: 340

PostPosted: Tue Jan 27, 2004 6:48 pm    Post subject: Reply with quote

So uh what is the best? The scripts, quickswitch, or hprofile?
I am just to configure quickswitch after emerging it.
I already set /etc/conf.d/net stuff with dhcp timeout of 5 seconds. This works fine.
The trouble is to select proxy setting. At home I use proxy server of my main PC. At work the laptop is connected directly. To change the proxy setting of like various web browsers is just a pain in my ass!
I think quickswitch can handle this after some hard work.
Back to top
View user's profile Send private message
zojas
Veteran
Veteran


Joined: 22 Apr 2002
Posts: 1138
Location: Phoenix, AZ

PostPosted: Tue Jan 27, 2004 9:18 pm    Post subject: Reply with quote

I made a file called /etc/wpad.dat & set all my browsers to use a script to get the location of the proxy. then when I switch runlevels I change out the wpad.dat.

the file should contain code like this:

Code:

function FindProxyForURL(url, host)
{
  return "PROXY 192.168.0.4:3128; DIRECT";
}


that's for my squid proxy at home. at work it's just a different ip address.

then to set it to no proxy at all the wpad.dat should contain this:
Code:

function FindProxyForURL(url, host)
{
  return "DIRECT";
}


so I do the same old thing of having multiple files in /etc/ and copy the correct one to /etc/wpad.dat when switching runlevels. sometimes I have to close konqueror windows before the change is picked up but at least i don't have to log out.
_________________
http://www.desertsol.com/~kevin/ppc
Back to top
View user's profile Send private message
optilude
Apprentice
Apprentice


Joined: 29 May 2002
Posts: 248
Location: England

PostPosted: Wed Jan 28, 2004 1:33 pm    Post subject: Reply with quote

yamakawa wrote:
So uh what is the best? The scripts, quickswitch, or hprofile?


Well, I'm biased since I wrote hprofile (http://hprofile.sourceforge.net), but I do think that hprofile is quite a simple and elegant solution that gives you a lot of flexibility. Basically, you just provide alternate versions of any file you want switched and name them and place them in a directory that indicates which file to switch and which profile the file represents. You can also write simple scripts that will be run when a profile is applied or unloaded.

I much prefer this over mangling Gentoo rc scripts or startup code (which will be problematic when new versions of these come out and you have to upgrade, and you could end up unknowingly breaking something). I'm not entirely sure whether quickswitch is more or less powerful (since it takes quite a different approach), but with quickswitch you have to write a long(ish) configuration file and manage the locations of the alternate files yourself. With hprofile, you just place the file in a directory that logically mirrors its destination in the file system and give it a suffix indicating the profile name.

Another advantage is that hprofile comes with sample gentoo init scripts that I am actually using right now, so it's more "gentoo specific".

There is an ebuild in Bugzilla, but no-one appears to have done anything about it. :-(

The default install of hprofile is non-destructive (it won't do any damage to your system). I'd recommend you download it and play with it a bit. If you read the FAQ on hprofile.sourceforge.net, that should probably give you all the information you need to get started, and a more detailed manual is found in the README.

Let me know how you get on!

Martin
_________________
--
"Life is both a major and a minor key" -- Travis
Back to top
View user's profile Send private message
k-dub
n00b
n00b


Joined: 18 Feb 2003
Posts: 67
Location: Frederick, CO

PostPosted: Wed Jan 28, 2004 3:18 pm    Post subject: Reply with quote

optilude wrote:
I'm not entirely sure whether quickswitch is more or less powerful (since it takes quite a different approach), but with quickswitch you have to write a long(ish) configuration file and manage the locations of the alternate files yourself. With hprofile, you just place the file in a directory that logically mirrors its destination in the file system and give it a suffix indicating the profile name.


I haven't tried hprofile, but I feel you have a misconception about quickswitch. I use quickswitch and I have two PCMCIA "schemes" that I want to be able to switch between. My quickswitch config file is about 7 lines and allows me to put my alternate files wherever makes sense to me (to simplify backup scripts, for example). I contributed to this thread to let everyone know how to simply switch runlevels at boot time (softlevel=<runlevelname>). Since quickswitch also has boot time selection, this is how I choose to run.

I'm not saying hprofile is bad, but quickswitch suits me perfectly and I don't feel the need to learn yet another tool. The upside to this thread is letting everyone know all the wonderful options they have abailable.
Back to top
View user's profile Send private message
yamakawa
Guru
Guru


Joined: 28 Jul 2003
Posts: 340

PostPosted: Wed Jan 28, 2004 5:26 pm    Post subject: Reply with quote

Holy smoke! I emerged -p hprofile and only error msg came out.
So I ended up with using quickswitch, which I recently just installed.
The sample script seemed to me quite simple and understandable. I definitely needed this kind of tool for what they call "dynamic file switching" for various setting files. I made two profiles, put the file names of which I wanted to switch.
Code:
[Home]
dillo=/home/user/.dillo/dillorc.home
emerge=/etc/make.conf.home
[Work]
dillo=/home/user/.dillo/dillorc.work
emerge=/etc/make.conf.work

It seemed thus quite simple. However, at that moment, I did not make any copy of the original files, say /etc/make.conf and ~/.dillo/dillorc.
What happneded then was just a crap! When I hit "switchto Home", the original files are overwritten by soft links of the same names with no copies being made to where I directed in the config file! The original files were replaced with links and there were no destination for the links.
So I ended up with losing my well-maintained make.conf. Screw quickswitch. I should have read your comment earlier :cry:
So my big advice to noobs to quickswitch is BACK UP ALL THE FILES YOU WANTED TO SWITCH. Quickswitch does not take care of initial treatment for this. Take good care.

optilude wrote:

I'm not entirely sure whether quickswitch is more or less powerful (since it takes quite a different approach), but with quickswitch you have to write a long(ish) configuration file and manage the locations of the alternate files yourself. With hprofile, you just place the file in a directory that logically mirrors its destination in the file system and give it a suffix indicating the profile name.

Another advantage is that hprofile comes with sample gentoo init scripts that I am actually using right now, so it's more "gentoo specific".

There is an ebuild in Bugzilla, but no-one appears to have done anything about it. :-(

The default install of hprofile is non-destructive (it won't do any damage to your system). I'd recommend you download it and play with it a bit.
Martin
Back to top
View user's profile Send private message
optilude
Apprentice
Apprentice


Joined: 29 May 2002
Posts: 248
Location: England

PostPosted: Thu Jan 29, 2004 8:54 am    Post subject: Reply with quote

Quote:

I haven't tried hprofile, but I feel you have a misconception about quickswitch. I use quickswitch and I have two PCMCIA "schemes" that I want to be able to switch between. My quickswitch config file is about 7 lines and allows me to put my alternate files wherever makes sense to me (to simplify backup scripts, for example). I contributed to this thread to let everyone know how to simply switch runlevels at boot time (softlevel=<runlevelname>). Since quickswitch also has boot time selection, this is how I choose to run.


Well, I know this. But it's still a config file format to read and understand, and there were things I wanted to do with it that I didn't immediately understand. I think the approach of placing files in a directory mirroring the filesystem is much easier to manage than having to manually specify each one, especially when there are more than a handful of files to switch. I also think the hprofile way of running a single arbitrary script when a profile is applied or unloaded makes more sense than specifying commands from within a central configuration file. But that's just me - this is the beauty of open source! :-)

Bear in mind that I wrote hprofile before I discovered quickswitch, because hprofile is a general "profile selection" system (and started off being focused on "hardware profiles"). Quickswitch brands itself as specific(ish) to network profiles (although I understand it can go beyond that) so I never even looked at it.

yamakawa wrote:
Holy smoke! I emerged -p hprofile and only error msg came out.


That's strange. Could you pm me the error? It may be easier to get the tarball from [url]hprofile.sf.net[/url] and just install that - it comes with an install script that puts everything where it should be (and puts binaries in /usr/local/sbin, so it won't mess up portage's well-maintained /usr/sbin), with example profiles and a comprehensive manual in the README. Look at the FAQ on the website first - it should get you up and running quickly so you probably won't have to read the entire README.

Quote:
It seemed thus quite simple. However, at that moment, I did not make any copy of the original files, say /etc/make.conf and ~/.dillo/dillorc.
What happneded then was just a crap! When I hit "switchto Home", the original files are overwritten by soft links of the same names with no copies being made to where I directed in the config file!


Always make backups! :-) hprofile works on this principle, too (although you can tell it to make copies back and forth if you want, but it makes more sense to use symlinks, because that way if you update a file attached to a profile, your changes are overwritten the next time you apply the same or another profile. hprofile can work around this by copying files back, but it's still a bit risky). However, hprofile will always make a backup of a file before replacing it if that file didn't come from a profile it was managing.

As an aside, this was very easy to do in hprofile specifically because of the well-defined naming / placement scheme of files - hprofile can easily determine which files came from profiles and which ones did not, and will back files that would've been overwritten up to the profile directory with a ".bak" extension. (It only does this one generation, but it won't overwrite the backup unless it was actually going to replace another file that did *not* come from a profile).

Actually... this stuff is harder to explain than to work with. :-)

Martin
_________________
--
"Life is both a major and a minor key" -- Travis
Back to top
View user's profile Send private message
yamakawa
Guru
Guru


Joined: 28 Jul 2003
Posts: 340

PostPosted: Thu Jan 29, 2004 4:28 pm    Post subject: Reply with quote

optilude wrote:

yamakawa wrote:
Holy smoke! I emerged -p hprofile and only error msg came out.


That's strange. Could you pm me the error? It may be easier to get the tarball from [url]hprofile.sf.net[/url] and just install that - it comes with an install script that puts everything where it should be (and puts binaries in /usr/local/sbin, so it won't mess up portage's well-maintained /usr/sbin), with example profiles and a comprehensive manual in the README.

Martin


Sorry for messing you up with my short message. By this I meant, since I did not even install your ebuild, I got an error telling me that there was no ebuild of that name.
If only there had been the ebuild in my sync tree!
Since you are a hard working maintainer of the source, what do you say to make your ebuild gentoo official? :D
Back to top
View user's profile Send private message
optilude
Apprentice
Apprentice


Joined: 29 May 2002
Posts: 248
Location: England

PostPosted: Thu Jan 29, 2004 9:02 pm    Post subject: Reply with quote

Haha, sorry. :-)

I made the ebuild, and I want to maintain it, but if I understand how this stuff works, someone responsible for that app-admin part of portage will have to accept it from BugZilla.

For now, you can put it in /usr/local/portage/app-admin, (make sure PORTDIR_OVERLAY is set to /usr/local/portage in /etc/make.conf), run "ebuild /usr/local/portage/app-admin/hprofile/hprofile-2.0_beta2.ebuild digest" and then doing "emerge -p hprofile".

The ebuild does the following:

- Install hprofile, hprunlevel and hpdet in /usr/sbin
- Install hprofile startup scripts in /etc/init.d
- Put hprofile in list of critical startup services in /etc/runlevels/.critical (this is necessary so that hprofile can be started before things like "modules", which are likely to be influenced by the current profile. If you don't like this, or have no use for it, just delete that file - portage will fall back on a sensible default)
- Put example profiles and settings in /etc/hprofile
- Put docs in /usr/share/doc/hprofile-2.0_beta2
- Substitutes a few references in the startup files and configuration files that are necessary because the default hprofile install assumes things are put in /usr/local/sbin, not /usr/sbin

er... think that's it :-)

Martin
_________________
--
"Life is both a major and a minor key" -- Travis
Back to top
View user's profile Send private message
Zarhan
l33t
l33t


Joined: 27 Feb 2004
Posts: 996

PostPosted: Thu Apr 08, 2004 10:30 am    Post subject: Reply with quote

Is anybody going to integrate this into the main portage tree? I tried it out and it works great.
Back to top
View user's profile Send private message
BigBaaadBob
Guru
Guru


Joined: 19 Apr 2003
Posts: 342
Location: Swampscott, MA USA

PostPosted: Sun Apr 25, 2004 2:56 pm    Post subject: Reply with quote

Zarhan wrote:
Is anybody going to integrate this into the main portage tree? I tried it out and it works great.
Still not there. :cry:

I have another question. I have four hardware configs for my laptop: No network, in the docking station, using the wired Ethernet, and using the wireless Ethernet. In addition I have several environments: Home, work, hotel, etc. Do any of these tools support the concept of factoring these out so that I can say I want "wired ethernet at the hotel" or "Wireless ethernet at work", without having a setup for every permutation of hardware config and environment? I'm hoping for N + M configs rather than N * M.
Back to top
View user's profile Send private message
osti
n00b
n00b


Joined: 22 Nov 2017
Posts: 11

PostPosted: Wed Jul 24, 2019 8:08 am    Post subject: Re: Selecting Runlevel at boot (good for laptops) Reply with quote

Garbz wrote:
Basically with the help of an rc init script which is run at the boot runlevel it is possible to select which runlevel to start at boottime by passing cmdline options to the kernel. (also i've heard this is a bad way to do things, but hey it works.)


Thanks; I ran into this thread while thinking about the following:
Having (ordered) several raspberry pis for different network tasks, I'd like a "Master SD card" image (Gentoo, of course) pre-configured, dynamically configured during boot based on e.g. the eth0 ethernet address. My first
Code:
 /etc/init.d/setup-pi
(in runlevel boot) as a reference:

Code:

#!/sbin/openrc-run
# Copyright 2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

name="setup-pi daemon"
description="based on eth0 ether: set hostname, network config, runlevel configuration"

depend() {
   need localmount
}

start() {
   HW0="dc:a6:32:xx:xx:xx";
   HW1="dc:a6:32:yy:yy:yy";
   HW=$(cat /sys/class/net/eth0/address)
   ebegin "Setting up pi, ether address: $HW"

   ebegin "    hostname"
   case "$HW" in
      $HW0)
      rm /etc/conf.d/hostname && ln -s /etc/conf.d/hostname-rapsi0 /etc/conf.d/hostname ;;
      $HW1)
      rm /etc/conf.d/hostname && ln -s /etc/conf.d/hostname-rapsi1 /etc/conf.d/hostname ;;
      *)
      echo "UNKNOWN ETHERNET ADDRESS"
      false
      ;;
   esac
   eend $?

   ebegin "    network"
   case "$HW" in
      $HW0)
      rm /etc/conf.d/net && ln -s /etc/conf.d/net-rapsi0 /etc/conf.d/net ;;
      $HW1)
      rm /etc/conf.d/net && ln -s /etc/conf.d/net-rapsi1 /etc/conf.d/net ;;
      *)
      echo "UNKNOWN ETHERNET ADDRESS"
      false
      ;;
   esac
   eend $?

   ebegin "    runlevel"
   case "$HW" in
      $HW0)
      rm /etc/runlevels/default && ln -s /etc/runlevels/default-rapsi0 /etc/runlevels/default ;;
      $HW1)
      rm /etc/runlevels/default && ln -s /etc/runlevels/default-rapsi1 /etc/runlevels/default ;;
      *)
      echo "UNKNOWN ETHERNET ADDRESS"
      false
      ;;
   esac
   eend $?

   eend $?
}


Still a bit ugly during development / early testing; but it seems to work.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum