2015-08-23 261 views
0

我寫了下面的systemd服務在無線登錄在系統啓動:無法啓動systemd服務

[Unit] 
Description=Wireless network connectivity (%i) 
Wants=network.target 
Before=network.target 
BindsTo=sys-subsystem-net-devices-%i-device 
After=sys-subsystem-net-devices-%i-device 

[Service] 
Type=oneshot 
RemainAfterExit=yes 

ExecStart=/usr/bin/ip link set dev %i up 
ExecStart=/usr/bin/wpa_supplicant -B -i %i -c /etc/wpa_supplicant/wpa_supplicant.conf 
ExecStart=/usr/bin/dhcpcd %i 

ExecStop=/usr/bin/ip link set dev %i down 

[Install] 
WantedBy=multi-user.target 

我那麼enable,但每次我碰到下面的錯誤我啓動我的電腦:

[[email protected] ~]$ systemctl --failed 
    UNIT       LOAD ACTIVE SUB DESCRIPTION 
● [email protected] loaded failed failed Wireless network connectivity (wlp3s0) 

但是,如果我開機後手動啓動該服務:

systemctl start [email protected] 

的SERVIC e按預期開始。

這是

ctrl_interface=/var/run/wpa_supplicant 
ctrl_interface_group=wheel 
network={ 
     ssid="TeliaGateway30-91-8F-1C-B2-29" 
     #psk="A80871A90A" 
     psk=b4d8a1e9ad665eed0178fea6f141134e795e15183a661848b371a41bb73a6844 
} 

這是爲什麼服務開始確定在啓動手動,但沒有啓動的時候它的wpa_supplicant.conf的內容以及如何將其更改爲在開機啓動?

編輯:添加錯誤輸出: 這是錯誤即時得到:

