_HAVE_FORK != $(_HAVE_FORK_SH)
FORK = $(_HAVE_FORK)$(shell $(_HAVE_FORK_SH))
-# Work out if we use Open RC or BSD RC
-_RC_SH = if [ -d /etc/init.d ]; then echo "-DENABLE_ORC"; elif [ -d /etc/rc.d ]; then echo "-DENABLE_BRC"; fi
+# Work out how to restart services
+_RC_SH = if [ -n "$(HAVE_INIT)" ]; then \
+ [ "$(HAVE_INIT)" = "no" ] || echo "-DENABLE_$(HAVE_INIT)"; \
+ elif [ -x /sbin/runscript ]; then echo "-DENABLE_ORC"; \
+ elif [ -x /sbin/service ]; then echo "-DENABLE_SERVICE"; \
+ elif [ -d /etc/rc.d ]; then echo "-DENABLE_BRC"; \
+ elif [ -d /etc/init.d ]; then echo "-DENABLE_SYSV"; \
+ fi
_RC != $(_RC_SH)
RC = $(_RC)$(shell $(_RC_SH))
-----
If you're cross compiling you may need to send HAVE_FORK=yes or HAVE_FORK=no
to the make command to avoid to automatic test.
+
+We try and detect how to restart ntp and ypbind, you can override this with
+HAVE_INIT=no or force one of these values
+ORC (OpenRC as used by Gentoo (forked from baselayout))
+BRC (BSD RC system - /etc/rc.d/ntpd restart )
+SERVICE (RedHat service command - service ntpd restart)
+SYSV (SYSV style - /etc/init.d/ntpd restart)
#define DUIDFILE CONFIGDIR "/" PACKAGE ".duid"
-/* ORC is the Open Run Control, forked from Gentoo's baselayout package
- * RC is a BSD style Run Control system */
+/* ORC is Open Run Control, forked from Gentoo's baselayout package
+ * BRC is BSD style Run Control
+ * SRC is Slackware Run Control
+ * SERVICE is RedHat
+ * SYSV should cover everthing else */
#ifdef ENABLE_ORC
-#define NISSERVICE ETCDIR "/init.d/ypbind"
-#define NISRESTARTARGS "--nodeps", "--quiet", "conditionalrestart"
-#define NTPSERVICE ETCDIR "/init.d/ntpd"
-#define NTPRESTARTARGS "--nodeps", "--quiet", "conditionalrestart"
-#define OPENNTPSERVICE ETCDIR "/init.d/ntpd"
-#define OPENNTPRESTARTARGS "--nodeps", "--quiet", "conditionalrestart"
+# define SERVICE "ORC"
+# define NISSERVICE ETCDIR "/init.d/ypbind"
+# define NISRESTARTARGS "--nodeps", "--quiet", "conditionalrestart"
+# define NTPSERVICE ETCDIR "/init.d/ntpd"
+# define NTPRESTARTARGS "--nodeps", "--quiet", "conditionalrestart"
#elif ENABLE_BRC
-#define NISSERVICE ETCDIR "/rc.d/ypbind"
-#define NISRESTARTARGS "restart"
-#define NTPSERVICE ETCDIR "/rc.d/ntpd"
-#define NTPRESTARTARGS "restart"
-#define OPENNTPSERVICE ETCDIR "/rc.d/ntpd"
-#define OPENNTPRESTARTARGS "restart"
+# define SERVICE "BRC"
+# define NISSERVICE ETCDIR "/rc.d/ypbind"
+# define NISRESTARTARGS "restart"
+# define NTPSERVICE ETCDIR "/rc.d/ntpd"
+# define NTPRESTARTARGS "restart"
+#elif ENABLE_SRC
+# define SERVICE "SRC"
+# define NISSERVICE ETCDIR "/rc.d/rc.ypbind"
+# define NISRESTARTARGS "restart"
+# define NTPSERVICE ETCDIR "/rc.d/rc.ntpd"
+# define NTPRESTARTARGS "restart"
+#elif ENABLE_SERVICE
+# define SERVICE "SERVICE"
+# define NISSERVICE "service"
+# define NISRESTARTARGS "ypbind", "restart"
+# define NTPSERVICE "service"
+# define NTPRESTARTARGS "ntpd", "restart"
+#elif ENABLE_SYSV
+# define SERVICE "SYSV"
+# define NISSERVICE ETCDIR "/init.d/ypbind"
+# define NISRESTARTARGS "restart"
+# define NTPSERVICE ETCDIR "/init.d/ntpd"
+# define NTPRESTARTARGS "restart"
#else
-#undef ENABLE_NIS
-#undef ENABLE_NTP
+# undef ENABLE_NIS
+# undef ENABLE_NTP
#endif
#endif
#endif
#ifdef NTPSERVICE
- if (restart_ntp)
- retval += exec_cmd (NTPSERVICE, NTPRESTARTARGS, (char *) NULL);
+ if (restart_ntp) {
+#ifdef NTPCHECK
+ if (system (NTPCHECK) == 0)
+#endif
+ retval += exec_cmd (NTPSERVICE, NTPRESTARTARGS, (char *) NULL);
+ }
#endif
#if defined (NTPSERVICE) && defined (OPENNTPSERVICE)
if (restart_openntp &&
(strcmp (NTPSERVICE, OPENNTPSERVICE) != 0 || ! restart_ntp))
- retval += exec_cmd (OPENNTPSERVICE, OPENNTPRESTARTARGS, (char *) NULL);
+ {
+#ifdef OPENNTPCHECK
+ if (system (OPENNTPCHECK) == 0)
+#endif
+ retval += exec_cmd (OPENNTPSERVICE, OPENNTPRESTARTARGS, (char *) NULL);
+ }
#elif defined (OPENNTPSERVICE) && ! defined (NTPSERVICE)
- if (restart_openntp)
- retval += exec_cmd (OPENNTPSERVICE, OPENNTPRESTARTARGS, (char *) NULL);
+ if (restart_openntp) {
+#ifdef OPENNTPCHECK
+ if (system (OPENNTPCHECK) == 0)
+#endif
+ retval += exec_cmd (OPENNTPSERVICE, OPENNTPRESTARTARGS, (char *) NULL);
#endif
return retval;
free (prefix);
fclose (f);
- exec_cmd (NISSERVICE, NISRESTARTARGS, (char *) NULL);
+#ifdef NISCHECK
+ if (system (NISCHECK) == 0)
+#endif
+ exec_cmd (NISSERVICE, NISRESTARTARGS, (char *) NULL);
return 0;
}
#endif