summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-05-03 15:55:38 +0200
committerLennart Poettering <lennart@poettering.net>2012-05-03 16:00:49 +0200
commit04b6f7c1a7ba7e7baef99b2b0db9842864c0ff82 (patch)
tree0360014cd66cd35be3128d0c1224a0c0ab76131e /src
parente677bf7ef610acdc5068b9d5d4c79556a236e52f (diff)
rc-local-generator: hook halt-local in based on generator too
Diffstat (limited to 'src')
-rw-r--r--src/rc-local-generator/rc-local-generator.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c
index 42d7ae41ed..a5987f977e 100644
--- a/src/rc-local-generator/rc-local-generator.c
+++ b/src/rc-local-generator/rc-local-generator.c
@@ -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;