From 4dc942d789b17100f1e637b7450bd7d8a3239236 Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Mon, 13 Dec 2021 10:00:16 +0000 Subject: [PATCH 1/2] Update init.d support --- .gitignore | 1 + INSTALL.md | 15 ++-- configure.ac | 14 ++- script/Makefile.am | 23 ++++- script/ethercatctl.in | 14 ++- script/init.d/Makefile.am | 27 ------ script/init.d/ethercat.in | 168 +++-------------------------------- script/sysconfig/Makefile.am | 29 ------ script/sysconfig/ethercat | 68 -------------- 9 files changed, 60 insertions(+), 299 deletions(-) delete mode 100644 script/init.d/Makefile.am delete mode 100644 script/sysconfig/Makefile.am delete mode 100644 script/sysconfig/ethercat diff --git a/.gitignore b/.gitignore index 482f9389..ce70a823 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ lib/libethercat.la lib/libethercat.pc libtool master/*.o.d +script/ethercat script/ethercat.service script/ethercatctl script/init.d/ethercat diff --git a/INSTALL.md b/INSTALL.md index a4aa2766..38045c4e 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -10,12 +10,12 @@ section of the --- -For the impatient: The procedure mainly consists of calling +For the impatient, the procedure mainly consists of calling: ```bash ./bootstrap # to create the configure script, if downloaded from the repo -./configure +./configure --sysconfdir=/etc make all modules ``` @@ -26,13 +26,11 @@ make modules_install install depmod ``` -... and linking the init script and copying the sysconfig file from $PREFIX/etc -to the appropriate locations and customizing the sysconfig file. +... and then customizing the appropriate configuration file: ```bash -ln -s ${PREFIX}/etc/init.d/ethercat /etc/init.d/ethercat -cp ${PREFIX}/etc/sysconfig/ethercat /etc/sysconfig/ethercat -vi /etc/sysconfig/ethercat +# vi /etc/ethercat.conf # For systemd based distro +# vi /etc/sysconfig/ethercat # For init.d based distro ``` Make sure, that the 'udev' package is installed, to automatically create the @@ -47,7 +45,8 @@ echo KERNEL==\"EtherCAT[0-9]*\", MODE=\"0664\" > /etc/udev/rules.d/99-EtherCAT.r Now you can start the EtherCAT master: ```bash -/etc/init.d/ethercat start +# systemctl start ethercat # For systemd based distro +# /etc/init.d/ethercat start # For init.d based distro ``` Have a look at the [examples subdirectory](examples/) for some application diff --git a/configure.ac b/configure.ac index b3a40f4d..4e50ca98 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,7 @@ AC_CONFIG_HEADERS([config.h]) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_MACRO_DIR([m4]) AC_PROG_SED +AC_PROG_MKDIR_P m4_ifndef([PKG_INSTALLDIR], [m4_fatal([pkgconf or pkg-config not found or too old (`pkg-config --version` must be >= 0.27)])]) PKG_PROG_PKG_CONFIG(0.27) PKG_INSTALLDIR @@ -1328,6 +1329,16 @@ else AC_MSG_RESULT([no]) fi +#----------------------------------------------------------------------------- +# init.d support +#----------------------------------------------------------------------------- + +AC_ARG_ENABLE([initd], + AS_HELP_STRING([--disable-initd], + [Disable /etc/init.d script support (default: enabled)]) +) +AM_CONDITIONAL(HAVE_INITD, test "x$enable_initd" != "xno") + #----------------------------------------------------------------------------- # systemd service support #----------------------------------------------------------------------------- @@ -1405,9 +1416,6 @@ AC_CONFIG_FILES([ master/Kbuild master/Makefile script/Makefile - script/init.d/Makefile - script/init.d/ethercat - script/sysconfig/Makefile tool/Makefile tty/Kbuild tty/Makefile diff --git a/script/Makefile.am b/script/Makefile.am index 37605229..cf9e5046 100644 --- a/script/Makefile.am +++ b/script/Makefile.am @@ -23,15 +23,14 @@ # #------------------------------------------------------------------------------ -SUBDIRS = init.d sysconfig - sbin_SCRIPTS = ethercatctl dist_sysconf_DATA = ethercat.conf script_templates = \ ethercatctl.in \ - ethercat.service.in + ethercat.service.in \ + init.d/ethercat.in EXTRA_DIST = \ $(script_templates) \ @@ -40,7 +39,9 @@ EXTRA_DIST = \ CLEANFILES = \ ethercatctl \ - ethercat.service + ethercat.service \ + init.d/ethercat \ + ethercat if HAVE_SYSTEMD systemdsystemunit_DATA = ethercat.service @@ -57,6 +58,13 @@ uninstall-hook: cd $(DESTDIR)$(completionsdir); \ rm ethercat +if HAVE_INITD +initdir = $(sysconfdir)/init.d +init_SCRIPTS = init.d/ethercat +sysdir = $(sysconfdir)/sysconfig +sys_DATA = ethercat +endif + # Any precious variable used inside script_templates should appear here expand_script = $(SED) \ -e 's,[@]VERSION[@],$(VERSION),g' \ @@ -70,4 +78,11 @@ ethercatctl: $(srcdir)/ethercatctl.in Makefile ethercat.service: $(srcdir)/ethercat.service.in Makefile $(expand_script) < $< > $@ +init.d/ethercat: $(srcdir)/init.d/ethercat.in Makefile + $(MKDIR_P) init.d && \ + $(expand_script) < $< > $@ + +ethercat: $(srcdir)/ethercat.conf Makefile + $(SED) -e 's,for use with ethercatctl,for use with init.d,g' < $< > $@ + #------------------------------------------------------------------------------ diff --git a/script/ethercatctl.in b/script/ethercatctl.in index 763147ac..03083459 100755 --- a/script/ethercatctl.in +++ b/script/ethercatctl.in @@ -35,7 +35,15 @@ ETHERCAT=@bindir@/ethercat #------------------------------------------------------------------------------ -ETHERCAT_CONFIG=@sysconfdir@/ethercat.conf +if [ "$1" = "-c" ]; then + ETHERCAT_CONFIG="$2" + COMMAND="$3" +else + ETHERCAT_CONFIG=@sysconfdir@/ethercat.conf + COMMAND="$1" +fi + +#------------------------------------------------------------------------------ if [ ! -r ${ETHERCAT_CONFIG} ]; then echo ${ETHERCAT_CONFIG} not existing; @@ -73,7 +81,7 @@ parse_mac_address() { #------------------------------------------------------------------------------ -case "${1}" in +case "$COMMAND" in start) # bring up all updown interfaces before anything else @@ -229,7 +237,7 @@ status) #------------------------------------------------------------------------------ *) - echo "USAGE: $0 {start|stop|restart|status}" + echo "USAGE: $0 [-c path/to/ethercat.conf] {start|stop|restart|status}" exit 1 ;; esac diff --git a/script/init.d/Makefile.am b/script/init.d/Makefile.am deleted file mode 100644 index 1ee86ecb..00000000 --- a/script/init.d/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH -# -# This file is part of the IgH EtherCAT Master. -# -# The IgH EtherCAT Master is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 2, as -# published by the Free Software Foundation. -# -# The IgH EtherCAT Master is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with the IgH EtherCAT Master; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# -#------------------------------------------------------------------------------ - -initdir = $(sysconfdir)/init.d - -init_SCRIPTS = ethercat - -#------------------------------------------------------------------------------ diff --git a/script/init.d/ethercat.in b/script/init.d/ethercat.in index 6eac1bec..36d9cc30 100755 --- a/script/init.d/ethercat.in +++ b/script/init.d/ethercat.in @@ -40,27 +40,7 @@ #------------------------------------------------------------------------------ -LSMOD=/sbin/lsmod -MODPROBE=/sbin/modprobe -RMMOD=/sbin/rmmod -MODINFO=/sbin/modinfo -ETHERCAT=@prefix@/bin/ethercat -MASTER_ARGS= - -#------------------------------------------------------------------------------ - -ETHERCAT_CONFIG=/etc/sysconfig/ethercat - -if [ ! -r ${ETHERCAT_CONFIG} ]; then - echo ${ETHERCAT_CONFIG} not existing; - if [ "${1}" = "stop" ]; then - exit 0 - else - exit 6 - fi -fi - -. ${ETHERCAT_CONFIG} +ETHERCATCTL="@sbindir@/ethercatctl -c @sysconfdir@/sysconfig/ethercat" #------------------------------------------------------------------------------ @@ -90,41 +70,6 @@ exit_fail() { #------------------------------------------------------------------------------ -print_running() { - if [ -r /etc/rc.status ]; then - rc_reset - rc_status -v - else - echo " running" - fi -} - -#------------------------------------------------------------------------------ - -print_dead() { - if [ -r /etc/rc.status ]; then - rc_failed - rc_status -v - else - echo " dead" - fi -} - -#------------------------------------------------------------------------------ - -parse_mac_address() { - if [ -z "${1}" ]; then - MAC="" - elif echo "${1}" | grep -qE '^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$'; then - MAC=${1} - else - echo Invalid MAC address \""${1}"\" in ${ETHERCAT_CONFIG} - exit_fail - fi -} - -#------------------------------------------------------------------------------ - if [ -r /etc/rc.status ]; then . /etc/rc.status rc_reset @@ -135,85 +80,21 @@ case "${1}" in start) echo -n "Starting EtherCAT master @VERSION@ " - # construct DEVICES and BACKUPS from configuration variables - DEVICES="" - BACKUPS="" - MASTER_INDEX=0 - while true; do - DEVICE=$(eval echo "\${MASTER${MASTER_INDEX}_DEVICE}") - BACKUP=$(eval echo "\${MASTER${MASTER_INDEX}_BACKUP}") - if [ -z "${DEVICE}" ]; then break; fi - - if [ ${MASTER_INDEX} -gt 0 ]; then - DEVICES=${DEVICES}, - BACKUPS=${BACKUPS}, - fi - - parse_mac_address "${DEVICE}" - DEVICES=${DEVICES}${MAC} - - parse_mac_address "${BACKUP}" - BACKUPS=${BACKUPS}${MAC} - - MASTER_INDEX=$((${MASTER_INDEX} + 1)) - done - - # load master module - if ! ${MODPROBE} ${MODPROBE_FLAGS} ec_master "${MASTER_ARGS}" \ - main_devices="${DEVICES}" backup_devices="${BACKUPS}"; then + if $ETHERCATCTL start; then + exit_success + else exit_fail fi - - # check for modules to replace - for MODULE in ${DEVICE_MODULES}; do - ECMODULE=ec_${MODULE} - if ! ${MODINFO} "${ECMODULE}" > /dev/null; then - continue # ec_* module not found - fi - if [ "${MODULE}" != "generic" ]; then - if ${LSMOD} | grep "^${MODULE} " > /dev/null; then - if ! ${RMMOD} "${MODULE}"; then - exit_fail - fi - fi - fi - if ! ${MODPROBE} ${MODPROBE_FLAGS} "${ECMODULE}"; then - if [ "${MODULE}" != "generic" ]; then - ${MODPROBE} ${MODPROBE_FLAGS} "${MODULE}" # try to restore - fi - exit_fail - fi - done - - exit_success ;; stop) echo -n "Shutting down EtherCAT master @VERSION@ " - # unload EtherCAT device modules - for MODULE in ${DEVICE_MODULES} master; do - ECMODULE=ec_${MODULE} - if ! ${LSMOD} | grep -q "^${ECMODULE} "; then - continue # ec_* module not loaded - fi - if ! ${RMMOD} "${ECMODULE}"; then - exit_fail - fi; - done - - sleep 1 - - # reload previous modules - for MODULE in ${DEVICE_MODULES}; do - if [ "${MODULE}" != "generic" ]; then - if ! ${MODPROBE} ${MODPROBE_FLAGS} "${MODULE}"; then - echo Warning: Failed to restore "${MODULE}". - fi - fi - done - - exit_success + if $ETHERCATCTL stop; then + exit_success + else + exit_fail + fi ;; restart) @@ -223,35 +104,8 @@ restart) ;; status) - echo "Checking for EtherCAT master @VERSION@ " - - # count masters in configuration file - MASTER_COUNT=0 - while true; do - DEVICE=$(eval echo "\${MASTER${MASTER_COUNT}_DEVICE}") - if [ -z "${DEVICE}" ]; then break; fi - MASTER_COUNT=$((${MASTER_COUNT} + 1)) - done - - RESULT=0 - - for i in $(seq 0 "$((${MASTER_COUNT} - 1))"); do - echo -n "Master${i} " - - # Check if the master is in idle or operation phase - ${ETHERCAT} master --master "${i}" 2>/dev/null | \ - grep -qE 'Phase:[[:space:]]*Idle|Phase:[[:space:]]*Operation' - EXITCODE=$? - - if [ ${EXITCODE} -eq 0 ]; then - print_running - else - print_dead - RESULT=1 - fi - done - - exit ${RESULT} + $ETHERCATCTL status + exit $? ;; *) diff --git a/script/sysconfig/Makefile.am b/script/sysconfig/Makefile.am deleted file mode 100644 index 2273c32b..00000000 --- a/script/sysconfig/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH -# -# This file is part of the IgH EtherCAT Master. -# -# The IgH EtherCAT Master is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 2, as -# published by the Free Software Foundation. -# -# The IgH EtherCAT Master is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with the IgH EtherCAT Master; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# -#------------------------------------------------------------------------------ - -sysdir = $(sysconfdir)/sysconfig - -sys_DATA = ethercat - -EXTRA_DIST = ethercat - -#------------------------------------------------------------------------------ diff --git a/script/sysconfig/ethercat b/script/sysconfig/ethercat deleted file mode 100644 index f8b2388b..00000000 --- a/script/sysconfig/ethercat +++ /dev/null @@ -1,68 +0,0 @@ -#------------------------------------------------------------------------------ -# -# EtherCAT master sysconfig file -# -# vim: spelllang=en spell tw=78 -# -#------------------------------------------------------------------------------ - -# -# Main Ethernet devices. -# -# The MASTER_DEVICE variable specifies the Ethernet device for a master -# with index 'X'. -# -# Specify the MAC address (hexadecimal with colons) of the Ethernet device to -# use. Example: "00:00:08:44:ab:66" -# -# The broadcast address "ff:ff:ff:ff:ff:ff" has a special meaning: It tells -# the master to accept the first device offered by any Ethernet driver. -# -# The MASTER_DEVICE variables also determine, how many masters will be -# created: A non-empty variable MASTER0_DEVICE will create one master, adding a -# non-empty variable MASTER1_DEVICE will create a second master, and so on. -# -MASTER0_DEVICE="" -#MASTER1_DEVICE="" - -# -# Backup Ethernet devices -# -# The MASTER_BACKUP variables specify the devices used for redundancy. They -# behaves nearly the same as the MASTER_DEVICE variable, except that it -# does not interpret the ff:ff:ff:ff:ff:ff address. -# -#MASTER0_BACKUP="" - -# -# Ethernet driver modules to use for EtherCAT operation. -# -# Specify a non-empty list of Ethernet drivers, that shall be used for -# EtherCAT operation. -# -# Except for the generic Ethernet driver module, the init script will try to -# unload the usual Ethernet driver modules in the list and replace them with -# the EtherCAT-capable ones. If a certain (EtherCAT-capable) driver is not -# found, a warning will appear. -# -# Possible values: 8139too, e100, e1000, e1000e, r8169, generic, ccat, igb. -# Separate multiple drivers with spaces. -# -# Note: The e100, e1000, e1000e, r8169, ccat and igb drivers are not built by -# default. Enable them with the --enable- configure switches. -# -# Attention: When using the generic driver, the corresponding Ethernet device -# has to be activated (with OS methods, for example 'ip link set ethX up'), -# before the master is started, otherwise all frames will time out. -# -DEVICE_MODULES="" - -# -# Flags for loading kernel modules. -# -# This can usually be left empty. Adjust this variable, if you have problems -# with module loading. -# -#MODPROBE_FLAGS="-b" - -#------------------------------------------------------------------------------ From d31fe6db685e7fd6a63b7ae8d063581bd3f1a077 Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Mon, 6 Jun 2022 16:58:47 +0200 Subject: [PATCH 2/2] doc: fix references to init scripts init.d support has been updated but the TeX files still reference some old contents. Fix all the `../script` folder references, avoid pointing to generated files (that, depending on the configure options, may or may not exist) and, while at it, refresh a bit the systemd/init.d documentations. --- documentation/ethercat_doc.tex | 49 +++++++++++-------------------- documentation/ethercat_doc_fr.tex | 45 +++++++++------------------- 2 files changed, 31 insertions(+), 63 deletions(-) diff --git a/documentation/ethercat_doc.tex b/documentation/ethercat_doc.tex index a4b7813e..ca525c97 100644 --- a/documentation/ethercat_doc.tex +++ b/documentation/ethercat_doc.tex @@ -2926,8 +2926,8 @@ before others) inside the init script code, LSB defines a special comment block. System tools can extract this information to insert the EtherCAT init script at the correct place in the startup sequence: -\lstinputlisting[firstline=38,lastline=48] - {../script/init.d/ethercat} +\lstinputlisting[firstline=36,lastline=46,basicstyle=\ttfamily\scriptsize] + {../script/init.d/ethercat.in} \subsection{Sysconfig File} \label{sec:sysconfig} @@ -2939,8 +2939,8 @@ mandatory for the init script. The sysconfig file contains all configuration variables needed to operate one or more masters. The documentation is inside the file and included below: -\lstinputlisting[numbers=left,firstline=9,basicstyle=\ttfamily\scriptsize] - {../script/sysconfig/ethercat} +\lstinputlisting[numbers=left,firstline=11,basicstyle=\ttfamily\scriptsize,language=sh,escapechar={}] + {../script/ethercat.conf} For systems managed by systemd (see \autoref{sec:systemd}), the sysconfig file has moved to \lstinline+/etc/ethercat.conf+. Both versions are part of the @@ -2976,19 +2976,18 @@ the EtherCAT master. It has to be executed with one of the parameters Distributions using \textit{systemd} instead of the SysV init system are using service files to describe how a service is to be maintained. \autoref{lst:service} lists the master's service file: -\lstinputlisting[basicstyle=\ttfamily\footnotesize,caption=Service file, -label=lst:service]{../script/ethercat.service} +\lstinputlisting[basicstyle=\ttfamily\scriptsize,caption=Service file,label=lst:service] + {../script/ethercat.service.in} -The \textit{ethercatctl} command is used to load and unload the master and +The \textit{systemctl} command is used to load and unload the master and network driver modules in a similar way to the former init script -(\autoref{sec:init}). Because it is installed into the \textit{sbin/} -directory, it can also be used separately: +(\autoref{sec:init}). \begin{lstlisting}[gobble=2] - # `\textbf{ethercatctl start}` + # `\textbf{systemctl start ethercat}` \end{lstlisting} -When using systemd and/or the \textit{ethercatctl} command, the master +When using systemd and/or the \textit{systemctl} command, the master configuration must be in \texttt{/etc/ethercat.conf} instead of \texttt{/etc/sysconfig/ethercat}! The latter is ignored. The configuration options are exactly the same. @@ -3385,16 +3384,17 @@ Interface''. \section{Installing the Software} -The below commands have to be entered as \textit{root}: The first one will -install the EtherCAT header, init script, sysconfig file and the userspace +The below commands have to be entered as \textit{root}: the first one will +install the EtherCAT header, service scripts (systemd or init.d) and the userspace tool to the prefix path. The second one will install the kernel modules to the kernel's modules directory. The final \lstinline+depmod+ call is necessary to include the kernel modules into the \textit{modules.dep} file to make it -available to the \lstinline+modprobe+ command, used in the init script. +available to the \lstinline+modprobe+ command, used by the service scripts. \begin{lstlisting} # `\textbf{make install}` # `\textbf{make modules\_install}` +# `\textbf{depmod}` \end{lstlisting} If the target kernel's modules directory is not under \textit{/lib/modules}, a @@ -3408,21 +3408,6 @@ make variable. For example: This command will install the compiled kernel modules to \textit{/vol/nfs/root/lib/modules}, prepended by the kernel release. -If the EtherCAT master shall be run as a service\footnote{Even if the EtherCAT -master shall not be loaded on system startup, the use of the init script is -recommended for manual (un-)loading.} (see \autoref{sec:system}), the init -script and the sysconfig file (or the systemd service file, respectively) have -to be copied (or linked) to the appropriate locations. The below example is -suitable for SUSE Linux. It may vary for other distributions. - -% FIXME relative ln -s? -\begin{lstlisting} -# `\textbf{cd /opt/etherlab}` -# `\textbf{cp etc/sysconfig/ethercat /etc/sysconfig/}` -# `\textbf{ln -s etc/init.d/ethercat /etc/init.d/}` -# `\textbf{insserv ethercat}` -\end{lstlisting} - Now the sysconfig file \texttt{/etc/sysconfig/ethercat} (see \autoref{sec:sysconfig}), or the configuration file \textit{/etc/ethercat.conf}, if using systemd, has to be customized. The @@ -3435,13 +3420,13 @@ After the basic configuration is done, the master can be started with the below command: \begin{lstlisting} -# `\textbf{/etc/init.d/ethercat start}` +# `\textbf{systemctl start ethercat}` \end{lstlisting} -When using systemd, the following command can be used alternatively: +When using init.d, the following command can be used alternatively: \begin{lstlisting} -# `\textbf{ethercatctl start}` +# `\textbf{/etc/init.d/ethercat start}` \end{lstlisting} At this time, the operation of the master can be observed by viewing the diff --git a/documentation/ethercat_doc_fr.tex b/documentation/ethercat_doc_fr.tex index 3a2e101b..32287035 100644 --- a/documentation/ethercat_doc_fr.tex +++ b/documentation/ethercat_doc_fr.tex @@ -3117,8 +3117,8 @@ bloc sp\'ecial de commentaires. Les outils syst\`emes peuvent extraire cette information pour ins\'erer le script d'initialisation EtherCAT \`a la bonne position dans la s\'equence de d\'emarrage: -\lstinputlisting[firstline=38,lastline=48] - {../script/init.d/ethercat} +\lstinputlisting[firstline=36,lastline=46,basicstyle=\ttfamily\scriptsize] + {../script/init.d/ethercat.in} \subsection{Fichier sysconfig} \label{sec:sysconfig} @@ -3131,8 +3131,8 @@ sysconfig contient toutes les variables de configuration requises pour op\'erer un ou plusieurs ma\^itres. La documentation se trouve dans le fichier et elle est reproduite ci-dessous: -\lstinputlisting[numbers=left,firstline=9,basicstyle=\ttfamily\scriptsize] - {../script/sysconfig/ethercat} +\lstinputlisting[numbers=left,firstline=11,basicstyle=\ttfamily\scriptsize,language=sh,escapechar={}] + {../script/ethercat.conf} Pour les syst\`emes g\'er\'es par systemd (voir \autoref{sec:systemd}), le fichier sysconfig a \'et\'e d\'eplac\'e dans \lstinline+/etc/ethercat.conf+. @@ -3175,20 +3175,19 @@ d'initialisation SysV utilisent des fichiers de service pour d\'ecrire comment un service doit \^etre maintenu. \autoref{lst:service} liste le fichier de service du ma\^itre: -\lstinputlisting[basicstyle=\ttfamily\footnotesize,caption=Service - file, label=lst:service]{../script/ethercat.service} +\lstinputlisting[basicstyle=\ttfamily\scriptsize,caption=Service file,label=lst:service] + {../script/ethercat.service.in} -La commande \textit{ethercatctl} est utilis\'ee pour charger et +La commande \textit{systemctl} est utilis\'ee pour charger et d\'echarger le ma\^itre et les modules des pilotes r\'eseaux de la m\^eme mani\`ere que l'ancien script d'initialisation -(\autoref{sec:init}). Puisqu'il est install\'e dans le dossier -\textit{sbin/}, il peut aussi \^etre utilis\'e s\'epar\'ement: +(\autoref{sec:init}). \begin{lstlisting}[gobble=2] - # `\textbf{ethercatctl start}` + # `\textbf{systemctl start ethercat}` \end{lstlisting} -Lorsqu'on utilise systemd et/ou la commande \textit{ethercatctl}, le +Lorsqu'on utilise systemd et/ou la commande \textit{systemctl}, le fichier de configuration du ma\^itre doit \^etre dans \texttt{/etc/ethercat.conf} au lieu de \texttt{/etc/sysconfig/ethercat}! Celui-ci est ignor\'e. Les options @@ -3648,6 +3647,7 @@ script d'initialisation. \begin{lstlisting} # `\textbf{make install}` # `\textbf{make modules\_install}` +# `\textbf{depmod}` \end{lstlisting} Si le dossier de destination des modules noyaux ne se trouve dans @@ -3662,23 +3662,6 @@ Ce commande installe les modules noyaux compil\'es dans \textit{/vol/nfs/root/lib/modules}, auquel on ajoute la version du noyau. -Si le ma\^itre EtherCAT doit s'ex\'ecuter en tant que -service\footnote{ m\^eme si le ma\^itre EtherCAT ne doit pas \^etre - charg\'e au d\'emarrage, l'utilisation du script d'initialisation - est recommand\'e pour le (d\'e-)chargement manuel.} (voir -\autoref{sec:system}), le script d'initialisation et le fichier -sysconfig (ou le fichier de service systemd, respectivement) doivent -\^etre copi\'es (ou li\'e) dans les emplacements appropri\'es. -L'exemple ci-dessous convient pour SUSE Linux. Il peut \^etre -diff\'erent pour les autres distributions. - -% FIXME relative ln -s? -\begin{lstlisting} -# `\textbf{cd /opt/etherlab}` -# `\textbf{cp etc/sysconfig/ethercat /etc/sysconfig/}` -# `\textbf{ln -s etc/init.d/ethercat /etc/init.d/}` -# `\textbf{insserv ethercat}` -\end{lstlisting} Maintenant le fichier de configuration \texttt{/etc/sysconfig/ethercat} (voir \autoref{sec:sysconfig}) ou @@ -3694,14 +3677,14 @@ Apr\`es que la d\'efinition de la configuration de base, le ma\^itre peut \^etre d\'emarr\'e avec la commande ci-dessous: \begin{lstlisting} -# `\textbf{/etc/init.d/ethercat start}` +# `\textbf{systemctl start ethercat}` \end{lstlisting} -Lorsqu'on utilise systemd, la commande suivante peut \^etre utilis\'ee +Lorsqu'on utilise init.d, la commande suivante peut \^etre utilis\'ee \`a la place: \begin{lstlisting} -# `\textbf{ethercatctl start}` +# `\textbf{/etc/init.d/ethercat start}` \end{lstlisting} A partir de cet instant, l'op\'eration du ma\^itre peut \^etre oberv\'ee