summaryrefslogtreecommitdiffstats
path: root/src.etc/init.d/hostname
diff options
context:
space:
mode:
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