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 

 

 

 

 

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