summaryrefslogtreecommitdiff
path: root/rootfs/samizdat-hostname.sh
diff options
context:
space:
mode:
Diffstat (limited to 'rootfs/samizdat-hostname.sh')
-rwxr-xr-xrootfs/samizdat-hostname.sh26
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
2hostnames()
3{
4cat <<EOF
5adam
6billy
7cletus
8doris
9elaine
10frank
11gilbert
12hilda
13EOF
14}
15
16next_hostname()
17{
18 h=$(hostname) || exit
19 hostnames | sed -n "/^${h}\$/ {n;p;q}" || exit
20}
21
22set -x
23hostname=$(next_hostname)
24[ "$hostname" ] || hostname=$(hostnames | head -n1)
25printf '%s\n' "$hostname" > /etc/hostname
26sed -i -e 's/\blocalhost\b/& '"$hostname"'/' /etc/hosts