次のサービス構成があります。
$ systemctl cat bluetooth
# /lib/systemd/system/bluetooth.service
[Unit]
Description=Bluetooth service
Documentation=man:bluetoothd(8)
ConditionPathIsDirectory=/sys/class/bluetooth
[Service]
Type=dbus
BusName=org.bluez
ExecStart=/usr/lib/bluetooth/bluetoothd
NotifyAccess=main
#WatchdogSec=10
#Restart=on-failure
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
LimitNPROC=1
#RestartSec=5
[Install]
WantedBy=bluetooth.target suspend.target
Alias=dbus-org.bluez.service
suspend.target
パラメータ(WantedBy=
)の[Install]
パラメータにman systemd.unit
を追加して、再開時にサービスを再開できるようにしましたが、これは機能しません。
EDIT0:サービスはサスペンド時に停止しませんが、このサービスは私の構成でサスペンド/レジューム操作をサポートしていないため、再開後に再起動する必要があります。
EDIT1:suspend.target
によれば、man systemd.special
も機能するはずです。
suspend.target A special target unit for suspending the system. This pulls in sleep.target.
EDIT2:コマンドSudo systemctl edit --full bluetooth
がbluetooth.service
に/etc/systemd/system/bluetooth.service
の別のコピーを作成したようですが、ファイルが保存されると(/lib/systemd/system/bluetooth.service
とは)異なります。
bluetooth.service
の2つの異なるバージョンがあることに気付いたので、少し混乱しました。
再開時にsystemdサービスを再起動する方法は?
新しいsystemdサービスを作成します。
Sudo vim.tiny /lib/systemd/system/blrestart.service
Sudo ln -s /lib/systemd/system/blrestart.service /etc/systemd/system/
その隣に貼り付けます:
[Unit]
Description=Restart Bluetooth after resume
After=suspend.target
[Service]
Type=simple
ExecStart=/bin/systemctl --no-block restart bluetooth.service
# ExecStart=/usr/bin/systemctl --no-block restart bluetooth.service
[Install]
WantedBy=suspend.target
新しく作成したサービスを有効にして開始します。
Sudo systemctl enable blrestart && Sudo systemctl start blrestart
/usr/lib/pm-utils/sleep.d
を使用してみてください そこでスクリプトを作成 :
# 70yourservice
case $1 in
hibernate)
echo "Hey guy, we are going to suspend to disk!"
;;
suspend)
echo "Oh, this time we are doing a suspend to RAM. Cool!"
;;
thaw)
echo "Oh, suspend to disk is over, we are resuming..."
;;
resume)
systemctl restart yourservice.service
;;
*) echo "Somebody is calling me totally wrong."
;;
esac
忘れないでくださいSudo chmod +x /usr/lib/pm-utils/sleep.d/70yourservice