[opensuse-factory] chrooted factory question
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I often update factory while running my "stable" system by chrooting to it: mount /otros/test_d/ mount /otros/test_d/boot/ mount --bind /proc /otros/test_d/proc mount --bind /sys /otros/test_d/sys mount --bind /dev /otros/test_d/dev cp -f /etc/resolv.conf /otros/test_d/etc/resolv.conf chroot /otros/test_d/ Where "/otros/test_d/" is the partition where factory is. This works, I do a "zypper dup" and factory is updated. Fine :-) But there is a glitch: the prompt does not change: nimrodel:/ # I'd like to have a different prompt on that chrooted xterm, so that I don't confuse it with my "stable's" xterms. Is it possible? The command "hostname" returns "nimrodel", not the real name of factory (minas-morgul). I tried: nimrodel:/ # export HOSTNAME=minas-morgul hostname nimrodel:/ # which does not work. Anyway, I don't really need the hostname to change, the prompt would be enough. Do you know of a trick to do that? This is not strictly a "factory" question, but intend to use the trick for factory O:-) - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) iD8DBQFIhQpxtTMYHG2NR9URApAwAJ4zxYaZlyg1RdgXBSd0PU1Z55DUYACeKSPK 9WmMMExyLGAvVEl12ntKy8E= =Wux/ -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-factory+help@opensuse.org
Hello, Carlos E. R. írta:
I'd like to have a different prompt on that chrooted xterm, so that I don't confuse it with my "stable's" xterms. Is it possible? The command "hostname" returns "nimrodel", not the real name of factory (minas-morgul).
I tried:
nimrodel:/ # export HOSTNAME=minas-morgul hostname nimrodel:/ #
which does not work. Anyway, I don't really need the hostname to change, the prompt would be enough. The command prompt is set at the start of the shell, so a later host name change does not help here. But you can change the prompt later any time. The variable in question is PS1:
czanik@bigone:~> set | grep PS1 PS1='$(ppwd \l)\u@\h:\w> ' czanik@bigone:~> export PS1='$(ppwd \l)\u@unstable:\w> ' czanik@unstable:~> Your friend is 'man bash', and search for 'PROMPTING'. Bye, CzP --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-factory+help@opensuse.org
On Tue 22 Jul 2008 18:23:39 NZST +1200, Peter Czanik wrote: [chroot to mounted factory filesystem] I do this all the time too.
czanik@bigone:~> export PS1='$(ppwd \l)\u@unstable:\w> '
Yes. Your other problem is that the chroot subshell is not a login shell, so doesn't get properly initialised. Force it with chroot /... /bin/bash --login Volker -- Volker Kuhlmann is list0570 with the domain in header http://volker.dnsalias.net/ Please do not CC list postings to me. --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-factory+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Tuesday 2008-07-22 at 08:23 +0200, Peter Czanik wrote:
The command prompt is set at the start of the shell, so a later host name change does not help here. But you can change the prompt later any time. The variable in question is PS1:
czanik@bigone:~> set | grep PS1 PS1='$(ppwd \l)\u@\h:\w> ' czanik@bigone:~> export PS1='$(ppwd \l)\u@unstable:\w> ' czanik@unstable:~>
Your friend is 'man bash', and search for 'PROMPTING'.
Ah! Good. Tried that, worked, but lost the red color. So I found the original PS1 (10.3) and changed it thus: nimrodel:/ # export PS1=$'\\[\E[1m\E[31m\\]NOT_\\h:\\w # \\[\E(B\E[m\\]' NOT_nimrodel:/ # which is a good enough approximation to what I want, thanks. I wrote it as a comment in my script before the chroot command, because after it, it doesn't execute (and I don't want to change the profile or bashrc): echo echo " Copy paste the next line to activate prompt change:" echo "export PS1=$'\\[\E[1m\E[31m\\]NOT_\\h:\\w # \\[\E(B\E[m\\]'" echo chroot /otros/test_d/ /bin/bash --login So thanks, and thanks also to Volker for the "login" hint. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) iD8DBQFIhbNMtTMYHG2NR9URArF7AJwKxS51shTTel4NaMrCtCJUyH1nFACeIDrh DQR1rNyU46ySZm+5S2XkhMk= =NFZg -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-factory+help@opensuse.org
Hello, on Dienstag, 22. Juli 2008, Carlos E. R. wrote: ...
which is a good enough approximation to what I want, thanks. I wrote it as a comment in my script before the chroot command, because after it, it doesn't execute (and I don't want to change the profile or bashrc):
Well, if you put it after the chroot command, it is executed after the chroot _exits_. (You don't see the result because your script ends afterwards.)
echo " Copy paste the next line to activate prompt change:"
Ouch. This sounds annoying and error-prone (I'm quite sure you will forget to change the prompt some day...)
echo "export PS1=$'\\[\E[1m\E[31m\\]NOT_\\h:\\w # \\[\E(B\E[m\\]'" echo chroot /otros/test_d/ /bin/bash --login
Add the "export PS1" command to /etc/bash.bashrc.local in your factory installation ;-) (create the file if it doesn't exist already) Regards, Christian Boltz --
Currently you get a SUSE Linux box for 60 bugs with 1 DVD, 5 CDs, Although there are actually more bugs available for SUSE LINUX 10.0, as you can easily see at bugzilla So I have to pay 60 bugs to get 851 bugs. Sounds like a really good deal. :) [Martin Sommer and > Robert Schiele in opensuse]
To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-factory+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Tuesday 2008-07-22 at 13:18 +0200, Christian Boltz wrote:
Hello,
on Dienstag, 22. Juli 2008, Carlos E. R. wrote: ...
which is a good enough approximation to what I want, thanks. I wrote it as a comment in my script before the chroot command, because after it, it doesn't execute (and I don't want to change the profile or bashrc):
Well, if you put it after the chroot command, it is executed after the chroot _exits_. (You don't see the result because your script ends afterwards.)
Yes, I guessed so.
echo " Copy paste the next line to activate prompt change:"
Ouch. This sounds annoying and error-prone (I'm quite sure you will forget to change the prompt some day...)
I'm sure I will :-) But I'm using to copy-paste commands. I have a file with a list of my most used commands. I even keep a backup of the bash history file!
echo "export PS1=$'\\[\E[1m\E[31m\\]NOT_\\h:\\w # \\[\E(B\E[m\\]'" echo chroot /otros/test_d/ /bin/bash --login
Add the "export PS1" command to /etc/bash.bashrc.local in your factory installation ;-) (create the file if it doesn't exist already)
Ah, that would be better than on on root's home as I was thinking of doing. However, I don't want to see that prompt on the occasions that I do boot my real factory partition, so the copy-paste approach may have to do for the moment :-) Or I might try something with "expect" if I forget too often the copy paste thing. I doubt it, not worth the effort, I think. Maybe... feed a command to "bash --login" thing with an option not to exit? Dunno if possible :-? I'll have to read the man page again. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) iD8DBQFIhmqdtTMYHG2NR9URAhWyAJ99wj+lx0GHDE4GtkAgaaoAcAzxHQCfYt7G 3sSfrhV8yOkequhDtZoWI/8= =/X/g -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-factory+help@opensuse.org
Carlos E. R. wrote:
The Tuesday 2008-07-22 at 13:18 +0200, Christian Boltz wrote:
echo "export PS1=$'\\[\E[1m\E[31m\\]NOT_\\h:\\w # \\[\E(B\E[m\\]'" echo chroot /otros/test_d/ /bin/bash --login Add the "export PS1" command to /etc/bash.bashrc.local in your factory installation ;-) (create the file if it doesn't exist already)
Ah, that would be better than on on root's home as I was thinking of doing. However, I don't want to see that prompt on the occasions that I do boot my real factory partition, so the copy-paste approach may have to do for the moment :-)
You could try something like # stat -c '%d/%i' / /proc/1/root/ which should print two identical device/inode pairs a real root and two different in a chroot :-). tht, Michal --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-factory+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Wednesday 2008-07-23 at 14:03 +0200, Michal Marek wrote:
Add the "export PS1" command to /etc/bash.bashrc.local in your factory installation ;-) (create the file if it doesn't exist already)
Ah, that would be better than on on root's home as I was thinking of doing. However, I don't want to see that prompt on the occasions that I do boot my real factory partition, so the copy-paste approach may have to do for the moment :-)
You could try something like # stat -c '%d/%i' / /proc/1/root/ which should print two identical device/inode pairs a real root and two different in a chroot :-).
Cute! :-) I wrote "/etc/bash.bashrc.local": UNO=`stat -c '%d/%i' /` DOS=`stat -c '%d/%i' /proc/1/root/` if test $UNO != $DOS ; then export PS1=$'\[\E[1m\E[31m\](chroot)_\h:\w # \[\E(B\E[m\]' fi But it still need refinements; It works fine for root: NOT_nimrodel:/etc # su - (chroot)_nimrodel:~ # but not for a user (aside from the PS1 needing to be different): NOT_nimrodel:/etc # su - cer stat: cannot stat `/proc/1/root/': Permission denied - -bash: test: 5710/2: unary operator expected cer@nimrodel:~> I'd might add the stat command to sudoers, with no password. But it is getting complicated, even if I do I also need to detect if it is a user or root and change the PS1 differently. So, for the moment, I can leave it as: if test $UID = 0 ; then UNO=`stat -c '%d/%i' /` DOS=`stat -c '%d/%i' /proc/1/root/` if test $UNO != $DOS ; then export PS1=$'\[\E[1m\E[31m\](chroot)_\h:\w # \[\E(B\E[m\]' fi fi As normally I will not be using that chroot as a user. Still... - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) iD8DBQFIiEoTtTMYHG2NR9URAo7jAJwL93NJ6tfsn1oDfjg8ic8whhn+JwCdEv4B ViNGNBEOnU0Zx+RGUsTwcHs= =c7Ng -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-factory+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-factory+help@opensuse.org
participants (6)
-
Carlos E. R.
-
Carlos E. R.
-
Christian Boltz
-
Michal Marek
-
Peter Czanik
-
Volker Kuhlmann