Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (4) </ [1] 2 3 4 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Startup Configs, bootlocal, bash_profile, etc.< Next Oldest | Next Newest >
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Aug. 03 2005,18:47 QUOTE

Anything put in this thread (by me anyway) will assume that you have an understanding of the backup/restore process. You may also find that some (or many) posts will not be kept updated anywhere near as well as the DSL distro itself.  Some posts may in fact be useless by the time you read them =o)
----------

Set up Multiple Virtual Terminals
With Login Prompt


files used in this lesson:
/etc/inittab
/etc/shadow
/opt/bootlocal.sh
/.bash_profile
/home/dsl/.bash_profile

The default behavior in DSL is to automatically log in user dsl in runlevel 5 and automatically start X.  This is something I try to change immediately when setting up a new Linux system.
In runlevel 2 you have multiple terminals, but all are already logged in as root.  This is also something I care for not at all.

The ideal situation, in my opinion, is what is found by default in many distros:  When the boot process completes, you are presented with a login prompt.  Press Alt+F# and you're taken to another virtual terminal with another login prompt.

Here's what I did to get this in DSL...

First thing, if you want a login prompt to work, the system will first need to know what password to accept.  There are two ways I can think of to do this.  One is to set up your passwords before doing anything else, and then backup /etc/shadow.  The other is to boot with the "secure" boot option, setting up passwords when prompted each time you boot.  The former will give you a quicker boot time, since the passwords will automatically be set up next time you boot.  It also may be a bit more secure, as it can't be overridden by the "secure" boot option (unless the restore is disabled at the same time).../etc/shadow is restored *after* the passwords are set manually.

/etc/inittab:
change this
Code Sample
1:12345:respawn:/bin/bash -login >/dev/tty1 2>&1 </dev/tty1
2:234:respawn:/bin/bash -login >/dev/tty2 2>&1 </dev/tty2
3:234:respawn:/bin/bash -login >/dev/tty3 2>&1 </dev/tty3
4:234:respawn:/bin/bash -login >/dev/tty4 2>&1 </dev/tty4

to this
Code Sample
1:12345:respawn:/sbin/getty 38400 tty1
2:2345:respawn:/sbin/getty 38400 tty2
3:2345:respawn:/sbin/getty 38400 tty3
4:2345:respawn:/sbin/getty 38400 tty4

The first one respawns only once in runlevel 5 and uses bash, which basically just opens a new shell for the same user (root). The second one adds runlevel 5 to the other lines, and uses getty, so you get a "real" virtual terminal set up to accept an interactive login.
Since /etc/inittab is already read during the init process, before myDSL apps and backups are restored, The file will need to be read again before the user logs in.  This can be done in
/opt/bootlocal.sh:
Code Sample
telinit q

This rereads the /etc/inittab file so your restored file will work.

/home/dsl/.bash_profile automatically starts X when dsl logs in.  You probably won't want this or you will have a new X session started on every terminal you login to (or you'll get errors...not sure which will happen).  To fix this, remove the startx command from this file.  You will then need to type "startx" in order to start an X session.

/.bash_profile will automatically log in user dsl in runlevel 5 when you log in as root.  You probably don't want that either.  Remove the lines concerning "su dsl", or simply backup an empty version of this file.

Now you should be presented with 4 virtual terminals when you start DSL.  If you want more than 4, simply add more lines to /etc/inittab:
Code Sample
5:2345:respawn:/sbin/getty 38400 tty5
6:2345:respawn:/sbin/getty 38400 tty6
If you want fewer, remove lines starting with the last one.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Aug. 04 2005,02:47 QUOTE

Just About Anything Can Be Triggered With A Boot Option

Everything you enter at the boot prompt or through the bootloader is stored in a file called /proc/cmdline.  What this means for the user is that anything can be given at boot, regardless of whether it's built into DSL's boot scripts, and later be called up to trigger a command.  This is very handy if you want something done during the boot process which isn't a standard part of DSL.  A keyword can be entered at boot, and when /opt/bootlocal.sh runs just before login it could be scripted to search for that keyword, and react accordingly.

Here's a simple example....
Say you want to automatically run syslogd, but not necessary every time you boot up.  You could add the word "log" to your boot string, and then have /opt/bootlocal.sh check for that word:

Code Sample
if egrep -q " log" /proc/cmdline 2>/dev/null; then
chmod 644 /var/log/messages
syslogd
fi

The "chmod" command is optional...it just makes messages readable by regular users.

There are a couple of ways to set up boot options, and the file /etc/init.d/dsl-functions provides easy access to these methods.
You can check for a simple one-word boot option with the above egrep, or if you source dsl-functions in whatever script you use you can do it with "checkbootparam word", and you can check for a "word=something" with "getbootparam word" (getbootparam returns "something").


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
Deranged Offline





Group: Members
Posts: 6
Joined: Aug. 2005
Posted: Aug. 29 2005,18:05 QUOTE

