Skip to content

Commit 4cf0436

Browse files
authored
update motd file to dynamic ip (#1633)
1 parent 9fd9ab0 commit 4cf0436

File tree

2 files changed

+18
-28
lines changed

2 files changed

+18
-28
lines changed

misc/alpine-install.func

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,16 @@ motd_ssh() {
146146
OS_NAME="Alpine Linux"
147147
OS_VERSION="Unknown"
148148
fi
149-
# Set MOTD with application info and system details
150-
MOTD_FILE="/etc/motd"
151-
if [ -f "$MOTD_FILE" ]; then
152-
echo -e "\n${BOLD}${APPLICATION} LXC Container${CL}" > "$MOTD_FILE"
153-
echo -e "${TAB}${GATEWAY}${YW} Provided by: ${GN}community-scripts ORG ${YW}| Project: ${GN}ProxmoxVE ${YW}| GitHub: ${GN}https://github.com/community-scripts/ProxmoxVE${CL}\n" >> "$MOTD_FILE"
154-
echo -e "${TAB}${OS}${YW} OS: ${GN}${OS_NAME} ${OS_VERSION}${CL}" >> "$MOTD_FILE"
155-
echo -e "${TAB}${HOSTNAME}${YW} Hostname: ${GN}$(hostname)${CL}" >> "$MOTD_FILE"
156-
echo -e "${TAB}${INFO}${YW} IP Address: ${GN}${IP}${CL}" >> "$MOTD_FILE"
157-
else
158-
echo -e "${RD}[WARNING] MOTD file does not exist!${CL}" >&2
159-
fi
149+
150+
PROFILE_FILE="/etc/profile.d/00_lxc-details.sh"
151+
echo "echo -e \"\"" > "$PROFILE_FILE"
152+
echo -e "echo -e \"${BOLD}${APPLICATION} LXC Container${CL}"\" >> "$PROFILE_FILE"
153+
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"
154+
echo "echo \"\"" >> "$PROFILE_FILE"
155+
echo -e "echo -e \"${TAB}${OS}${YW} OS: ${GN}${OS_NAME} - Version: ${OS_VERSION}${CL}\"" >> "$PROFILE_FILE"
156+
echo -e "echo -e \"${TAB}${HOSTNAME}${YW} Hostname: ${GN}\$(hostname)${CL}\"" >> "$PROFILE_FILE"
157+
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"
158+
160159
# Configure SSH if enabled
161160
if [[ "${SSH_ROOT}" == "yes" ]]; then
162161
# Enable sshd service

misc/install.func

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,6 @@ motd_ssh() {
202202
# Set terminal to 256-color mode
203203
grep -qxF "export TERM='xterm-256color'" /root/.bashrc || echo "export TERM='xterm-256color'" >> /root/.bashrc
204204

205-
# Get the current private IP address
206-
IP=$(hostname -I | awk '{print $1}') # Private IP
207-
208205
# Get OS information (Debian / Ubuntu)
209206
if [ -f "/etc/os-release" ]; then
210207
OS_NAME=$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '"')
@@ -214,20 +211,14 @@ motd_ssh() {
214211
OS_VERSION=$(cat /etc/debian_version)
215212
fi
216213

217-
# Set MOTD with application info, system details
218-
MOTD_FILE="/etc/motd"
219-
if [ -f "$MOTD_FILE" ]; then
220-
# Start MOTD with application info and link
221-
echo -e "\n${BOLD}${APPLICATION} LXC Container${CL}" > "$MOTD_FILE"
222-
echo -e "${TAB}${GATEWAY}${YW} Provided by: ${GN}community-scripts ORG ${YW}| GitHub: ${GN}https://github.com/community-scripts/ProxmoxVE${CL}\n" >> "$MOTD_FILE"
223-
224-
# Add system information with icons
225-
echo -e "${TAB}${OS}${YW} OS: ${GN}${OS_NAME} - Version: ${OS_VERSION}${CL}" >> "$MOTD_FILE"
226-
echo -e "${TAB}${HOSTNAME}${YW} Hostname: ${GN}$(hostname)${CL}" >> "$MOTD_FILE"
227-
echo -e "${TAB}${INFO}${YW} IP Address: ${GN}${IP}${CL}" >> "$MOTD_FILE"
228-
else
229-
echo "MotD file does not exist!" >&2
230-
fi
214+
PROFILE_FILE="/etc/profile.d/00_lxc-details.sh"
215+
echo "echo -e \"\"" > "$PROFILE_FILE"
216+
echo -e "echo -e \"${BOLD}${APPLICATION} LXC Container${CL}"\" >> "$PROFILE_FILE"
217+
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"
218+
echo "echo \"\"" >> "$PROFILE_FILE"
219+
echo -e "echo -e \"${TAB}${OS}${YW} OS: ${GN}${OS_NAME} - Version: ${OS_VERSION}${CL}\"" >> "$PROFILE_FILE"
220+
echo -e "echo -e \"${TAB}${HOSTNAME}${YW} Hostname: ${GN}\$(hostname)${CL}\"" >> "$PROFILE_FILE"
221+
echo -e "echo -e \"${TAB}${INFO}${YW} IP Address: ${GN}\$(hostname -I | awk '{print \$1}')${CL}\"" >> "$PROFILE_FILE"
231222

232223
# Disable default MOTD scripts
233224
chmod -x /etc/update-motd.d/*

0 commit comments

Comments
 (0)