CubieTruck 測試 – Fedora 20 rc.local

etc/rc.local 或 /etc/rc.d/rc.local 是 Linux 中一個系統開機快要完成時,會執行的一個檔案,有點像是 DOS 中的 autoexec.bat。Fedora 20 中似乎沒有這一個檔案,要自己手動加上去。
# vim /etc/rc.d/rc.local
#!/bin/bash
# 打開鍵盤上的 Num Lock
[ -x /usr/bin/numlockx ] && numlockx on

更改檔案權限
# chmod 755 /etc/rc.d/rc.local

重新開機後,發現 numlock 燈有亮,但也出現了一些錯誤訊息
[@more@]檢查 rc-local 服務出現的錯誤訊息
# systemctl status rc-local.service
rc-local.service – /etc/rc.d/rc.local Compatibility
   Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static)
   Active: failed (Result: exit-code) since 一 2014-10-20 14:31:58 CST; 6min ago

10月 20 14:31:58 localhost systemd[1]: Starting /etc/rc.d/rc.local Compatibility…
10月 20 14:31:58 localhost systemd[1]: rc-local.service: control process exited, code=exited status=1
10月 20 14:31:58 localhost systemd[1]: Failed to start /etc/rc.d/rc.local Compatibility.
10月 20 14:31:58 localhost systemd[1]: Unit rc-local.service entered failed state.

啟動 rc-local 服務時出現的錯誤訊息,看起來好像 /usr/lib/systemd/system/rc-local.service 缺少了 Install 的區段
# systemctl enable rc-local
The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit’s
   .wants/ or .requires/ directory.
2) A unit’s purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, …).

/usr/lib/systemd/system/rc-local.service 最後面加入下面區段
[Install]
WantedBy=multi-user.target

# sed -i ‘$a[Install]nWantedBy=multi-user.target’ /usr/lib/systemd/system/rc-local.service
[Install]
WantedBy=multi-user.target

開機啟動 rc.local 服務
# systemctl enable rc-local
ln -s ‘/usr/lib/systemd/system/rc-local.service’ ‘/etc/systemd/system/multi-user.target.wants/rc-local.service’

查 rc-local 服務狀態
# systemctl status rc-local.service
rc-local.service – /etc/rc.d/rc.local Compatibility
   Loaded: loaded (/usr/lib/systemd/system/rc-local.service; enabled)
   Active: active (exited) since 一 2014-10-20 14:46:42 CST; 11s ago
  Process: 1961 ExecStart=/etc/rc.d/rc.local start (code=exited, status=0/SUCCESS)

10月 20 14:46:42 localhost systemd[1]: Started /etc/rc.d/rc.local Compatibility.