Thanks. .bash_profile was what I was looking for, Now it logins how I want it. Thanks!
Back to top
Profile PM 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Sep. 19 2005,02:29 QUOTE

Pick One Of Several Window Managers To Start

There are several ways to specify which window manager to use when you start an X session.  Here are a few methods:

1) Edit $HOME/.xinitrc every time before running startx (not an appealing method).

2) Write an xinitrc file for each window manager (.xinitrc.twm, .xinitrc.fluxbox, etc.) and symlink .xinitrc to the one you want to run at a given time.  For example, if you want to start twm with this setup you could use something like this to start it:
Code Sample
ln -sf .xinitrc.twm .xinitrc && startx
This overwrites the current .xinitrc with a link to .xinitrc.twm. The startx command runs as usual,and xinit uses .xinitrc.twm as its config file.

3) Set up .xinitrc to start a window manager according to a parameter sent along with the startx command.  This apparently doesn't work with DSL's startx, so i won't go into how to do this.

4) Set up .xinitrc to start a window manager according to an environment variable.  You would need to export a variable ("wm", for example) with a keyword associated with a particular window manager, and then startx:
Code Sample
export wm=evilwm && startx
or
Code Sample
wm=evil startx

and .xinitrc would be set up to look for this variable before running the window manager. The following is from my current .xinitrc file, which works with the above command, and also works by using "wm=evil" in the bootloader's options.
Code Sample
CMDLINE=`cat /proc/cmdline`
. /etc/init.d/dsl-functions

if [ -n "$wm" ]; then
WINDOWMANAGER="$wm"
else
WINDOWMANAGER=`getbootparam wm`
fi

case $WINDOWMANAGER in
evil*)
root-tail --noinitial --font snap -f --color red4 --whole --cont ........ --cont-color black -g 512x384+4+0 \
${HOME}/WM.log,red4,'general' \
/var/log/messages,orange4,'messages' &
bsetbg -f $HOME/.fluxbox/backgrounds/thinklinux1024.jpg
WM=/opt/evilwm/evilwm
;;
wmi*)
WM=/opt/wmii/bin/wmii
;;
*dev|*devel)
WM=/opt/fluxbox_0.9.14/bin/fluxbox
wmix &>/dev/null &
monto &>/dev/null &
;;
*)
WM=fluxbox
wmix &>/dev/null &
monto &>/dev/null &
;;
esac

exec $WM &>$HOME/WM.log


EDIT: forgot to add the "CMDLINE" variable for getbootparam


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Sep. 19 2005,03:12 QUOTE

Use A Persitent Home And/Or Opt On The Same Partition As Root In Frugal

The current DSL init process fails to accept the 'home=' and 'opt=' boot options using the same partition as the KNOPPIX file system unless you use toram and frugal as well.  Personally I prefer not to use toram, particularly when working with multimedia applications. So I've come up with a workaround.

NOTE: This procedure runs from bootlocal, so it overwrites any home and opt files automatically restored from mydsl or backup.tar.gz.  Do not use it if you autoload other files to home and opt.

Step 1: Create /home/dsl and /opt directories on the partition containing KNOPPIX.  These directories should not initially be empty, or you'll lose a lot of functionality. What I did was copy the directories from my DSL ramdisk.

Step 2: Edit /opt/bootlocal.sh and back it up.  You can back it up using the backup/restore process, or create a myDSL extension for this file.  In addition to whatever other commands you want to run from bootlocal, you should also have the following:
Code Sample
rm -rf /{,ramdisk/}{home,opt}
mkdir /{home,opt}
mount --bind /cdrom/home /home
mount --bind /cdrom/opt /opt

What this will do is:
a) Remove /ramdisk/home, /ramdisk/opt, and the symlinks to these directories.
b) Create mountpoints for home and opt.
c) Mount the new home and opt.
If you want to do *only* home, it would look more like this:
Code Sample
rm -rf /{,ramdisk/}home
mkdir /home
mount --bind /cdrom/home /home

This assumes that /cdrom is the location of the frugal install.  I'm guessing that this is a standard location, but one should never assume =o)  You probably should make sure of the location of KNOPPIX as seen from within DSL before doing this.

Step 3: Reboot using the "frugal" boot option, and pointing either "mydsl=" or "restore=" to the location of your backup or mydsl extension containing the new bootlocal.  The frugal boot option is vital, since you will need to be able to write to /cdrom.

EDIT:  If you are anything like me you probably do a lot of editing and re-editing of files, and if bootlocal.sh is one of these files you may find it annoying to have to create a backup or mydsl package every time you make a change to bootlocal.sh...particularly when you have a persistent opt that would normally make it very simple to make and keep changes.  A way around this is to create a bootlocal.sh containing only the code above, followed by a command to run a second script (e.g. "exec /opt/bootlocal2.sh").  This way you can have all your other bootlocal stuff in an uncompressed, persistent script, making it easy to edit and forget it.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
18 replies since Aug. 03 2005,18:47 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (4) </ [1] 2 3 4 >/
reply to topic new topic new poll
Quick Reply: Startup Configs

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code