openSUSE 12.1啓動沒有(不能)運行after.local的問題

在openSUSE 12.1中,默認的/etc/init.d/after.local不執行,先介紹下after.local

 在openSUSE中沒有redhat,centos系的rc.local,作爲代替的有boot.local,before.local和after.local,這3個文件都在/etc/init.d/目錄下

  • boot.local

    系統中運行rc啓動腳本之前會執行這個文件,所以這個文件執行時候系統的網絡是沒有的

  • befor.local

    該文件在也是在rc啓動腳本之前執行,但是會在boot.local之後執行。

  • after.local

    該文件在rc啓動腳本之後執行。類似redhat,centos系的rc.local

但是我安裝了openSUSE之後,需要開機自動啓動一些腳本,但是after.local就是不會執行,問google之後,只有一個老外說了此問題,下面是解決方法:

  1. 我們需要創建一個after-local.server的文件在/lib/systemd/system目錄中,可以在openSUSE的KDE桌面下按快捷鍵Alt + F2,然後輸入下面命令很回車
  2. kdesu kwrite /lib/systemd/system/after-local.service 

    把下面內容複製到文件中並保存:

  3. 
    #  This file is part of systemd.
    #
    # systemd is free software; you can redistribute it and/or modify it
    # under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 2 of the License, or
    # (at your option) any later version.

    [Unit]
    Description=/etc/init.d/after.local Compatibility
    ConditionFileIsExecutable=/etc/init.d/after.local

    [Service]
    Type=oneshot
    ExecStart=/etc/init.d/after.local
    TimeoutSec=0
    StandardOutput=tty
    RemainAfterExit=yes
    SysVStartPriority=99

    [Install]
    WantedBy=multi-user.target

  4. 我們需要把after-local.service加入到systemd中。打開你的終端(Termial),執行下面命令:
sudo systemctl enable /lib/systemd/system/after-local.service 
  1. 最後我們編輯/etc/init.d/after.local加入你的啓動腳本即可,繼續Alt+F2執行下面命令
kdesu kwrite /etc/init.d/after.local 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章