summaryrefslogtreecommitdiff
path: root/repo/openrc/hostname.initd
blob: 4581595d28bafbd01582dbbfa0279062fc30d238 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/sbin/openrc-run

description="Sets the hostname of the machine."

depend() {
	keyword -prefix -lxc -docker
}

start() {
	if [ -s /etc/hostname ] ; then
		name=$(cat /etc/hostname)
	else
		name="${hostname:-localhost}"
	fi
	ebegin "Setting hostname"
	hostname $name
	eend $?
}