Skip to content

Commit 5e5a8cd

Browse files
authored
feat(motd): dynamically read OS version on each login (#9751)
1 parent 0da3231 commit 5e5a8cd

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

misc/alpine-install.func

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,13 @@ update_os() {
125125
# This function modifies the message of the day (motd) and SSH settings
126126
motd_ssh() {
127127
echo "export TERM='xterm-256color'" >>/root/.bashrc
128-
IP=$(ip -4 addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1 | head -n 1)
129-
130-
if [ -f "/etc/os-release" ]; then
131-
OS_NAME=$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '"')
132-
OS_VERSION=$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '"')
133-
else
134-
OS_NAME="Alpine Linux"
135-
OS_VERSION="Unknown"
136-
fi
137128

138129
PROFILE_FILE="/etc/profile.d/00_lxc-details.sh"
139130
echo "echo -e \"\"" >"$PROFILE_FILE"
140131
echo -e "echo -e \"${BOLD}${APPLICATION} LXC Container${CL}"\" >>"$PROFILE_FILE"
141132
echo -e "echo -e \"${TAB}${GATEWAY}${YW} Provided by: ${GN}community-scripts ORG ${YW}| GitHub: ${GN}https://github.com/community-scripts/ProxmoxVE${CL}\"" >>"$PROFILE_FILE"
142133
echo "echo \"\"" >>"$PROFILE_FILE"
143-
echo -e "echo -e \"${TAB}${OS}${YW} OS: ${GN}${OS_NAME} - Version: ${OS_VERSION}${CL}\"" >>"$PROFILE_FILE"
134+
echo -e "echo -e \"${TAB}${OS}${YW} OS: ${GN}\$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')${CL}\"" >>"$PROFILE_FILE"
144135
echo -e "echo -e \"${TAB}${HOSTNAME}${YW} Hostname: ${GN}\$(hostname)${CL}\"" >>"$PROFILE_FILE"
145136
echo -e "echo -e \"${TAB}${INFO}${YW} IP Address: ${GN}\$(ip -4 addr show eth0 | awk '/inet / {print \$2}' | cut -d/ -f1 | head -n 1)${CL}\"" >>"$PROFILE_FILE"
146137

misc/install.func

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,21 +222,12 @@ motd_ssh() {
222222
# Set terminal to 256-color mode
223223
grep -qxF "export TERM='xterm-256color'" /root/.bashrc || echo "export TERM='xterm-256color'" >>/root/.bashrc
224224

225-
# Get OS information (Debian / Ubuntu)
226-
if [ -f "/etc/os-release" ]; then
227-
OS_NAME=$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '"')
228-
OS_VERSION=$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '"')
229-
elif [ -f "/etc/debian_version" ]; then
230-
OS_NAME="Debian"
231-
OS_VERSION=$(cat /etc/debian_version)
232-
fi
233-
234225
PROFILE_FILE="/etc/profile.d/00_lxc-details.sh"
235226
echo "echo -e \"\"" >"$PROFILE_FILE"
236227
echo -e "echo -e \"${BOLD}${APPLICATION} LXC Container${CL}"\" >>"$PROFILE_FILE"
237228
echo -e "echo -e \"${TAB}${GATEWAY}${YW} Provided by: ${GN}community-scripts ORG ${YW}| GitHub: ${GN}https://github.com/community-scripts/ProxmoxVE${CL}\"" >>"$PROFILE_FILE"
238229
echo "echo \"\"" >>"$PROFILE_FILE"
239-
echo -e "echo -e \"${TAB}${OS}${YW} OS: ${GN}${OS_NAME} - Version: ${OS_VERSION}${CL}\"" >>"$PROFILE_FILE"
230+
echo -e "echo -e \"${TAB}${OS}${YW} OS: ${GN}\$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')${CL}\"" >>"$PROFILE_FILE"
240231
echo -e "echo -e \"${TAB}${HOSTNAME}${YW} Hostname: ${GN}\$(hostname)${CL}\"" >>"$PROFILE_FILE"
241232
echo -e "echo -e \"${TAB}${INFO}${YW} IP Address: ${GN}\$(hostname -I | awk '{print \$1}')${CL}\"" >>"$PROFILE_FILE"
242233

0 commit comments

Comments
 (0)