Skip to content
SimpleTracker edited this page Jan 28, 2024 · 35 revisions

Systemd

普通服务

若以 Root 用户运行, 则:

  1. 放入 /etc/systemd/system/ (全局系统服务) 下;
  2. 重载 Systemd Daemon 以识别新服务: systemctl daemon-reload;
  3. 启动服务: systemctl start qbittorrent-clientblocker.service;
  4. 为服务设置开机自启 (可选): systemctl enable qbittorrent-clientblocker.service;

若以 普通 用户运行, 则:

  1. 放入 /etc/systemd/user/ (全局用户服务) 或 ~/.local/share/systemd/user/ (单用户服务) 下;
  2. 重载 Systemd Daemon 以识别新服务: systemctl --user daemon-reload;
  3. 启动服务: systemctl --user start qbittorrent-clientblocker.service;
  4. 为服务设置开机自启 (可选): systemctl --user enable qbittorrent-clientblocker.service;

qbittorrent-clientblocker.service

[Unit]
Description=qBittorrent-ClientBlocker service
Wants=network-online.target
After=qbittorrent-nox.service

[Service]
Type=simple
Restart=always
WorkingDirectory=%h/.config/qBittorrent-ClientBlocker/
ExecStart=/usr/local/bin/qBittorrent-ClientBlocker

[Install]
WantedBy=multi-user.target

实例化服务

  1. 放入 /etc/systemd/system/ (全局系统服务) 下;
  2. 重载 Systemd Daemon 以识别新服务: systemctl daemon-reload;
  3. 启动服务: systemctl start qbittorrent-clientblocker@实例.service;
  4. 为服务设置开机自启 (可选): systemctl enable qbittorrent-clientblocker@实例.service;

qbittorrent-clientblocker(at).service (替换 (at) 为 @)

[Unit]
Description=qBittorrent-ClientBlocker service
Wants=network-online.target
After=qbittorrent-nox.service

[Service]
Type=simple
Restart=always
User=%i
WorkingDirectory=/etc/qBittorrent-ClientBlocker/%i/
ExecStart=/usr/local/bin/qBittorrent-ClientBlocker

[Install]
WantedBy=multi-user.target

Thanks @amefs #9

Clone this wiki locally