/etc/rc.local과 /etc/init.d/rc.local의 차이점은 무엇입니까?

/etc/rc.local과 /etc/init.d/rc.local의 차이점은 무엇입니까?

iptables새 규칙에 영구 규칙을 추가하고 싶은데 VPS, 간단한 Google 검색 후에 이 규칙을 추가할 수 있는 두 곳이 동일해 보이는 것을 발견하고 놀랐 /etc/rc.local습니다 /etc/init.d/rc.local. 간단한 시작 코드를 넣을 수 있는 위치가 두 군데인 이유를 아는 사람이 있을까요? Linux 버전에만 해당됩니까(하지만 우분투에는 둘 다 있습니다!)? 아니면 그 중 하나가 더 이상 사용되지 않습니까?

답변1

/etc/init.dsysvinit과의 하위 호환성을 위해 우분투에서 유지 관리됩니다. 실제로 살펴보면 다음과 같은 내용을 /etc/init.d/rc.local볼 수 있습니다(12.04 LTS 서버에서도 마찬가지).

#! /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

그리고"/etc/rc.local 실행"정확히 그것이 하는 일입니다. 전체 텍스트 /etc/rc.local는 다음과 같습니다.

#!/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

내 생각에 이것의 목적은 /etc/init.d/rc.local.

따라서 이는 실제로 서비스이며 다음과 같이 실행될 수 있습니다. 나는 한 줄을 추가했고 echo:/etc/rc.local

»service rc.local start
hello world

그러나 나는 upstart의 (init.d가 아닌!) 디렉토리 /etc/init에 있는 어떤 것도 이를 참조한다고 믿지 않습니다.

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

upstart에는 몇 가지 "rc" 서비스가 있습니다.

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

하지만 이 중 어느 것도 rc.local과 관련이 없는 것 같습니다.

답변2

이것은 배포판과 관련된 것입니다. (예를 들어 CentOS에서는 다른 rc.local을 찾을 수 없습니다).

이제 실제 질문에 이르면 /etc/init.d/rc.local에 무엇이든 추가하면 "서비스"로 시작되지만 /etc/rc.local에 있는 내용은 스크립트 시작만 가능하다고 생각합니다.

왜 우분투에 아직도 그것들이 있는지 잘 모르겠습니다. (어쩌면 다른 분이 이 부분을 밝혀줄 수도 있겠네요!!)

관련 정보