Dim*_*las 9 startup shell-script alpine-linux
我已经完成了以下 shell 脚本,这些脚本/etc/issue使用所有非环回接口的当前 ip更新:
#!/bin/sh
echo "You can use one of the following ip addresses in order to look the page or even ssh into the machine" > /etc/issue
ip -4 -o addr show up scope global | awk '{print $2,":",$4}'| sed -e "s/\/[1-9]*//" >> /etc/issue
Run Code Online (Sandbox Code Playgroud)
现在我想让它在启动时运行,以便/etc/issue使用网络 ips更新。在基于 Debian 的发行版上,我会把它放在上面,/etc/rc.local但 alpine 没有这个文件。我将如何使这个脚本以等效的方式运行/etc/rc.local?
我试图戴上它,/etc/local.d但它未能正确改变/etc/issue
小智 9
您必须local.d在启动时启用脚本:
rc-update add local default
Run Code Online (Sandbox Code Playgroud)
然后只需将您的脚本放入/etc/local.d/UpdateIssue.start并使其可执行。
您可以local.d在 Gentoo wiki 上找到有关OpenRC 中脚本的更多详细信息:
https://wiki.gentoo.org/wiki//etc/local.d