【问题标题】:How can i disable all systemd network configuration features and run my network initialize shell script?如何禁用所有 systemd 网络配置功能并运行我的网络初始化 shell 脚本?
【发布时间】:2019-07-13 13:17:03
【问题描述】:

我有一个网络初始化脚本而不是

  1. 运行 wpa_supplicant
  2. 运行 dhcpcd

configureWifi.sh

pkill -9 wpa_supplicant
pkill -9 dhcpcd

wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -B
dhcpcd wlan0

我想禁用所有 systemd 的“网络配置”功能 因为它们不工作并使我的系统在启动时挂起。 我只想启动 shell 脚本。

我的 systemd 单元描述文件如下所示:

/lib/systemd/system/goodwifi.service

[Unit]
description=Good wifi service, initializes wifi without networkmanger
[Service]
ExecStart=/root/configureWifi.sh
type=oneshot

[Install]
WantedBy=network.target
# systemctl enable goodwifi

然后重启后wifi没有配置。 当我手动运行此脚本时,它可以 100% 运行。

有什么建议吗?

【问题讨论】:

    标签: networking systemd


    【解决方案1】:

    您的服务可能在启动顺序中的错误时间运行。尝试至少添加AfterBeforeproperties 来配置它。
    我的建议是,让一切网络启动,然后启动您的服务。
    这是取自 OpenSuse 框中的 /etc/systemd/system/network.service

    [Unit]
    Description=Network Manager
    Documentation=man:NetworkManager(8)
    Wants=remote-fs.target network.target
    After=network-pre.target dbus.service
    Before=network.target
    

    另外,如果您的脚本位于标准 PATH 目录中会更好,也许是/usr/local/sbin

    ExecStart=/usr/local/sbin/configureWifi.sh
    

    检查服务启动顺序

    systemctl list-dependencies network.service
    
    network.service
    ● ├─dbus.socket
    ● ├─system.slice
    ● ├─network.target
    ● ├─remote-fs.target
    ● │ ├─iscsi.service
    ● │ └─remote-fs-pre.target
    ● └─sysinit.target
    ●   ├─detect-part-label-duplicates.service
    ●   ├─dev-hugepages.mount
    

    journalctl -b0 应该会告诉你脚本的运行情况。

    【讨论】:

      猜你喜欢
      • 2018-08-21
      • 2016-10-29
      • 2017-05-08
      • 2014-01-01
      • 1970-01-01
      • 2018-08-13
      • 2013-12-27
      • 1970-01-01
      • 2016-02-21
      相关资源
      最近更新 更多