[[email protected] ~]$ journalctl -b -u [email protected] 
-- Logs begin at Sat 2015-08-22 12:50:42 CEST, end at Sun 2015-08-23 22:15:26 CEST. -- 
Aug 23 21:23:36 arch systemd[1]: Starting Wireless network connectivity (wlp3s0)... 
Aug 23 21:23:36 arch ip[274]: Cannot find device "wlp3s0" 
Aug 23 21:23:36 arch systemd[1]: [email protected]: Main process exited, code=exited, status=1/FAILURE 
Aug 23 21:23:36 arch systemd[1]: Failed to start Wireless network connectivity (wlp3s0). 
Aug 23 21:23:37 arch systemd[1]: [email protected]: Unit entered failed state. 
Aug 23 21:23:37 arch systemd[1]: [email protected]: Failed with result 'exit-code'. 
Aug 23 21:25:11 arch systemd[1]: Starting Wireless network connectivity (wlp3s0)... 
Aug 23 21:25:11 arch dhcpcd[424]: wlp3s0: waiting for carrier 
Aug 23 21:25:16 arch dhcpcd[424]: wlp3s0: carrier acquired 
Aug 23 21:25:16 arch dhcpcd[424]: DUID 00:01:00:01:1d:6b:6b:e6:10:0d:7f:b7:30:f3 
Aug 23 21:25:16 arch dhcpcd[424]: wlp3s0: IAID c1:c4:73:e0 
Aug 23 21:25:16 arch dhcpcd[424]: wlp3s0: soliciting an IPv6 router 
Aug 23 21:25:16 arch dhcpcd[424]: wlp3s0: rebinding lease of 192.168.1.85 
Aug 23 21:25:21 arch dhcpcd[424]: wlp3s0: leased 192.168.1.85 for 3600 seconds 
Aug 23 21:25:21 arch dhcpcd[424]: wlp3s0: adding route to 192.168.1.0/24 
Aug 23 21:25:21 arch dhcpcd[424]: wlp3s0: adding default route via 192.168.1.1 
Aug 23 21:25:21 arch dhcpcd[424]: forked to background, child pid 477 
Aug 23 21:25:21 arch dhcpcd[424]: wlp3s0: waiting for carrier 
Aug 23 21:25:21 arch dhcpcd[424]: wlp3s0: carrier acquired 
Aug 23 21:25:21 arch dhcpcd[424]: DUID 00:01:00:01:1d:6b:6b:e6:10:0d:7f:b7:30:f3 
Aug 23 21:25:21 arch dhcpcd[424]: wlp3s0: IAID c1:c4:73:e0 
Aug 23 21:25:21 arch dhcpcd[424]: wlp3s0: soliciting an IPv6 router 
Aug 23 21:25:21 arch dhcpcd[424]: wlp3s0: rebinding lease of 192.168.1.85 
Aug 23 21:25:21 arch dhcpcd[424]: wlp3s0: leased 192.168.1.85 for 3600 seconds 
Aug 23 21:25:21 arch dhcpcd[424]: wlp3s0: adding route to 192.168.1.0/24 
Aug 23 21:25:21 arch dhcpcd[424]: wlp3s0: adding default route via 192.168.1.1 
Aug 23 21:25:21 arch dhcpcd[424]: forked to background, child pid 477 
Aug 23 21:25:21 arch systemd[1]: Started Wireless network connectivity (wlp3s0). 
Aug 23 21:25:28 arch dhcpcd[477]: wlp3s0: no IPv6 Routers available 
Aug 23 22:15:09 arch dhcpcd[477]: wlp3s0: carrier lost 
Aug 23 22:15:09 arch dhcpcd[477]: wlp3s0: deleting route to 192.168.1.0/24 
Aug 23 22:15:09 arch dhcpcd[477]: wlp3s0: deleting default route via 192.168.1.1 
Aug 23 22:15:13 arch dhcpcd[477]: wlp3s0: carrier acquired 
Aug 23 22:15:14 arch dhcpcd[477]: wlp3s0: IAID c1:c4:73:e0 
Aug 23 22:15:14 arch dhcpcd[477]: wlp3s0: soliciting an IPv6 router 
Aug 23 22:15:14 arch dhcpcd[477]: wlp3s0: rebinding lease of 192.168.1.85 
Aug 23 22:15:19 arch dhcpcd[477]: wlp3s0: leased 192.168.1.85 for 3600 seconds 
Aug 23 22:15:19 arch dhcpcd[477]: wlp3s0: adding route to 192.168.1.0/24 
Aug 23 22:15:19 arch dhcpcd[477]: wlp3s0: adding default route via 192.168.1.1 
Aug 23 22:15:19 arch dhcpcd[477]: wlp3s0: removing route to 192.168.1.0/24 
Aug 23 22:15:26 arch dhcpcd[477]: wlp3s0: no IPv6 Routers available 

編輯: 我發現一個potetential錯誤,它好像網絡接口引導過程中不會爲wlan0改名,但是我試着用wlan0啓動服務,但結果沒有任何變化。

+0

什麼錯誤是系統報告的服務? – larsks

+0

我該如何檢查? – user3139545

+0

嘗試運行:'systemctl status network-wireless @ wlp3s0.service'或'journalctl -b' – rodrigo

回答

0

服務在啓動時停止的原因是因爲ip命令無法找到該接口。根據systemd services的手冊頁,這是足夠的理由失敗的服務。

正如你注意到自己界面被重新命名或尚未準備好在啓動。

  • 您可以檢查,如果你需要添加一個After=聲明
  • 你可以用systemd-analyse命令檢查,如果在開機的順序是正確的
  • 你可以分裂的服務,使其更加堅固。即使界面尚未準備好,大多數守護進程也可以正常啓動。

    就我個人而言,我會使dhcpd和wpa_supplicant單獨的服務,並使用systemd的networkd或udev規則來調出接口(如果甚至需要)有很多wpa_supplicant和dhcpd的單元文件的例子在線也許有看看那些?