3

我正在尝试设置一个 Systemd 服务,该服务将在暂停恢复后重新启动我的 VPN 连接(ProtonVPN)。做我需要的命令是sudo protonvpn r. 所以这就是我所做的:我创建了一个 service /etc/systemd/system/protonvpn-restart.service,其中包含以下内容:

[Unit]
Description=Restart ProtonVPN after suspend
After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

[Service]
ExecStart=/bin/pvpn-resume
User=root

[Install]
WantedBy=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

和一个包含以下内容的脚本/bin/pvpn-resume(我确保它是可执行的):

#!/bin/sh

protonvpn r

然后我跑了sudo systemctl start protonvpn-restart.service && sudo systemctl enable protonvpn-restart.service。但最后,当我暂停并返回时,VPN 不会重新启动,我的 Internet 将无法工作,直到我手动运行sudo protonvpn r。任何人都可以帮忙吗?

4

0 回答 0