diff options
Diffstat (limited to 'rootfs/samizdat-hostname.sh')
-rwxr-xr-x | rootfs/samizdat-hostname.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/rootfs/samizdat-hostname.sh b/rootfs/samizdat-hostname.sh new file mode 100755 index 0000000..52837ba --- /dev/null +++ b/rootfs/samizdat-hostname.sh | |||
@@ -0,0 +1,26 @@ | |||
1 | #!/bin/sh | ||
2 | hostnames() | ||
3 | { | ||
4 | cat <<EOF | ||
5 | adam | ||
6 | billy | ||
7 | cletus | ||
8 | doris | ||
9 | elaine | ||
10 | frank | ||
11 | gilbert | ||
12 | hilda | ||
13 | EOF | ||
14 | } | ||
15 | |||
16 | next_hostname() | ||
17 | { | ||
18 | h=$(hostname) || exit | ||
19 | hostnames | sed -n "/^${h}\$/ {n;p;q}" || exit | ||
20 | } | ||
21 | |||
22 | set -x | ||
23 | hostname=$(next_hostname) | ||
24 | [ "$hostname" ] || hostname=$(hostnames | head -n1) | ||
25 | printf '%s\n' "$hostname" > /etc/hostname | ||
26 | sed -i -e 's/\blocalhost\b/& '"$hostname"'/' /etc/hosts | ||