如何在 Alpine Linux 上启动时自动启动 Wireguard (wg-quick)
如果你有 Wireguard 配置文件如 /etc/wireguard/wghome.conf,你可以使用 wg-quick up wghome 手动启动它,以下是如何在启动时自动启动它。感谢 Justin Ludwig 在 Serverfault 上 提供该 init 脚本的模板
创建 /etc/init.d/wg-quick-wghome:
wg_quick_openrc_init.sh
#!/sbin/openrc-run
description="wg-quick wghome"
depend() {
need net
need localmount
}
start() {
wg-quick up schlaftier
}
stop() {
wg-quick down schlaftier
}然后使其可执行:
chmod_wg_init.sh
chmod a+x /etc/init.d/wg-quick-wghome并启用它在启动时启动:
enable_wg_init.sh
rc-update add wg-quick-wghome default如果需要,立即启动它:
start_wg_init.sh
/etc/init.d/wg-quick-wghome start当然你可以添加多个这样的脚本。只需确保以不同方式命名它们并执行启用启动时启动所需的所有步骤。
Check out similar posts by category:
Alpine Linux, Networking, Wireguard
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow