#!/bin/bash
# Step 01: Set hostname and /etc/hosts

step_01_hostname() {
  echo "$HOSTNAME" > /etc/hostname
  hostnamectl set-hostname "$HOSTNAME" 2>/dev/null || true
  if ! grep -q "127.0.1.1[[:space:]]*$HOSTNAME" /etc/hosts 2>/dev/null; then
    sed -i "/127.0.1.1[[:space:]].*$/d" /etc/hosts
    echo "127.0.1.1	$HOSTNAME" >> /etc/hosts
  fi
  log "Hostname set to $HOSTNAME"
}
