From: thelma@sys-concept.com
To: gentoo-user@lists.gentoo.org, Bas Zoutendijk <slzoutendijk@gmail.com>
Subject: Re: [gentoo-user] bash scrip prompt after bootstrap
Date: Mon, 2 Apr 2018 10:50:41 -0600 [thread overview]
Message-ID: <53f08c91-d11e-7639-463e-591f463318e8@sys-concept.com> (raw)
In-Reply-To: <20180402092907.GC7634@blackeye.localdomain>
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
next prev parent reply other threads:[~2018-04-02 16:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` thelma [this message]
2018-04-02 18:36 ` [gentoo-user] " Tom H
2018-04-02 20:40 ` Bas Zoutendijk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53f08c91-d11e-7639-463e-591f463318e8@sys-concept.com \
--to=thelma@sys-concept.com \
--cc=gentoo-user@lists.gentoo.org \
--cc=slzoutendijk@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox