blob: 52837ba7df11a4c331a4abb8228e78d6e7dd7ae5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/bin/sh
hostnames()
{
cat <<EOF
adam
billy
cletus
doris
elaine
frank
gilbert
hilda
EOF
}
next_hostname()
{
h=$(hostname) || exit
hostnames | sed -n "/^${h}\$/ {n;p;q}" || exit
}
set -x
hostname=$(next_hostname)
[ "$hostname" ] || hostname=$(hostnames | head -n1)
printf '%s\n' "$hostname" > /etc/hostname
sed -i -e 's/\blocalhost\b/& '"$hostname"'/' /etc/hosts
|