summaryrefslogtreecommitdiffstats
path: root/src.etc/init.d/hostname
blob: f64407d94246cce7acbf0548d53758b5c9b36b1b (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
#!/bin/sh

start()
{
	[ -f /etc/hostname ] && HOSTNAME="$(cat /etc/hostname)"
	[ -z "${HOSTNAME}" ] && HOSTNAME="$(hostname)"
	[ -z "${HOSTNAME}" ] && HOSTNAME='localhost'

	printf 'Setting hostname to %s... ' "${HOSTNAME}"
	hostname "${HOSTNAME}"
	printf 'done.\n'
}

case "${1}" in
	start)
		start
		;;
	stop)
		;;
	*)
		printf 'Usage: %s {start|stop}\n' "${0}" >&2
		exit 1
		;;
esac