tools: nm-in-vm: fix motd

Message of the day was shown twice because the same bashrc.my file than
for containers was used. That file contained some code to show motd in
the container, where it is not shown by default. But in the VM, the motd
is shown by default, so it was shown twice.

Move the code to show motd to a file used only by nm-in-container and
not by nm-in-vm.

Also, modify the explanation about using prepare-for-system.sh because
it's only valid for Fedora but nm-in-vm can be used with other SOs too.
This commit is contained in:
Íñigo Huguet 2023-08-31 11:21:12 +02:00
parent c8a329bc12
commit 0ec71289ed
4 changed files with 10 additions and 8 deletions

View file

@ -0,0 +1,4 @@
if test "$SHOW_MOTD" != 0; then
cat /etc/motd
export SHOW_MOTD=0
fi

View file

@ -41,8 +41,3 @@ nm_run_normal() {
. /usr/share/git-core/contrib/completion/git-prompt.sh
PS1="\[\033[01;36m\]\u@\h\[\033[00m\]:\t:\[\033[01;34m\]\w\$(__git_ps1 \" \[\033[01;36m\](%s)\[\033[00m\]\")\[\033[00m\]$ "
export GIT_PS1_SHOWDIRTYSTATE=1
if test "$SHOW_MOTD" != 0; then
cat /etc/motd
export SHOW_MOTD=0
fi

View file

@ -55,7 +55,7 @@ For example, configure NetworkManager with
Test with:
$ systemctl stop NetworkManager; /opt/test/sbin/NetworkManager --debug 2>&1 | tee -a /tmp/nm-log.txt
Or better, configure with `contrib/fedora/rpm/configure-for-system.sh`,
Or better, if using Fedora, configure with `contrib/fedora/rpm/configure-for-system.sh`,
subsequent `make && make install` will overwrite your system's NetworkManager,
and you can test it with `systemctl daemon-reload ; systemctl restart NetworkManager`.

View file

@ -131,8 +131,9 @@ create_dockerfile() {
local CONTAINERFILE="$1"
local BASE_IMAGE="$2"
local GEN_FILES="bin-nm-env-prepare.sh bin-nm-deploy.sh bin-_nm-in-container-setup.sh
etc-rc.local etc-motd-container etc-bashrc.my nm-90-my.conf nm-95-user.conf
home-bash_history home-gdbinit home-gdb_history home-behaverc systemd-20-nm.override"
etc-rc.local etc-motd-container etc-bashrc.my etc-bashrc-motd.my nm-90-my.conf
nm-95-user.conf home-bash_history home-gdbinit home-gdb_history home-behaverc
systemd-20-nm.override"
cp "$BASEDIR_NM/contrib/scripts/NM-log" "$BASEDIR_DATA/data-bin-NM-log"
CLEANUP_FILES+=( "$BASEDIR_DATA/data-NM-log" )
@ -310,6 +311,7 @@ COPY data-bin-_nm-in-container-setup.sh "/usr/bin/_nm-in-container-setup.sh"
COPY data-etc-rc.local "/etc/rc.d/rc.local"
COPY data-etc-motd-container /etc/motd
COPY data-etc-bashrc.my /etc/bashrc.my
COPY data-etc-bashrc-motd.my /etc/bashrc-motd.my
COPY data-nm-90-my.conf /etc/NetworkManager/conf.d/90-my.conf
COPY data-nm-95-user.conf /etc/NetworkManager/conf.d/95-user.conf
COPY data-home-bash_history /root/.bash_history
@ -339,6 +341,7 @@ $RUN_LN_BASEDIR_NM_CI
RUN rm -rf /etc/NetworkManager/system-connections/*
RUN echo -e '\n. /etc/bashrc.my\n' >> /etc/bashrc
RUN echo -e '\n. /etc/bashrc-motd.my\n' >> /etc/bashrc
RUN updatedb
EOF