Linux 使用upstart/systemd检测创建sysv init脚本
我正在尝试为Ubuntu upstart/Debian SysV和systemd系统创建一组通用的init脚本 我意识到对于upstart,我总是可以在我的Linux 使用upstart/systemd检测创建sysv init脚本,linux,init,upstart,systemd,Linux,Init,Upstart,Systemd,我正在尝试为Ubuntu upstart/Debian SysV和systemd系统创建一组通用的init脚本 我意识到对于upstart,我总是可以在我的/etc/init.d/appname文件中进行简单的检查: . /lib/lsb/init-functions check_for_upstart() { if init_is_upstart; then echo "Upstarted detected. Use upstart service commands.
/etc/init.d/appname
文件中进行简单的检查:
. /lib/lsb/init-functions
check_for_upstart() {
if init_is_upstart; then
echo "Upstarted detected. Use upstart service commands. Exiting." >&2
exit 1
fi
}
(或者我可以像一些Ubuntu脚本那样,让fancier将相关命令转发给upstart)
是否有类似的方法来检测systemd是否正在使用并退出或重定向到systemctl?我意识到很多openSUSE脚本重定向到systemctl,但看看这些脚本,我不太明白它们是如何做到这一点的。我猜这是通过它们包含的/etc/rc\u status
文件实现的,但这似乎是openSUSE特有的,不适用于CentOS
最终我想支持Ubuntu 14、Debian 7、CentOS/RHEL 7和openSUSE(任何systemd)。因此,我的systemv init脚本实际上只适用于Debian,并且在其他发行版上都会有一条消息(或者以某种标准方式重定向到systemctl/upstart)
有没有实现这一目标的例子/最佳实践 Debian和Ubuntu通过init函数进行重定向。不知道CentOS/RHEL。嘿,看一看,不要在systemd系统上安装init或upstart脚本。问题解决了。