* [gentoo-user] bash scrip prompt after bootstrap @ 2018-03-30 16:33 thelma 2018-03-30 17:10 ` Bas Zoutendijk 0 siblings, 1 reply; 15+ messages in thread From: thelma @ 2018-03-30 16:33 UTC (permalink / raw To: Gentoo mailing list I'm using a scrip to log-in/boot strap the system over NFS ----- #!/bin/sh HOST=${0##*/} HOST=${HOST#*-} ROOT=/mnt/${HOST} ... exec chroot '${ROOT}' /bin/bash -l --- When I'm presented with bash prompt, it is the same as the one I logged IN from. So to eliminate the confusion I would like to change (add to) the bash prompt the "HOST' name I log-in to. When I log-in I'm presented with: "syscon3 #" I would like it to be: ROOT+HOST eg.: syscon3-eden -- Thelma ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [gentoo-user] bash scrip prompt after bootstrap 2018-03-30 16:33 [gentoo-user] bash scrip prompt after bootstrap thelma @ 2018-03-30 17:10 ` Bas Zoutendijk 2018-03-30 18:20 ` thelma 2018-04-02 2:54 ` thelma 0 siblings, 2 replies; 15+ messages in thread From: Bas Zoutendijk @ 2018-03-30 17:10 UTC (permalink / raw To: gentoo-user On Fri 30 Mar 2018 at 10:33:45 -0600, thelma@sys-concept.com wrote: > I'm using a scrip to log-in/boot strap the system over NFS > > ----- > #!/bin/sh > > HOST=${0##*/} > HOST=${HOST#*-} > ROOT=/mnt/${HOST} > ... > exec chroot '${ROOT}' /bin/bash -l > --- > > When I'm presented with bash prompt, it is the same as the one I logged > IN from. So to eliminate the confusion I would like to change (add to) > the bash prompt the "HOST' name I log-in to. > > When I log-in I'm presented with: "syscon3 #" > I would like it to be: ROOT+HOST > eg.: syscon3-eden To change the prompt you want to set $PS1. For example: echo 'export PS1="some string"; exec </dev/tty' | exec chroot $ROOT /bin/bash -i This command tells the Bash inside the chroot to first execute export PS1="some string" and then to continue as a regular log-in shell. The special syntax of the $PS1 string in described in the Bash man page. If you just want to prepend a string, you do not even have to bother with crafting a syntax: echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i Sincerely, Bas -- Sebastiaan L. Zoutendijk | slzoutendijk@gmail.com ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [gentoo-user] bash scrip prompt after bootstrap 2018-03-30 17:10 ` Bas Zoutendijk @ 2018-03-30 18:20 ` thelma 2018-04-02 2:54 ` thelma 1 sibling, 0 replies; 15+ messages in thread From: thelma @ 2018-03-30 18:20 UTC (permalink / raw To: gentoo-user, Bas Zoutendijk On 03/30/2018 11:10 AM, Bas Zoutendijk wrote: > On Fri 30 Mar 2018 at 10:33:45 -0600, thelma@sys-concept.com wrote: >> I'm using a scrip to log-in/boot strap the system over NFS >> >> ----- >> #!/bin/sh >> >> HOST=${0##*/} >> HOST=${HOST#*-} >> ROOT=/mnt/${HOST} >> ... >> exec chroot '${ROOT}' /bin/bash -l >> --- >> >> When I'm presented with bash prompt, it is the same as the one I logged >> IN from. So to eliminate the confusion I would like to change (add to) >> the bash prompt the "HOST' name I log-in to. >> >> When I log-in I'm presented with: "syscon3 #" >> I would like it to be: ROOT+HOST >> eg.: syscon3-eden > > To change the prompt you want to set $PS1. For example: > > echo 'export PS1="some string"; exec </dev/tty' | exec chroot $ROOT /bin/bash -i > > This command tells the Bash inside the chroot to first execute > > export PS1="some string" > > and then to continue as a regular log-in shell. The special syntax of > the $PS1 string in described in the Bash man page. If you just want to > prepend a string, you do not even have to bother with crafting a syntax: > > echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i > > Sincerely, > > Bas Thank you for the input. I'll try it as soon as my box finished compiling (-e @world), and post the complete script; to boot strap over NFS (it might help others). This method of compiling give some of my old (obsolete) system new lease of life. I've dusted off my retired (it hasn't been updated in over 250-days): VIA Eden Processor 1200MHz 1GB of RAM (was running asterisk, hylafax) and updating it over NFS. gcc-6.4.0-r1 took only 1:39hr to compile over NFS on: AMD Ryzen 5 1400 Quad-Core Processor 16GB or RAM When I was switching to a new profile on my another system (in production) Intel(R) Atom(TM) CPU 330 @ 1.60GHz 2GB or RAM and gcc-6.4.0-r1 with MAKEOPTS="-j5" would not compile; I had to downgraded recompile gcc with MAKEOPTS="-j1" gcc-6.4.0-r1 with MAKEOPTS="-j5" was running for over 6hr and failed;with MAKEOPTS="-j1" it took over 12hr to compile just gcc-6.4.0-r1 :-/ What a wast of time! considering that on that network I have AMD 8-core with 32GB of RAM idling. If I implemented that bootstrap over NFS it would recompile my entire @world in 1 days (or 12hr) instead of several several days. Happy Easter to everybody! -- Thelma ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [gentoo-user] bash scrip prompt after bootstrap 2018-03-30 17:10 ` Bas Zoutendijk 2018-03-30 18:20 ` thelma @ 2018-04-02 2:54 ` thelma 2018-04-02 8:00 ` Bas Zoutendijk ` (2 more replies) 1 sibling, 3 replies; 15+ messages in thread From: thelma @ 2018-04-02 2:54 UTC (permalink / raw To: gentoo-user, Bas Zoutendijk On 03/30/2018 11:10 AM, Bas Zoutendijk wrote: > On Fri 30 Mar 2018 at 10:33:45 -0600, thelma@sys-concept.com wrote: >> I'm using a scrip to log-in/boot strap the system over NFS >> >> ----- >> #!/bin/sh >> >> HOST=${0##*/} >> HOST=${HOST#*-} >> ROOT=/mnt/${HOST} >> ... >> exec chroot '${ROOT}' /bin/bash -l >> --- >> >> When I'm presented with bash prompt, it is the same as the one I logged >> IN from. So to eliminate the confusion I would like to change (add to) >> the bash prompt the "HOST' name I log-in to. >> >> When I log-in I'm presented with: "syscon3 #" >> I would like it to be: ROOT+HOST >> eg.: syscon3-eden > > To change the prompt you want to set $PS1. For example: > > echo 'export PS1="some string"; exec </dev/tty' | exec chroot $ROOT /bin/bash -i > > This command tells the Bash inside the chroot to first execute > > export PS1="some string" > > and then to continue as a regular log-in shell. The special syntax of > the $PS1 string in described in the Bash man page. If you just want to > prepend a string, you do not even have to bother with crafting a syntax: > > echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i > > Sincerely, > > Bas The above syntax produced an error: chroot-eden: line 30: syntax error near unexpected token `(' chroot-eden: line 30: `echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i' I've tried it without brackets "()" no effect. -- Thelma ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [gentoo-user] bash scrip prompt after bootstrap 2018-04-02 2:54 ` thelma @ 2018-04-02 8:00 ` Bas Zoutendijk 2018-04-02 8:25 ` David Haller 2018-04-02 18:36 ` Tom H 2 siblings, 0 replies; 15+ messages in thread From: Bas Zoutendijk @ 2018-04-02 8:00 UTC (permalink / raw To: gentoo-user On Sun 1 Apr 2018 at 20:54:13 -0600, thelma@sys-concept.com wrote: > The above syntax produced an error: > > chroot-eden: line 30: syntax error near unexpected token `(' > chroot-eden: line 30: `echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i' > > I've tried it without brackets "()" no effect. Strange, I get no error when I run the exact same command. Can you find out which part of the command is causing it, by process of elimination? Sincerely, Bas -- Sebastiaan L. Zoutendijk | slzoutendijk@gmail.com ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [gentoo-user] bash scrip prompt after bootstrap 2018-04-02 2:54 ` thelma 2018-04-02 8:00 ` Bas Zoutendijk @ 2018-04-02 8:25 ` David Haller 2018-04-02 9:29 ` Bas Zoutendijk 2018-04-02 18:36 ` Tom H 2 siblings, 1 reply; 15+ messages in thread From: David Haller @ 2018-04-02 8:25 UTC (permalink / raw To: gentoo-user Hello, On Sun, 01 Apr 2018, thelma@sys-concept.com wrote: >On 03/30/2018 11:10 AM, Bas Zoutendijk wrote: [..] >> echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i >The above syntax produced an error: > >chroot-eden: line 30: syntax error near unexpected token `(' >chroot-eden: line 30: `echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i' You owe me a dollar! export PS1="$(chroot '$HOST') $PS1"; ^ HTH, -dnh -- Don't Panic ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [gentoo-user] bash scrip prompt after bootstrap 2018-04-02 8:25 ` David Haller @ 2018-04-02 9:29 ` Bas Zoutendijk 2018-04-02 15:14 ` [gentoo-user] " Ian Zimmerman 2018-04-02 16:50 ` [gentoo-user] " thelma 0 siblings, 2 replies; 15+ messages in thread From: Bas Zoutendijk @ 2018-04-02 9:29 UTC (permalink / raw To: gentoo-user On Mon 2 Apr 2018 at 10:25:45 +0200, David Haller wrote: > You owe me a dollar! > > export PS1="$(chroot '$HOST') $PS1"; > ^ The text within the parentheses was meant as literal text, the chroot command is executed rightward of the pipe. I could just as well write echo 'export PS1="You have chrooted into '$HOST' from $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i No dollars necessary. Sincerely, Bas -- Sebastiaan L. Zoutendijk | slzoutendijk@gmail.com ^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-user] Re: bash scrip prompt after bootstrap 2018-04-02 9:29 ` Bas Zoutendijk @ 2018-04-02 15:14 ` Ian Zimmerman 2018-04-02 15:55 ` Bas Zoutendijk 2018-04-02 16:50 ` [gentoo-user] " thelma 1 sibling, 1 reply; 15+ messages in thread From: Ian Zimmerman @ 2018-04-02 15:14 UTC (permalink / raw To: gentoo-user On 2018-04-02 11:29, Bas Zoutendijk wrote: > echo 'export PS1="You have chrooted into '$HOST' from $PS1"; exec \ > <dev/tty' | exec chroot $ROOT /bin/bash -i This pipe is something of a Rube Goldberg device. Why not pass the variable directly: chroot $ROOT /usr/bin/env PS1="(chrooted to $HOST) $PS1" bash In fact I think I see a problem with your way: the chrooted shell sees a command like export PS1=You have chrooted into 'eden' from root which obviously cannot work. (No clue if that is why it breaks for Thelma, and no clue why it works for you :P) -- Please don't Cc: me privately on mailing lists and Usenet, if you also post the followup to the list or newsgroup. To reply privately _only_ on Usenet and on broken lists which rewrite From, fetch the TXT record for no-use.mooo.com. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [gentoo-user] Re: bash scrip prompt after bootstrap 2018-04-02 15:14 ` [gentoo-user] " Ian Zimmerman @ 2018-04-02 15:55 ` Bas Zoutendijk 2018-04-02 16:25 ` Ian Zimmerman 0 siblings, 1 reply; 15+ messages in thread From: Bas Zoutendijk @ 2018-04-02 15:55 UTC (permalink / raw To: gentoo-user On Mon 2 Apr 2018 at 08:14:40 -0700, Ian Zimmerman wrote: > This pipe is something of a Rube Goldberg device. Why not pass the > variable directly: > > chroot $ROOT /usr/bin/env PS1="(chrooted to $HOST) $PS1" bash That is of course a lot more elegant, I must have been half-asleep when I wrote that pipe the first time. > In fact I think I see a problem with your way: the chrooted shell sees a > command like > > export PS1=You have chrooted into 'eden' from root > > which obviously cannot work. (No clue if that is why it breaks for > Thelma, and no clue why it works for you :P) What my syntax is doing is to let the $PS1 inside the PS1 definition be evaluated by the chroot shell. Suppose you run this command with HOST=eden and ROOT=/mnt/eden: echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i The parent shell will translate this into echo 'export PS1="(chroot 'eden') $PS1"; exec </dev/tty' | exec chroot /mnt/eden /bin/bash -i This is where the purpose of the 's around $HOST shows: $HOST is outside the single quotes, so gets substituted, while the rest of the string, notably $PS1, remains the same. The child shell will therefore receive input export PS1="(chroot eden) $PS1"; exec </dev/tty which will prepend the desired text to the child shell’s prompt. But indeed why bother if the $PS1 of the parent shell will do just as well? -- Sebastiaan L. Zoutendijk | slzoutendijk@gmail.com ^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-user] Re: bash scrip prompt after bootstrap 2018-04-02 15:55 ` Bas Zoutendijk @ 2018-04-02 16:25 ` Ian Zimmerman 2018-04-02 17:18 ` Bas Zoutendijk 0 siblings, 1 reply; 15+ messages in thread From: Ian Zimmerman @ 2018-04-02 16:25 UTC (permalink / raw To: gentoo-user On 2018-04-02 17:55, Bas Zoutendijk wrote: > What my syntax is doing is to let the $PS1 inside the PS1 definition > be evaluated by the chroot shell. Suppose you run this command with > HOST=eden and ROOT=/mnt/eden: > > echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i > > The parent shell will translate this into > > echo 'export PS1="(chroot 'eden') $PS1"; exec </dev/tty' | exec chroot /mnt/eden /bin/bash -i > > This is where the purpose of the 's around $HOST shows: $HOST is > outside the single quotes, so gets substituted, while the rest of the > string, notably $PS1, remains the same. The child shell will > therefore receive input > > export PS1="(chroot eden) $PS1"; exec </dev/tty > > which will prepend the desired text to the child shell’s prompt. Ah, this is a comedy of errors. You've missed my intended point, which was wrong; but now I see the real problem. I missed the outermost single quotes in your echo command, so I thought the parent shell would strip the double quotes and then the child shell would see unquoted whitespace on the right side of the export. But the real problem is that quotes (either kind by itself or mixed) do not nest. So the first single quote will be paired with the one before $HOST and terminated by it; and the double quote after = will remain unbalanced and unterminated. > Sebastiaan L. Zoutendijk | slzoutendijk@gmail.com And now I learn, at last, that Bas is the Dutch nickname for Sebastiaan. Thanks for that ;-) -- Please don't Cc: me privately on mailing lists and Usenet, if you also post the followup to the list or newsgroup. To reply privately _only_ on Usenet and on broken lists which rewrite From, fetch the TXT record for no-use.mooo.com. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [gentoo-user] Re: bash scrip prompt after bootstrap 2018-04-02 16:25 ` Ian Zimmerman @ 2018-04-02 17:18 ` Bas Zoutendijk 2018-04-02 18:40 ` Ian Zimmerman 0 siblings, 1 reply; 15+ messages in thread From: Bas Zoutendijk @ 2018-04-02 17:18 UTC (permalink / raw To: gentoo-user On Mon 2 Apr 2018 at 09:25:57 -0700, Ian Zimmerman wrote: > Ah, this is a comedy of errors. You've missed my intended point, which > was wrong; but now I see the real problem. > > I missed the outermost single quotes in your echo command, so I thought > the parent shell would strip the double quotes and then the child shell > would see unquoted whitespace on the right side of the export. All of this because of one Rube Goldberg device ... At least we are converging to understanding each other. > But the real problem is that quotes (either kind by itself or mixed) do > not nest. So the first single quote will be paired with the one before > $HOST and terminated by it; and the double quote after = will remain > unbalanced and unterminated. That is exactly what I meant to do, and I admit it is rather kludgey. Because of the single quotes, which are around everything but $HOST, the double quotes are literally echoed. The child shell will therefore see the PS1 definition surrounded by double quotes. The echo part should be equivalent to this, which may be clearer: echo "export PS1=\"(chroot $HOST) \$PS1\"; exec <dev/tty" For the record, my original Goldberg device works for me. /How/ it works is another question, on which we will hopefully reach consensus at some point. <ot> > And now I learn, at last, that Bas is the Dutch nickname for Sebastiaan. > Thanks for that ;-) There is also Bastiaan and Sebas. Note that a short form can also be someone’s official given name, and that ‘nicknames’ are more formal in Dutch than in most languages. Many nicknames are given at birth and used in both formal and informal social situations. Calling someone by a different nickname or their full name might not be appreciated. Not everyone has a nickname. Not every Bas is a Sebastiaan and not every Sebastiaan is a Bas. </ot> Sincerely, Bas -- Sebastiaan L. Zoutendijk | slzoutendijk@gmail.com ^ permalink raw reply [flat|nested] 15+ messages in thread
* [gentoo-user] Re: bash scrip prompt after bootstrap 2018-04-02 17:18 ` Bas Zoutendijk @ 2018-04-02 18:40 ` Ian Zimmerman 0 siblings, 0 replies; 15+ messages in thread From: Ian Zimmerman @ 2018-04-02 18:40 UTC (permalink / raw To: gentoo-user On 2018-04-02 19:18, Bas Zoutendijk wrote: > That is exactly what I meant to do, and I admit it is rather kludgey. > Because of the single quotes, which are around everything but $HOST, > the double quotes are literally echoed. The child shell will > therefore see the PS1 definition surrounded by double quotes. The > echo part should be equivalent to this, which may be clearer: > > echo "export PS1=\"(chroot $HOST) \$PS1\"; exec <dev/tty" > > For the record, my original Goldberg device works for me. /How/ it > works is another question, on which we will hopefully reach consensus > at some point. I see. Color me stumped; your solution should work. -- Please don't Cc: me privately on mailing lists and Usenet, if you also post the followup to the list or newsgroup. To reply privately _only_ on Usenet and on broken lists which rewrite From, fetch the TXT record for no-use.mooo.com. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [gentoo-user] bash scrip prompt after bootstrap 2018-04-02 9:29 ` Bas Zoutendijk 2018-04-02 15:14 ` [gentoo-user] " Ian Zimmerman @ 2018-04-02 16:50 ` thelma 1 sibling, 0 replies; 15+ messages in thread From: thelma @ 2018-04-02 16:50 UTC (permalink / raw To: gentoo-user, Bas Zoutendijk On 04/02/2018 03:29 AM, Bas Zoutendijk wrote: > On Mon 2 Apr 2018 at 10:25:45 +0200, David Haller wrote: >> You owe me a dollar! >> >> export PS1="$(chroot '$HOST') $PS1"; >> ^ > > The text within the parentheses was meant as literal text, the chroot > command is executed rightward of the pipe. I could just as well write > > echo 'export PS1="You have chrooted into '$HOST' from $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i > > No dollars necessary. > > Sincerely, > > Bas > Here is original script, to boot-strap computer over nfs (it WORKS!) ---------- #!/bin/sh set -x HOST=${0##*/} HOST=${HOST#*-} ROOT=/mnt/${HOST} PS1="${HOST}" mkdir -p --mode=0755 "${ROOT}" #env -i - HOME="/root" TERM="${TERM}" exec sudo unshare -m /bin/sh -c " exec sudo unshare -m /bin/sh -c " set -e mount -t nfs -o rw,noatime,nocto,actimeo=60,lookupcache=positive,vers=4,fsc '${HOST}:/' '${ROOT}' mount --bind {,'${ROOT}'}/dev mount --bind {,'${ROOT}'}/dev/pts mount --bind {,'${ROOT}'}/dev/shm mount --bind {,'${ROOT}'}/proc mount --bind {,'${ROOT}'}/sys mount --bind {,'${ROOT}'}/usr/local/portage mount --bind {,'${ROOT}'}/usr/portage mount --bind {,'${ROOT}'}/var/cache/edb/dep mount --bind {,'${ROOT}'}/var/tmp/portage exec chroot '${ROOT}' /bin/bash -i env-update source /etc/profile " -------------------- The above script works when I run chroot-eden - which is a just a link to chroot.sh Not sure if these two lines are needed, but it works with or without them: env-update source /etc/profile ---result----- syscon3 /home/thelma # sh chroot-eden + HOST=chroot-eden + HOST=eden + ROOT=/mnt/eden + PS1=eden + mkdir -p --mode=0755 /mnt/eden + exec sudo unshare -m /bin/sh -c ' set -e mount -t nfs -o rw,noatime,nocto,actimeo=60,lookupcache=positive,vers=4,fsc '\''eden:/'\'' '\''/mnt/eden'\'' mount --bind {,'\''/mnt/eden'\''}/dev mount --bind {,'\''/mnt/eden'\''}/dev/pts mount --bind {,'\''/mnt/eden'\''}/dev/shm mount --bind {,'\''/mnt/eden'\''}/proc mount --bind {,'\''/mnt/eden'\''}/sys mount --bind {,'\''/mnt/eden'\''}/usr/local/portage mount --bind {,'\''/mnt/eden'\''}/usr/portage mount --bind {,'\''/mnt/eden'\''}/var/cache/edb/dep mount --bind {,'\''/mnt/eden'\''}/var/tmp/portage exec chroot '\''/mnt/eden'\'' /bin/bash -i env-update source /etc/profile ' syscon3 / # ----end result---- The above execution shows that "PS1=eden" but the prompt shows: "syscon3 / #" (not eden). I've tried the below lines they don't work, I get a syntax error: 1.) echo 'export PS1="$(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i + HOST=chroot-eden + HOST=eden + ROOT=/mnt/eden + PS1=eden + mkdir -p --mode=0755 /mnt/eden chroot-eden: line 31: syntax error near unexpected token `(' chroot-eden: line 31: `# echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i' 2.) echo 'export PS1="You have chrooted into '$HOST' from $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i + HOST=chroot-eden + HOST=eden + ROOT=/mnt/eden + PS1=eden + mkdir -p --mode=0755 /mnt/eden chroot-eden: line 31: syntax error near unexpected token `(' chroot-eden: line 31: `# echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i' 3.) echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i + HOST=chroot-eden + HOST=eden + ROOT=/mnt/eden + PS1=eden + mkdir -p --mode=0755 /mnt/eden chroot-eden: line 31: syntax error near unexpected token `(' chroot-eden: line 31: ` echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i' -- Thelma ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [gentoo-user] bash scrip prompt after bootstrap 2018-04-02 2:54 ` thelma 2018-04-02 8:00 ` Bas Zoutendijk 2018-04-02 8:25 ` David Haller @ 2018-04-02 18:36 ` Tom H 2018-04-02 20:40 ` Bas Zoutendijk 2 siblings, 1 reply; 15+ messages in thread From: Tom H @ 2018-04-02 18:36 UTC (permalink / raw To: Gentoo User On Sun, Apr 1, 2018 at 10:54 PM, <thelma@sys-concept.com> wrote: > On 03/30/2018 11:10 AM, Bas Zoutendijk wrote: >> On Fri 30 Mar 2018 at 10:33:45 -0600, thelma@sys-concept.com wrote: >>> >>> I'm using a scrip to log-in/boot strap the system over NFS >>> >>> ----- >>> #!/bin/sh >>> >>> HOST=${0##*/} >>> HOST=${HOST#*-} >>> ROOT=/mnt/${HOST} >>> ... >>> exec chroot '${ROOT}' /bin/bash -l >>> --- >>> >>> When I'm presented with bash prompt, it is the same as the one I logged >>> IN from. So to eliminate the confusion I would like to change (add to) >>> the bash prompt the "HOST' name I log-in to. >>> >>> When I log-in I'm presented with: "syscon3 #" >>> I would like it to be: ROOT+HOST >>> eg.: syscon3-eden >> >> To change the prompt you want to set $PS1. For example: >> >> echo 'export PS1="some string"; exec </dev/tty' | exec chroot $ROOT /bin/bash -i >> >> This command tells the Bash inside the chroot to first execute >> >> export PS1="some string" >> >> and then to continue as a regular log-in shell. The special syntax of >> the $PS1 string in described in the Bash man page. If you just want to >> prepend a string, you do not even have to bother with crafting a syntax: >> >> echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i > > The above syntax produced an error: > > chroot-eden: line 30: syntax error near unexpected token `(' > chroot-eden: line 30: `echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i' > > I've tried it without brackets "()" no effect. You have "dev/tty". It should be "/dev/tty". Also, I'd expect "'$HOST'" to print out "'hostname'" rather than "hostname". Is this what you want? This is a snippet from the default Debian bashrc. You have to edit "/etc/debian_chroot" and use a similar PS1 in the to-be-chrooted system for this to take effect. if [ -z "$debian_chroot" ]; then PS1h="\h" else PS1h="($debian_chroot)" fi # Set options depending on terminal type if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then # The terminal supports colour: assume it complies with ECMA-48 # (ISO/IEC-6429). This is almost always the case... # Make ls(1) use colour in its listings if [ -x /usr/bin/dircolors ]; then alias ls="ls -v --color=auto" eval $(/usr/bin/dircolors --sh) fi # Set the terminal prompt if [ $(id -u) -ne 0 ]; then PS1="\[\e[42;30m\]\u@$PS1h\[\e[37m\]:\[\e[30m\]\w\[\e[0m\] \\\$ " else # Root user gets a nice RED prompt! PS1="\[\e[41;37;1m\]\u@$PS1h\[\e[30m\]:\[\e[37m\]\w\[\e[0m\] \\\$ " fi else # The terminal does not support colour PS1="\u@$PS1h:\w \\\$ " ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [gentoo-user] bash scrip prompt after bootstrap 2018-04-02 18:36 ` Tom H @ 2018-04-02 20:40 ` Bas Zoutendijk 0 siblings, 0 replies; 15+ messages in thread From: Bas Zoutendijk @ 2018-04-02 20:40 UTC (permalink / raw To: gentoo-user On Mon 2 Apr 2018 at 14:36:00 -0400, Tom H wrote: > You have "dev/tty". It should be "/dev/tty". Thank you for catching that typo, I lost the slash somewhere between the first and second syntax. In my case it was harmless, because I chrooted into a filesystem root, such that dev/tty == /dev/tty, and I do not see how this is related to Thelma’s error messages. Thelma, I suggest you use Ian’s solution, it is much simpler than mine. If you want we can continue looking why my solution does not work for you. Sincerely, Bas -- Sebastiaan L. Zoutendijk | slzoutendijk@gmail.com ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2018-04-02 20:40 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-03-30 16:33 [gentoo-user] bash scrip prompt after bootstrap thelma 2018-03-30 17:10 ` Bas Zoutendijk 2018-03-30 18:20 ` thelma 2018-04-02 2:54 ` thelma 2018-04-02 8:00 ` Bas Zoutendijk 2018-04-02 8:25 ` David Haller 2018-04-02 9:29 ` Bas Zoutendijk 2018-04-02 15:14 ` [gentoo-user] " Ian Zimmerman 2018-04-02 15:55 ` Bas Zoutendijk 2018-04-02 16:25 ` Ian Zimmerman 2018-04-02 17:18 ` Bas Zoutendijk 2018-04-02 18:40 ` Ian Zimmerman 2018-04-02 16:50 ` [gentoo-user] " thelma 2018-04-02 18:36 ` Tom H 2018-04-02 20:40 ` Bas Zoutendijk
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox