From 0ec71289ed3377ad2a844417dc34e9191a01d3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= Date: Thu, 31 Aug 2023 11:21:12 +0200 Subject: [PATCH] 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. --- tools/nm-guest-data/etc-bashrc-motd.my.in | 4 ++++ tools/nm-guest-data/etc-bashrc.my.in | 5 ----- tools/nm-guest-data/etc-motd-vm.in | 2 +- tools/nm-in-container | 7 +++++-- 4 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 tools/nm-guest-data/etc-bashrc-motd.my.in diff --git a/tools/nm-guest-data/etc-bashrc-motd.my.in b/tools/nm-guest-data/etc-bashrc-motd.my.in new file mode 100644 index 0000000000..510d30f8fa --- /dev/null +++ b/tools/nm-guest-data/etc-bashrc-motd.my.in @@ -0,0 +1,4 @@ +if test "$SHOW_MOTD" != 0; then + cat /etc/motd + export SHOW_MOTD=0 +fi diff --git a/tools/nm-guest-data/etc-bashrc.my.in b/tools/nm-guest-data/etc-bashrc.my.in index db8598a05c..531519bad7 100644 --- a/tools/nm-guest-data/etc-bashrc.my.in +++ b/tools/nm-guest-data/etc-bashrc.my.in @@ -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 diff --git a/tools/nm-guest-data/etc-motd-vm.in b/tools/nm-guest-data/etc-motd-vm.in index 17332d5ea0..10ae1f9fc8 100644 --- a/tools/nm-guest-data/etc-motd-vm.in +++ b/tools/nm-guest-data/etc-motd-vm.in @@ -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`. diff --git a/tools/nm-in-container b/tools/nm-in-container index 0a58d821a2..f91a747f32 100755 --- a/tools/nm-in-container +++ b/tools/nm-in-container @@ -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