mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 10:22:50 +00:00 
			
		
		
		
	Add MOTD IP Update (#1067)
This commit is contained in:
		@@ -157,6 +157,36 @@ arch_check() {
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Function to get the current IP address based on the distribution
 | 
			
		||||
get_current_ip() {
 | 
			
		||||
  if [ -f /etc/os-release ]; then
 | 
			
		||||
    # Check for Debian/Ubuntu (uses hostname -I)
 | 
			
		||||
    if grep -qE 'ID=debian|ID=ubuntu' /etc/os-release; then
 | 
			
		||||
      CURRENT_IP=$(hostname -I | awk '{print $1}')
 | 
			
		||||
    # Check for Alpine (uses ip command)
 | 
			
		||||
    elif grep -q 'ID=alpine' /etc/os-release; then
 | 
			
		||||
      CURRENT_IP=$(ip -4 addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1 | head -n 1)
 | 
			
		||||
    else
 | 
			
		||||
      CURRENT_IP="Unknown"
 | 
			
		||||
    fi
 | 
			
		||||
  fi
 | 
			
		||||
  echo "$CURRENT_IP"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Function to update the IP address in the MOTD file
 | 
			
		||||
update_motd_ip() {
 | 
			
		||||
  MOTD_FILE="/etc/motd"
 | 
			
		||||
  
 | 
			
		||||
  if [ -f "$MOTD_FILE" ]; then
 | 
			
		||||
    # Remove existing IP Address lines to prevent duplication
 | 
			
		||||
    sed -i '/IP Address:/d' "$MOTD_FILE"
 | 
			
		||||
    
 | 
			
		||||
    IP=$(get_current_ip)
 | 
			
		||||
    # Add the new IP address
 | 
			
		||||
    echo -e "${TAB}${NETWORK}${YW} IP Address: ${GN}${IP}${CL}" >> "$MOTD_FILE"
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# This function sets the APP-Name into an ASCII Header in Slant, figlet needed on proxmox main node.
 | 
			
		||||
header_info() {
 | 
			
		||||
  if [ -f /etc/debian_version ]; then
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user