From d1b52105553490825c111910313e7ecb79eae822 Mon Sep 17 00:00:00 2001 From: wmcheng Date: Sun, 1 Mar 2020 17:53:56 +0800 Subject: [PATCH] Update initialization steps --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f336e8f..824659a 100644 --- a/README.md +++ b/README.md @@ -206,8 +206,16 @@ $ sudo logrotate -d /etc/logrotate.conf # 確認系統是否有使用 /etc/logro ### 四、主機開機網站自動起始 ```sh # 開機網站自動起始 -$ sudo vim /etc/init.d/orbit # 內容建附註 orbit +$ sudo vim /etc/init.d/orbit # 內容見附註 orbit $ sudo chmod 755 /etc/init.d/orbit +$ update-rc.d orbit defaults +$ sudo vim /etc/init.d/rc.local #內容見附註 rc.local1 +$ sudo chmod 755 /etc/init.d/rc.local +$ sudo vim /etc/rc.local #內容見附註 rc.local +$ sudo chmod 755 /etc/rc.local +$ update-rc.d rc.local defaults +$ sudo systemctl start orbit +$ sudo systemctl start rc.local # ``` @@ -438,4 +446,58 @@ setup) exit 1 ;; esac -``` \ No newline at end of file +``` + +```txt +# 附註 rc.local1 +#! /bin/sh +### BEGIN INIT INFO +# Provides: rc.local +# Required-Start: $all +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: Run /etc/rc.local if it exist +### END INIT INFO + + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +. /lib/init/vars.sh +. /lib/lsb/init-functions + +do_start() { + if [ -x /etc/rc.local ]; then + [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)" + /etc/rc.local + ES=$? + [ "$VERBOSE" != no ] && log_end_msg $ES + return $ES + fi +} + +case "$1" in + start) + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac +``` + +```txt +# 附註 rc.local1 +#! /bin/sh +sudo mongod --config /etc/mongod.conf & +exit 0 +``` + +