システムサービスが起動時に開始されないが手動で起動できるのはなぜですか?

システムサービスが起動時に開始されないが手動で起動できるのはなぜですか?

コンピュータの起動時にワイヤレスアクセスポイントを起動するためのsystemdサービスを作成しました。私の問題は、コンピュータが起動したときに実際に起動しないため、その理由がわからないようです。サービスを手動で開始しても問題ありません。

マイwap.serviceシステムデバイスファイル:

[Unit]
Description=Enable the Wireless Access Point
Requires=dnsmasq.service iptables.service NetworkManager.service
Before=dnsmasq.service
After=iptables.service NetworkManager.service

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/project/wap.sh
TimeoutStartSec=0

[Install]
WantedBy=default.target

/project/wap.sh(中括弧はAnsible / Jinja2変数の置換です。):

#!/usr/bin/env bash

set -Eeuo pipefail

# Allow incoming DNS requests.
iptables -I INPUT -p udp --dport 53 -j ACCEPT -m comment --comment "DNS"

# Allow incoming DHCP requests.
iptables -I INPUT -p udp --dport 67 -j ACCEPT -m comment --comment "DHCP"

# Relinquish NetworkManager control over the wireless network interface.
nmcli r wifi off
rfkill unblock wifi

# Up and configure the wireless network interface.
ifconfig {{ap_interface}} 192.168.2.1 up
route add -net 0.0.0.0 netmask 255.255.255.0 gw 192.168.2.1 || true

# Restart hostapd so it can successfully bind to the newly configured wireless network interface.
service hostapd restart

関連/usr/lib/systemd/systemd --test --system --unit=default.target出力:

    -> Unit wap.service:
        Description: Enable the Wireless Access Point
        Instance: n/a
        Unit Load State: loaded
        Unit Active State: inactive
        Inactive Exit Timestamp: n/a
        Active Enter Timestamp: n/a
        Active Exit Timestamp: n/a
        Inactive Enter Timestamp: n/a
        GC Check Good: no
        Need Daemon Reload: no
        Transient: no
        Slice: system.slice
        CGroup: n/a
        CGroup realized: no
        CGroup mask: 0x0
        CGroup members mask: 0x0
        Name: wap.service
        Fragment Path: /etc/systemd/system/wap.service
        Requires: dnsmasq.service
        Requires: NetworkManager.service
        Requires: basic.target
        Requires: iptables.service
        Wants: system.slice
        WantedBy: multi-user.target
        Conflicts: shutdown.target
        Before: dnsmasq.service
        Before: multi-user.target
        Before: shutdown.target
        After: systemd-journald.socket
        After: iptables.service
        After: NetworkManager.service
        After: system.slice
        After: basic.target
        References: systemd-journald.socket
        References: iptables.service
        References: NetworkManager.service
        References: system.slice
        References: dnsmasq.service
        References: shutdown.target
        References: basic.target
        ReferencedBy: multi-user.target
        StopWhenUnneeded: no
        RefuseManualStart: no
        RefuseManualStop: no
        DefaultDependencies: yes
        OnFailureJobMode: replace
        IgnoreOnIsolate: no
        IgnoreOnSnapshot: no
        Service State: dead
        Result: success
        Reload Result: success
        PermissionsStartOnly: no
        RootDirectoryStartOnly: no
        RemainAfterExit: yes
        GuessMainPID: yes
        Type: oneshot
        Restart: no
        NotifyAccess: none
        NotifyState: unknown
        KillMode: control-group
        KillSignal: SIGTERM
        SendSIGKILL: yes
        SendSIGHUP:  no
        UMask: 0022
        WorkingDirectory: /
        RootDirectory: /
        NonBlocking: no
        PrivateTmp: no
        PrivateNetwork: no
        PrivateDevices: no
Loaded units and determined initial transaction in 75ms.        ProtectHome: no
        ProtectSystem: no

        IgnoreSIGPIPE: yes
        LimitNOFILE: 1024 4096
        StandardInput: null
        StandardOutput: journal
        StandardError: inherit
        SyslogFacility: daemon
        SyslogLevel: info
        -> ExecStart:
            Command Line: /project/wap.sh

再起動後のサービス状態:

$ sudo service wap status -l
Redirecting to /bin/systemctl status  -l wap.service
● wap.service - Enable the Wireless Access Point
   Loaded: loaded (/etc/systemd/system/wap.service; enabled; vendor preset: disabled)
   Active: inactive (dead)

手動起動後のサービス状態:

$ sudo service wap start
Redirecting to /bin/systemctl start wap.service
$ sudo service wap status -l
Redirecting to /bin/systemctl status  -l wap.service
● wap.service - Enable the Wireless Access Point
   Loaded: loaded (/etc/systemd/system/wap.service; enabled; vendor preset: disabled)
   Active: active (exited) since do 2019-09-26 12:10:40 BST; 6s ago
  Process: 8589 ExecStart=/project/wap.sh (code=exited, status=0/SUCCESS)
 Main PID: 8589 (code=exited, status=0/SUCCESS)

sep 26 12:10:40 localhost.localdomain systemd[1]: Starting Enable the Wireless Access Point...
sep 26 12:10:40 localhost.localdomain wap.sh[8589]: Redirecting to /bin/systemctl restart hostapd.service
sep 26 12:10:40 localhost.localdomain systemd[1]: Started Enable the Wireless Access Point.

journalctl出力:

$ journalctl -u wap
-- No entries --

マシンの起動時に決して実行されないことを確認しましたが、wap.shシステムログにこのサービスの起動試行などの情報が見つかりませんでした。

長すぎます。起動時にサービスを開始する必要がありますが、そうでない理由を理解できません。

ベストアンサー1

たぶんそれは簡単ですか? :

systemctl は wap.service を有効にします。

おすすめ記事