1 |
On Sun, Apr 1, 2018 at 10:54 PM, <thelma@×××××××××××.com> wrote: |
2 |
> On 03/30/2018 11:10 AM, Bas Zoutendijk wrote: |
3 |
>> On Fri 30 Mar 2018 at 10:33:45 -0600, thelma@×××××××××××.com wrote: |
4 |
>>> |
5 |
>>> I'm using a scrip to log-in/boot strap the system over NFS |
6 |
>>> |
7 |
>>> ----- |
8 |
>>> #!/bin/sh |
9 |
>>> |
10 |
>>> HOST=${0##*/} |
11 |
>>> HOST=${HOST#*-} |
12 |
>>> ROOT=/mnt/${HOST} |
13 |
>>> ... |
14 |
>>> exec chroot '${ROOT}' /bin/bash -l |
15 |
>>> --- |
16 |
>>> |
17 |
>>> When I'm presented with bash prompt, it is the same as the one I logged |
18 |
>>> IN from. So to eliminate the confusion I would like to change (add to) |
19 |
>>> the bash prompt the "HOST' name I log-in to. |
20 |
>>> |
21 |
>>> When I log-in I'm presented with: "syscon3 #" |
22 |
>>> I would like it to be: ROOT+HOST |
23 |
>>> eg.: syscon3-eden |
24 |
>> |
25 |
>> To change the prompt you want to set $PS1. For example: |
26 |
>> |
27 |
>> echo 'export PS1="some string"; exec </dev/tty' | exec chroot $ROOT /bin/bash -i |
28 |
>> |
29 |
>> This command tells the Bash inside the chroot to first execute |
30 |
>> |
31 |
>> export PS1="some string" |
32 |
>> |
33 |
>> and then to continue as a regular log-in shell. The special syntax of |
34 |
>> the $PS1 string in described in the Bash man page. If you just want to |
35 |
>> prepend a string, you do not even have to bother with crafting a syntax: |
36 |
>> |
37 |
>> echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i |
38 |
> |
39 |
> The above syntax produced an error: |
40 |
> |
41 |
> chroot-eden: line 30: syntax error near unexpected token `(' |
42 |
> chroot-eden: line 30: `echo 'export PS1="(chroot '$HOST') $PS1"; exec <dev/tty' | exec chroot $ROOT /bin/bash -i' |
43 |
> |
44 |
> I've tried it without brackets "()" no effect. |
45 |
|
46 |
You have "dev/tty". It should be "/dev/tty". |
47 |
|
48 |
Also, I'd expect "'$HOST'" to print out "'hostname'" rather than |
49 |
"hostname". Is this what you want? |
50 |
|
51 |
This is a snippet from the default Debian bashrc. You have to edit |
52 |
"/etc/debian_chroot" and use a similar PS1 in the to-be-chrooted |
53 |
system for this to take effect. |
54 |
|
55 |
|
56 |
if [ -z "$debian_chroot" ]; then |
57 |
PS1h="\h" |
58 |
else |
59 |
PS1h="($debian_chroot)" |
60 |
fi |
61 |
|
62 |
# Set options depending on terminal type |
63 |
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then |
64 |
# The terminal supports colour: assume it complies with ECMA-48 |
65 |
# (ISO/IEC-6429). This is almost always the case... |
66 |
|
67 |
# Make ls(1) use colour in its listings |
68 |
if [ -x /usr/bin/dircolors ]; then |
69 |
alias ls="ls -v --color=auto" |
70 |
eval $(/usr/bin/dircolors --sh) |
71 |
fi |
72 |
|
73 |
# Set the terminal prompt |
74 |
if [ $(id -u) -ne 0 ]; then |
75 |
PS1="\[\e[42;30m\]\u@$PS1h\[\e[37m\]:\[\e[30m\]\w\[\e[0m\] \\\$ " |
76 |
else |
77 |
# Root user gets a nice RED prompt! |
78 |
PS1="\[\e[41;37;1m\]\u@$PS1h\[\e[30m\]:\[\e[37m\]\w\[\e[0m\] \\\$ " |
79 |
fi |
80 |
else |
81 |
# The terminal does not support colour |
82 |
PS1="\u@$PS1h:\w \\\$ " |