blob: b752cd4faaaa9e3b1fff257b762e20b961bfacd8 [file] [log] [blame]
#!/bin/bash
ADJECTIVES_FILE=/usr/share/mendel-minimal/adjectives.txt
NOUNS_FILE=/usr/share/mendel-minimal/nouns.txt
random_word()
{
local wordlist=$1; shift
local max=$(wc -l $wordlist |awk '{ print $1 }')
local line=$(($RANDOM % $max + 1))
head -n $line $wordlist |tail -n 1
}
generate_hostname()
{
local adj=$(random_word $ADJECTIVES_FILE)
local noun=$(random_word $NOUNS_FILE)
echo "${adj}-${noun}"
}
hostname=$(generate_hostname)
echo $hostname >/etc/hostname
/bin/hostname $hostname
/usr/bin/hostnamectl set-hostname $hostname
echo 127.0.0.1 $hostname >>/etc/hosts