Moxa DA-682A-C7-W7E [13/112] Managing services with insserv

Moxa DA-682A-C7-W7E [13/112] Managing services with insserv
DA-682A Linux Softrware Software Configuration
2-7
use the one provided with the standard Debian distribution, which may be found at /etc/init.d/skeleton.
(the skeleton script provides a great deal more commentary and features). The complete process is described
below.
1. Copy your custom script to /usr/sbin using the convention of rc<scriptname>:
moxa@Moxa:~# cp <full-path-to-your-program> /usr/sbin/rc<scriptname>
2. Give this script executable permissions:
moxa@Moxa:~# chmod 755 /usr/sbin/rc<scriptname>
3. Make a copy of the sample file at /etc/init.d/skeleton (or the one provided in Appendix C of this
manual) and edit it to create an initialization script for your program.
moxa@Moxa:~# cp /etc/init.d/skeleton /etc/init.d/<scriptname>
4. Give the initialization script executable permissions.
moxa@Moxa:~# chmod 755 /etc/init.d/<scriptname>
5. Now activate your script so that it can be run when the system boots; use a low startup priority (below we
use 97 for starts, 03 for shutdown).
moxa@Moxa:~# update-rc.d <scriptname> default 97 03
ATTENTION
For more details about which systems in a Linux environment should be used for automated scripting and
processes, you may refer to the webpage
http://bencane.com/2011/12/30/when
-its-ok-and-not-ok-to-use-rc-local/
(Nov, 2013). For more information
about creating custom Linux scripts, refer to
http:/
/www.linux.com/learn/tutorials/442412-managing-linux-daemons-with-init-scripts
Managing Services with insserv
Linux services can be started or stopped using of the scripts in /etc/init.d/. If you want to start up some
service, you can use insserv to add or remove the service to a specific run level. This tutorial shows you how
to add or remove a service from a specified run level.
WARNING
Insserve is a low level tool, and when improperly called can result in an unbootable system. For this reason,
current Debian best practices recommends against the use of insserv. If you do not feel comfortable using such
a low
-level tool, use update-rc.d instead. A good summary of how to use update-rc.d is available here:
http://www.debuntu.org/how
-to-managing-services-with-update-rc-d/ (Nov. 2013)
The example will use a services start-stop utility named tcps2, which we shall add to /etc/init.d/.
# !/bin/sh
### BEGIN INIT INFO
# Provides: tcps2
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: tcps2
### END INIT INFO
. /lib/lsb/init-functions
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in

Содержание

Похожие устройства