init.d: 并非适用于所有 Linux 发行版
Author: tomcupCreated Sep 18, 2026Updated Sep 18, 2026
注意到在 linux install 脚本中大量使用了 systemd 相关服务,其中,init.d 作为 显然存在 的目录直接使用。
事实上,init.d 应当被看作一个被广泛使用的服务管理器,而非系统级别的默认功能。
在不使用 init.d 的发行版中,可能不存在 /etc/init.d,而是其它服务层,使得安装脚本不可用。
因此建议在安装时应检测 systemd 是否可用,比如该片段不应在安装过程中直接运行:
start_service()
{
if [ $ISSYSTEMD -ne 0 ]; then
chkconfig smartdns on >/dev/null 2>&1
service smartdns start
return $?
fi
systemctl daemon-reload
systemctl enable smartdns
systemctl start smartdns
}
...
install_smartdns()
{
...
if [ -z "$PREFIX" ]; then
start_service
fi
...
}Source: pymumu/smartdns