#!/bin/bash

export MemoryTotalBytes=$(expr $(sed -n 's/^MemTotal:  *\([0-9]*\)[^0-9]*/\1/p' /proc/meminfo) '*' 1024)

get_ip() {
	/sbin/ifconfig ${IFACE:-${INTERFACE:-eth0}} | sed -n '
		/^.*[[:space:]]inet addr:/ {
			s///
			s/[[:space:]].*//
			p
		}
	'
}

if [ -z "$HOSTNAME" ] || [ "$HOSTNAME" = host ]
then
	if [ -z "$newhost" ]
	then
		export newhost=$(get_ip | sed 's/\./-/g')
	fi
	export HOSTNAME="$newhost"
	hostname "$HOSTNAME"
	echo "$HOSTNAME" > /etc/hostname
	if [ -d "$target/etc/" ]
	then
		echo "$HOSTNAME" > "$target/etc/hostname"
	fi
fi

