맛집 여행 캠핑 일상 생활

[Proxmox] 부팅시 시작 스크립트 등록 방법 본문

Proxmox

[Proxmox] 부팅시 시작 스크립트 등록 방법

영은파더♥ 2024. 9. 23. 16:22
반응형

Proxmox 는 일반 리눅스 처럼 rc.local 파일이 없어서 시작시 제가 못 찾은건지 실행할 수 있는 방법이 없나보네요~

그래서 /etc/init.d 디렉토리에 스크립트로 한번 만들어보았습니다.

touch /etc/init.d/example.sh
chmod +x /etc/init.d/example.sh

vi /etc/init.d/example.sh

#!/bin/sh
### BEGIN INIT INFO
# Provides:          example.sh
# Required-Start:    $network
# Required-Stop:     $network
# Should-Start:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# X-Interactive:     true
# Short-Description: Example desc
# Description:       Example desc
### END INIT INFO

case "$1" in
    start)
        echo "start";
        ;;

    stop)
        echo "stop";
        ;;

    restart|force-reload)
        $0 stop
        $0 start
        ;;

    status)
        echo "status";
        ;;

    *)
        echo "Usage: /etc/init.d/example.sh {start|stop|restart|force-reload|status}"
        exit 1
        ;;
esac

exit 0

start, stop, status 엔 원하시는 내용으로 수정하시면 됩니다.

이제 /etc/rc0.d ~ rc6.d 에 심볼릭링크를 걸어줍니다.

ln -s /etc/init.d/example.sh /etc/rc0.d/K01example.sh
ln -s /etc/init.d/example.sh /etc/rc1.d/K01example.sh
ln -s /etc/init.d/example.sh /etc/rc2.d/S01example.sh
ln -s /etc/init.d/example.sh /etc/rc3.d/S01example.sh
ln -s /etc/init.d/example.sh /etc/rc4.d/S01example.sh
ln -s /etc/init.d/example.sh /etc/rc5.d/S01example.sh
ln -s /etc/init.d/example.sh /etc/rc6.d/K01example.sh

run-level 에 맞게 네이밍을 하시면 됩니다.

# Default-Start:     2 3 4 5 => S01example.sh
# Default-Stop:      0 1 6 => K01example.sh

제대로 되는지 재부팅 하시면 됩니다.

 

반응형
Trackback : | Comments :