rc-local-generator: hook halt-local in based on generator too

This commit is contained in:
Lennart Poettering 2012-05-03 15:55:38 +02:00
parent e677bf7ef6
commit 04b6f7c1a7
2 changed files with 14 additions and 22 deletions

View File

@ -3166,10 +3166,6 @@ if TARGET_MEEGO
endif
if TARGET_FEDORA
$(MKDIR_P) -m 0755 $(DESTDIR)$(systemunitdir)/final.target.wants
( cd $(DESTDIR)$(systemunitdir)/final.target.wants && \
rm -f halt-local.service && \
$(LN_S) $(systemunitdir)/halt-local.service halt-local.service )
( cd $(DESTDIR)$(systemunitdir) && \
rm -f display-manager.service single.service && \
$(LN_S) prefdm.service display-manager.service && \
@ -3180,10 +3176,6 @@ if TARGET_FEDORA
endif
if TARGET_MANDRIVA
$(MKDIR_P) -m 0755 $(DESTDIR)$(systemunitdir)/final.target.wants
( cd $(DESTDIR)$(systemunitdir)/final.target.wants && \
rm -f halt-local.service && \
$(LN_S) $(systemunitdir)/halt-local.service halt-local.service )
( cd $(DESTDIR)$(systemunitdir) && \
rm -f display-manager.service dm.service single.service && \
$(LN_S) prefdm.service display-manager.service && \
@ -3201,20 +3193,12 @@ if TARGET_DEBIAN_OR_UBUNTU
endif
if TARGET_SUSE
$(MKDIR_P) -m 0755 $(DESTDIR)$(systemunitdir)/final.target.wants
( cd $(DESTDIR)$(systemunitdir) && \
rm -f local.service && \
$(LN_S) rc-local.service local.service )
( cd $(DESTDIR)$(systemunitdir)/final.target.wants && \
rm -f halt-local.service && \
$(LN_S) $(systemunitdir)/halt-local.service halt-local.service )
endif
if TARGET_MAGEIA
$(MKDIR_P) -m 0755 $(DESTDIR)$(systemunitdir)/final.target.wants
( cd $(DESTDIR)$(systemunitdir)/final.target.wants && \
rm -f halt-local.service && \
$(LN_S) $(systemunitdir)/halt-local.service halt-local.service )
( cd $(DESTDIR)$(systemunitdir) && \
rm -f display-manager.service && \
$(LN_S) prefdm.service display-manager.service && \

View File

@ -29,21 +29,23 @@
#include "mkdir.h"
#if defined(TARGET_FEDORA) || defined(TARGET_MANDRIVA) || defined(TARGET_MAGEIA)
#define SCRIPT_PATH "/etc/rc.d/rc.local"
#define SCRIPT_PATH_START "/etc/rc.d/rc.local"
#elif defined(TARGET_SUSE)
#define SCRIPT_PATH "/etc/init.d/boot.local"
#define SCRIPT_PATH_START "/etc/init.d/boot.local"
#endif
#define SCRIPT_PATH_STOP "/sbin/halt.local"
const char *arg_dest = "/tmp";
static int add_symlink(const char *service) {
static int add_symlink(const char *service, const char *where) {
char *from = NULL, *to = NULL;
int r;
assert(service);
asprintf(&from, SYSTEM_DATA_UNIT_PATH "/%s", service);
asprintf(&to, "%s/multi-user.target.wants/%s", arg_dest, service);
asprintf(&to, "%s/%s.wants/%s", arg_dest, where, service);
if (!from || !to) {
log_error("Out of memory");
@ -96,12 +98,18 @@ int main(int argc, char *argv[]) {
if (argc > 1)
arg_dest = argv[1];
if (file_is_executable(SCRIPT_PATH)) {
if (file_is_executable(SCRIPT_PATH_START)) {
log_debug("Automatically adding rc-local.service.");
if (add_symlink("rc-local.service") < 0)
if (add_symlink("rc-local.service", "multi-user.target") < 0)
r = EXIT_FAILURE;
}
if (file_is_executable(SCRIPT_PATH_STOP)) {
log_debug("Automatically adding halt-local.service.");
if (add_symlink("halt-local.service", "final.target") < 0)
r = EXIT_FAILURE;
}
return r;