Loading…
The basic ideas behind BSD <filename>rc.d</filename> are <emphasis>fine modularity</emphasis> and <emphasis>code reuse</emphasis>. <emphasis>Fine modularity</emphasis> means that each basic <quote>service</quote> such as a system daemon or primitive startup task gets its own <citerefentry><refentrytitle>sh</refentrytitle><manvolnum>1</manvolnum></citerefentry> script able to start the service, stop it, reload it, check its status. A particular action is chosen by the command-line argument to the script. The <filename>/etc/rc</filename> script still drives system startup, but now it merely invokes the smaller scripts one by one with the <option>start</option> argument. It is easy to perform shutdown tasks as well by running the same set of scripts with the <option>stop</option> argument, which is done by <filename>/etc/rc.shutdown</filename>. Note how closely this follows the Unix way of having a set of small specialized tools, each fulfilling its task as well as possible. <emphasis>Code reuse</emphasis> means that common operations are implemented as <citerefentry><refentrytitle>sh</refentrytitle><manvolnum>1</manvolnum></citerefentry> functions and collected in <filename>/etc/rc.subr</filename>. Now a typical script can be just a few lines' worth of <citerefentry><refentrytitle>sh</refentrytitle><manvolnum>1</manvolnum></citerefentry> code. Finally, an important part of the <filename>rc.d</filename> framework is <citerefentry><refentrytitle>rcorder</refentrytitle><manvolnum>8</manvolnum></citerefentry>, which helps <filename>/etc/rc</filename> to run the small scripts orderly with respect to dependencies between them. It can help <filename>/etc/rc.shutdown</filename>, too, because the proper order for the shutdown sequence is opposite to that of startup.
Las ideas básicas detrás de BSD <filename>rc.d</filename> son <emphasis>fina modularidad</emphasis> Y <emphasis>reutilización de código</emphasis>. <emphasis>Fina modularidad</emphasis> Significa que cada básico <quote>servicio</quote> como un demonio del sistema o una tarea de inicio primitiva, obtiene su propia <citerefentry><refentrytitle>sh</refentrytitle><manvolnum>1</manvolnum></citerefentry> script capaz de iniciar el servicio, detenerlo, recargarlo, verificar su estado. Una acción particular se elige mediante el argumento de la línea de comandos del script. los <filename>/etc/rc</filename> El script todavía impulsa el inicio del sistema, pero ahora simplemente invoca los scripts más pequeños uno por uno con el <option>start</option> argumento. También es fácil realizar tareas de apagado ejecutando el mismo conjunto de scripts con el <option>stop</option> argumento, que es hecho por <filename>/etc/rc.shutdown</filename>. Tenga en cuenta lo cerca que sigue la forma Unix de tener un conjunto de pequeñas herramientas especializadas, cada una cumpliendo su tarea lo mejor posible. <emphasis>Reutilización de código</emphasis> significa que las operaciones comunes se implementan como <citerefentry><refentrytitle>sh</refentrytitle><manvolnum>1</manvolnum></citerefentry> funciones y recogidas en <filename>/etc/rc.subr</filename>. Ahora, un script típico puede tener solo unas pocas líneas de <citerefentry><refentrytitle>sh</refentrytitle><manvolnum>1</manvolnum></citerefentry> código. Finalmente, una parte importante de la <filename>rc.d</filename> marco es <citerefentry><refentrytitle>rcorder</refentrytitle><manvolnum>8</manvolnum></citerefentry>, que ayuda <filename>/etc/rc</filename>para ejecutar los pequeños scripts de forma ordenada con respecto a las dependencias entre ellos. Puede ayudar <filename>/etc/rc.shutdown</filename>, también, porque el orden correcto para la secuencia de apagado es opuesto al de inicio.