#!/bin/sh -efu
# configure hasher (implies that 30-users has been run already)

ARCH="$(rpm --eval '%_host_cpu')"
[ -n "$ARCH" ] || exit 2

gray="$(echo -ne "\\033[0;37m")"
white="$(echo -ne "\\033[1;37m")"
cyan="$(echo -ne "\\033[1;36m")"

# root
cat >> /root/.bash_profile << EOF

ram="\$(awk '/^MemTotal/ { print int(\$2/1024+0.5) }' /proc/meminfo)"
swap="\$(awk '/^SwapTotal/ { print int(\$2/1024+0.5) }' /proc/meminfo)"
tmpfs="\$(df -kT /tmp 2>/dev/null \\
	| awk '/^[a-zA-Z_0-9/-]+[[:space:]]+tmpfs/ { print int(\$3/1024); }')"

cat << EOH
Welcome to live builder host system!

Memory: $cyan\${ram}M$gray, swap: $cyan\${swap}M$gray
Autoconfigured tmpfs on /tmp: $cyan\${tmpfs}M$gray

Run ${white}swapon${gray}(8) on any local swaps you might like to employ
followed by ${white}service livecd-tmpfs restart${gray} to reconfigure tmpfs

EOH
EOF

# predefined passwordless livecd user is created with livecd-user