File: hostnamer.sh

package info (click to toggle)
libreswan 5.2-2.4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 81,656 kB
  • sloc: ansic: 129,988; sh: 32,018; xml: 20,646; python: 10,303; makefile: 3,022; javascript: 1,506; sed: 574; yacc: 511; perl: 264; awk: 52
file content (33 lines) | stat: -rwxr-xr-x 1,114 bytes parent folder | download | duplicates (2)
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
27
28
29
30
31
32
33
#!/bin/sh

echo hostnamer: determining hostname | tee /dev/console

host()
{
	echo hostnamer: hostname: $1 | tee /dev/console
	hostnamectl set-hostname $1
	exit 0
}

# this will fail for the build domains leaving the default

ip address show | tee /dev/console
macs=$(ip address show | awk '$1 == "link/ether" { print $2 }')

echo hostnamer: macs: ${macs} | tee /dev/console

for mac in ${macs} ; do
    echo hostnamer: mac: ${mac} | tee /dev/console
    case ${mac} in
    	 #   eth0                 eth1               eth2
	                     12:00:00:de:ad:ba | 12:00:00:32:64:ba ) host nic ;;
	 12:00:00:dc:bc:ff | 12:00:00:64:64:23                     ) host east ;;
	 12:00:00:ab:cd:ff | 12:00:00:64:64:45                     ) host west ;;
	 12:00:00:ab:cd:02                                         ) host road ;;
	 12:00:00:de:cd:49 | 12:00:00:96:96:49                     ) host north ;;
                             12:52:49:53:45:01                     ) host rise ;;
                             12:00:53:45:54:01                     ) host set ;;
     esac
done

echo hostnamer: hostname unchanged