aboutsummaryrefslogtreecommitdiffstats
path: root/bootscripts/contrib/lsb-v3/init.d/localnet
diff options
context:
space:
mode:
Diffstat (limited to 'bootscripts/contrib/lsb-v3/init.d/localnet')
-rw-r--r--bootscripts/contrib/lsb-v3/init.d/localnet84
1 files changed, 84 insertions, 0 deletions
diff --git a/bootscripts/contrib/lsb-v3/init.d/localnet b/bootscripts/contrib/lsb-v3/init.d/localnet
new file mode 100644
index 000000000..1a68fe3a2
--- /dev/null
+++ b/bootscripts/contrib/lsb-v3/init.d/localnet
@@ -0,0 +1,84 @@
+#!/bin/sh
+# Begin /etc/init.d/localnet
+
+### BEGIN INIT INFO
+# Provides: localnet
+# Required-Start: $local_fs
+# Should-Start:
+# Required-Stop: $network
+# Should-Stop: swap
+# Default-Start: sysinit 0 6
+# Default-Stop:
+# Short-Description: Starts the local network.
+# Description: Sets the hostname of the machine and starts the
+# loopback interface.
+# X-LFS-Default-Start: S80
+# X-LFS-Default-Stop: S90
+# X-LFS-Provided-By: LFS
+### END INIT INFO
+
+. /lib/lsb/init-functions
+. /etc/sysconfig/network
+
+case "${1}" in
+ start)
+ ip addr add 127.0.0.1/8 label lo dev lo
+ ip link set lo up
+ if [ "${?}" = "0" ]
+ then
+ log_success_msg "Bringing up the loopback interface..."
+ else
+ log_failure_msg "Bringing up the loopback interface..."
+ fi
+
+ hostname "${HOSTNAME}"
+ if [ "${?}" = "0" ]
+ then
+ log_success_msg "Setting hostname to ${HOSTNAME}..."
+ else
+ log_failure_msg "Setting hostname to ${HOSTNAME}..."
+ fi
+
+ ;;
+
+ stop)
+ ip link set lo down
+ if [ "${?}" = "0" ]
+ then
+ log_success_msg "Bringing down the loopback interface..."
+ else
+ log_failure_msg "Bringing down the loopback interface..."
+ fi
+
+ ;;
+
+ restart)
+ ip link set lo down
+ retval="${?}"
+ sleep 1
+ ip addr add 127.0.0.1/8 label lo dev lo
+ retval=$(( "${retval}" + "${?}" ))
+ ip link set lo up
+ retval=$(( "${retval}" + "${?}" ))
+ hostname "${HOSTNAME}"
+ retval=$(( "${retval}" + "${?}" ))
+ if [ "${retval}" = "0" ]
+ then
+ log_success_msg "Restarting local network..."
+ else
+ log_failure_msg "Restarting local network..."
+ fi
+ ;;
+
+ status)
+ log_success_msg "Hostname is: ${INFO}$(hostname)${NORMAL}"
+ ip link show lo
+ ;;
+
+ *)
+ echo "Usage: ${0} {start|stop|restart|status}"
+ exit 1
+ ;;
+esac
+
+# End /etc/init.d/localnet