File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,36 @@ arch_check() {
157157 fi
158158}
159159
160+ # Function to get the current IP address based on the distribution
161+ get_current_ip() {
162+ if [ -f /etc/os-release ]; then
163+ # Check for Debian/Ubuntu (uses hostname -I)
164+ if grep -qE 'ID=debian|ID=ubuntu' /etc/os-release; then
165+ CURRENT_IP=$(hostname -I | awk '{print $1}')
166+ # Check for Alpine (uses ip command)
167+ elif grep -q 'ID=alpine' /etc/os-release; then
168+ CURRENT_IP=$(ip -4 addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1 | head -n 1)
169+ else
170+ CURRENT_IP="Unknown"
171+ fi
172+ fi
173+ echo "$CURRENT_IP"
174+ }
175+
176+ # Function to update the IP address in the MOTD file
177+ update_motd_ip() {
178+ MOTD_FILE="/etc/motd"
179+
180+ if [ -f "$MOTD_FILE" ]; then
181+ # Remove existing IP Address lines to prevent duplication
182+ sed -i '/IP Address:/d' "$MOTD_FILE"
183+
184+ IP=$(get_current_ip)
185+ # Add the new IP address
186+ echo -e "${TAB}${NETWORK}${YW} IP Address: ${GN}${IP}${CL}" >> "$MOTD_FILE"
187+ fi
188+ }
189+
160190# This function sets the APP-Name into an ASCII Header in Slant, figlet needed on proxmox main node.
161191header_info() {
162192 if [ -f /etc/debian_version ]; then
You can’t perform that action at this time.
0 commit comments