summaryrefslogtreecommitdiffstats
path: root/src.etc/init.d/hostname
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-08-08 15:26:37 (EDT)
committer P. J. McDermott <pjm@nac.net>2013-08-08 15:26:37 (EDT)
commit60ee13961584e957020d30daf287d03e55a50763 (patch)
treeb6058d13da6bc00efee4d61b635df2e1a0158701 /src.etc/init.d/hostname
parent6b4e7447cb8e8d4265c2c8d846ac39de449c1ab1 (diff)
Rewrite init scripts.
Diffstat (limited to 'src.etc/init.d/hostname')
-rwxr-xr-xsrc.etc/init.d/hostname19
1 files changed, 15 insertions, 4 deletions
diff --git a/src.etc/init.d/hostname b/src.etc/init.d/hostname
index aec1102..f64407d 100755
--- a/src.etc/init.d/hostname
+++ b/src.etc/init.d/hostname
@@ -1,13 +1,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)
- printf 'Setting hostname... '
- [ -f /etc/hostname ] && hostname -F /etc/hostname || hostname none
- printf 'done.\n'
+ start
+ ;;
+ stop)
;;
*)
- printf 'Usage: %s start\n' "${0}" >&2
+ printf 'Usage: %s {start|stop}\n' "${0}" >&2
exit 1
;;
esac