#!/bin/bash
# Relax-and-Recover
# disable console logging for kernel messages
dmesg -n1

# basic mounts
mount -t proc -n none /proc
mount -t sysfs none /sys

if type udevd &>/dev/null && ! type udevinfo &>/dev/null; then
    ### we use udevinfo to filter out old udev versions (<106) that don't
    ### support --version
    udev_version=$(udevd --version)
    if [[ "$udev_version" -gt 175 ]]; then
        ### udev > 175 needs devtmpfs
        mount -t devtmpfs none /dev
    fi
fi

if [[ ! -d /dev/pts ]] ; then
    mkdir /dev/pts
fi

# was missing on ia64 rhel5
if [[ ! -L /dev/fd ]] ; then 
    ln -s /proc/self/fd /dev/fd
fi

mount -t devpts -o gid=5,mode=620 none /dev/pts

cat /proc/mounts >/etc/mtab 2>/dev/null

# basic loopback net
ip addr add 127.0.0.1/8 dev lo
ip link set lo up

# set hostname
export HOSTNAME="$(cat /etc/HOSTNAME)" # set hostname in THIS shell
hostname "$HOSTNAME" # set hostname in the system

echo Hostname set to $(uname -n)


