mirror of
https://github.com/systemd/systemd.git
synced 2024-12-01 06:13:38 +08:00
rc-local-generator: use macro to define main()
This commit is contained in:
parent
4917894417
commit
1332ecb8ad
@ -6,6 +6,7 @@
|
||||
|
||||
#include "generator.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "mkdir.h"
|
||||
#include "string-util.h"
|
||||
#include "util.h"
|
||||
@ -41,32 +42,30 @@ static int add_symlink(const char *service, const char *where) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int ret = EXIT_SUCCESS;
|
||||
static int run(int argc, char *argv[]) {
|
||||
int r = 0, k = 0;
|
||||
|
||||
if (argc > 1 && argc != 4) {
|
||||
log_error("This program takes three or no arguments.");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
log_setup_generator();
|
||||
|
||||
if (argc > 1 && argc != 4)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program takes three or no arguments.");
|
||||
|
||||
if (argc > 1)
|
||||
arg_dest = argv[1];
|
||||
|
||||
log_setup_generator();
|
||||
|
||||
if (access(RC_LOCAL_SCRIPT_PATH_START, X_OK) >= 0) {
|
||||
log_debug("Automatically adding rc-local.service.");
|
||||
|
||||
if (add_symlink("rc-local.service", "multi-user.target") < 0)
|
||||
ret = EXIT_FAILURE;
|
||||
r = add_symlink("rc-local.service", "multi-user.target");
|
||||
}
|
||||
|
||||
if (access(RC_LOCAL_SCRIPT_PATH_STOP, X_OK) >= 0) {
|
||||
log_debug("Automatically adding halt-local.service.");
|
||||
|
||||
if (add_symlink("halt-local.service", "final.target") < 0)
|
||||
ret = EXIT_FAILURE;
|
||||
k = add_symlink("halt-local.service", "final.target");
|
||||
}
|
||||
|
||||
return ret;
|
||||
return r < 0 ? r : k;
|
||||
}
|
||||
|
||||
DEFINE_MAIN_FUNCTION(run);
|
||||
|
Loading…
Reference in New Issue
Block a user