configuration – ¿Cuál es la diferencia entre /etc/rc.local y /etc/init.d/rc.local?

Pregunta:

Quiero agregar una regla iptables permanente a mi nuevo VPS , y después de una breve búsqueda en Google, me sorprendió que haya dos lugares en los que se puede agregar esta regla, que parece idéntica: /etc/rc.local y /etc/init.d/rc.local . Tal vez alguien sepa por qué hay dos lugares para colocar un código de inicio simple. ¿Es específico del sabor de Linux (¡pero ubuntu tiene ambos!)? ¿O uno de ellos está en desuso?

Respuesta:

/etc/init.d se mantiene en ubuntu para compatibilidad con versiones anteriores de sysvinit. Si realmente mira /etc/init.d/rc.local verá (también de un servidor LTS 12.04):

#! /bin/sh
### BEGIN INIT INFORMATION
# Provides:          rc.local
# Required-Start:    $remote_fs $syslog $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO

Y "Ejecutar /etc/rc.local" es exactamente lo que hace. La totalidad de /etc/rc.local es:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0

Supongo que el propósito de hacer esto es proporcionar un lugar muy simple para colocar los comandos de shell que desea ejecutar en el arranque, sin tener que lidiar con las cosas del servicio stop | start, que se encuentra en /etc/init.d/rc.local .

Entonces, de hecho, es un servicio y se puede ejecutar como tal. Agregué una línea de echo a /etc/rc.local y:

»service rc.local start
hello world

Sin embargo, no creo que se haga referencia a nada en el directorio /etc/init (no init.d!) De upstart:

»initctl start rc.local
initctl: Unknown job: rc.local

Hay algunos servicios "rc" en upstart:

»initctl list | grep rc
rc stop/waiting
rcS stop/waiting
rc-sysinit stop/waiting

Pero ninguno de ellos parece tener nada que ver con rc.local.

Leave a Comment

Your email address will not be published. Required fields are marked *

web tasarım