diff options
-rw-r--r-- | CMakeLists.txt | 16 | ||||
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/askfirst/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/askfirst/askfirst.c (renamed from utils/askfirst.c) | 0 | ||||
-rw-r--r-- | src/unitd/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/unitd/askconsole.c (renamed from askconsole.c) | 2 | ||||
-rw-r--r-- | src/unitd/early.c (renamed from early.c) | 3 | ||||
-rw-r--r-- | src/unitd/log.h (renamed from log.h) | 0 | ||||
-rw-r--r-- | src/unitd/service/instance.c (renamed from service/instance.c) | 0 | ||||
-rw-r--r-- | src/unitd/service/instance.h (renamed from service/instance.h) | 3 | ||||
-rw-r--r-- | src/unitd/service/service.c (renamed from service/service.c) | 0 | ||||
-rw-r--r-- | src/unitd/service/service.h (renamed from service/service.h) | 0 | ||||
-rw-r--r-- | src/unitd/signal.c (renamed from signal.c) | 3 | ||||
-rw-r--r-- | src/unitd/state.c (renamed from state.c) | 11 | ||||
-rw-r--r-- | src/unitd/system.c (renamed from system.c) | 5 | ||||
-rw-r--r-- | src/unitd/ubus.c (renamed from ubus.c) | 3 | ||||
-rw-r--r-- | src/unitd/unitd.c (renamed from unitd.c) | 5 | ||||
-rw-r--r-- | src/unitd/unitd.h (renamed from unitd.h) | 5 | ||||
-rw-r--r-- | src/unitd/utils.c (renamed from utils/utils.c) | 4 | ||||
-rw-r--r-- | src/unitd/utils.h (renamed from utils/utils.h) | 0 | ||||
-rw-r--r-- | src/unitd/watchdog.c (renamed from watchdog.c) | 5 | ||||
-rw-r--r-- | src/unitd/watchdog.h (renamed from watchdog.h) | 0 |
22 files changed, 43 insertions, 35 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c874d9..b6b0717 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,20 +5,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) project(unitd C) include(GNUInstallDirs) - find_package(JSON_C REQUIRED) - -add_executable(init unitd.c signal.c watchdog.c state.c askconsole.c ubus.c system.c early.c - service/service.c service/instance.c utils/utils.c) -set_property(TARGET init PROPERTY COMPILE_FLAGS "-std=gnu99 -Wall ${JSON_C_CFLAGS_OTHER}") -set_property(TARGET init PROPERTY LINK_FLAGS "${JSON_C_LDFLAGS_OTHER}") -set_property(TARGET init PROPERTY INCLUDE_DIRECTORIES ${JSON_C_INCLUDE_DIR}) -target_link_libraries(init ubox ubus blobmsg_json ${JSON_C_LIBRARIES}) - -install(TARGETS init RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}) - - -add_executable(askfirst utils/askfirst.c) - -install(TARGETS askfirst RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}) +add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..ea743d7 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(askfirst) +add_subdirectory(unitd) diff --git a/src/askfirst/CMakeLists.txt b/src/askfirst/CMakeLists.txt new file mode 100644 index 0000000..aa8c89a --- /dev/null +++ b/src/askfirst/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(askfirst askfirst.c) + +install(TARGETS askfirst RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/unitd) diff --git a/utils/askfirst.c b/src/askfirst/askfirst.c index cdb5074..cdb5074 100644 --- a/utils/askfirst.c +++ b/src/askfirst/askfirst.c diff --git a/src/unitd/CMakeLists.txt b/src/unitd/CMakeLists.txt new file mode 100644 index 0000000..6ef73f6 --- /dev/null +++ b/src/unitd/CMakeLists.txt @@ -0,0 +1,8 @@ +add_executable(unitd unitd.c signal.c watchdog.c state.c askconsole.c ubus.c system.c early.c + service/service.c service/instance.c utils.c) +set_property(TARGET unitd PROPERTY COMPILE_FLAGS "-std=gnu99 -Wall ${JSON_C_CFLAGS_OTHER}") +set_property(TARGET unitd PROPERTY LINK_FLAGS "${JSON_C_LDFLAGS_OTHER}") +set_property(TARGET unitd PROPERTY INCLUDE_DIRECTORIES ${JSON_C_INCLUDE_DIR}) +target_link_libraries(unitd ubox ubus blobmsg_json ${JSON_C_LIBRARIES}) + +install(TARGETS unitd RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/unitd) diff --git a/askconsole.c b/src/unitd/askconsole.c index fe37141..d7d4cb5 100644 --- a/askconsole.c +++ b/src/unitd/askconsole.c @@ -21,7 +21,7 @@ static void askconsole(struct uloop_process *proc) { char *const ask[] = { - "/sbin/askfirst", + "/lib/unitd/askfirst", "/bin/ash", "--login", NULL, diff --git a/early.c b/src/unitd/early.c index cc5a17c..644c15d 100644 --- a/early.c +++ b/src/unitd/early.c @@ -15,6 +15,8 @@ * GNU General Public License for more details. */ +#include "unitd.h" + #include <sys/mount.h> #include <sys/types.h> #include <sys/stat.h> @@ -24,7 +26,6 @@ #include <unistd.h> #include <stdlib.h> -#include "unitd.h" static void early_console(const char *dev) diff --git a/service/instance.c b/src/unitd/service/instance.c index 0949c0f..0949c0f 100644 --- a/service/instance.c +++ b/src/unitd/service/instance.c diff --git a/service/instance.h b/src/unitd/service/instance.h index 22f4ae5..8f5e61b 100644 --- a/service/instance.h +++ b/src/unitd/service/instance.h @@ -17,10 +17,11 @@ #pragma once +#include "../utils.h" + #include <libubox/vlist.h> #include <libubox/uloop.h> #include <libubox/ustream.h> -#include "../utils/utils.h" #define RESPAWN_ERROR (5 * 60) diff --git a/service/service.c b/src/unitd/service/service.c index a57d470..a57d470 100644 --- a/service/service.c +++ b/src/unitd/service/service.c diff --git a/service/service.h b/src/unitd/service/service.h index 2b6071c..2b6071c 100644 --- a/service/service.h +++ b/src/unitd/service/service.h diff --git a/signal.c b/src/unitd/signal.c index 9d5b3fc..b888760 100644 --- a/signal.c +++ b/src/unitd/signal.c @@ -15,12 +15,13 @@ * GNU General Public License for more details. */ +#include "unitd.h" + #include <sys/reboot.h> #include <sys/types.h> #include <unistd.h> -#include "unitd.h" static void do_reboot(void) { diff --git a/state.c b/src/unitd/state.c index a16ec36..c22d225 100644 --- a/state.c +++ b/src/unitd/state.c @@ -15,6 +15,12 @@ * GNU General Public License for more details. */ +#include "unitd.h" +#include "syslog.h" +#include "utils.h" +#include "watchdog.h" +#include "service/service.h" + #include <fcntl.h> #include <sys/reboot.h> #include <stdio.h> @@ -23,11 +29,6 @@ #include <sys/types.h> #include <signal.h> -#include "unitd.h" -#include "syslog.h" -#include "watchdog.h" -#include "service/service.h" -#include "utils/utils.h" enum { STATE_NONE = 0, diff --git a/system.c b/src/unitd/system.c index 0765d41..2316f96 100644 --- a/system.c +++ b/src/unitd/system.c @@ -15,6 +15,9 @@ * GNU General Public License for more details. */ +#include "unitd.h" +#include "watchdog.h" + #include <sys/utsname.h> #include <sys/sysinfo.h> #include <sys/ioctl.h> @@ -27,8 +30,6 @@ #include <libubox/uloop.h> -#include "unitd.h" -#include "watchdog.h" static struct blob_buf b; static int notify; diff --git a/ubus.c b/src/unitd/ubus.c index f1cb51f..370d4ba 100644 --- a/ubus.c +++ b/src/unitd/ubus.c @@ -15,12 +15,13 @@ * GNU General Public License for more details. */ +#include "unitd.h" + #include <sys/resource.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> -#include "unitd.h" char *ubus_socket = NULL; static struct ubus_context *ctx; diff --git a/unitd.c b/src/unitd/unitd.c index 19cfbed..aa26be3 100644 --- a/unitd.c +++ b/src/unitd/unitd.c @@ -15,6 +15,9 @@ * GNU General Public License for more details. */ +#include "unitd.h" +#include "watchdog.h" + #include <sys/wait.h> #include <sys/types.h> #include <sys/stat.h> @@ -24,8 +27,6 @@ #include <getopt.h> #include <libgen.h> -#include "unitd.h" -#include "watchdog.h" unsigned int debug = 4; diff --git a/unitd.h b/src/unitd/unitd.h index c5a92de..e9bebf1 100644 --- a/unitd.h +++ b/src/unitd/unitd.h @@ -17,6 +17,8 @@ #pragma once +#include "log.h" + #include <libubox/uloop.h> #include <libubox/utils.h> #include <libubus.h> @@ -24,9 +26,6 @@ #include <stdio.h> #include <syslog.h> -#include "log.h" - -#define __init __attribute__((constructor)) extern char *ubus_socket; diff --git a/utils/utils.c b/src/unitd/utils.c index 1f7d604..acf065c 100644 --- a/utils/utils.c +++ b/src/unitd/utils.c @@ -15,9 +15,11 @@ * GNU General Public License for more details. */ +#include "utils.h" + #include <libubox/avl.h> #include <libubox/avl-cmp.h> -#include "utils.h" + #include <asm-generic/setup.h> #include <regex.h> #include <unistd.h> diff --git a/utils/utils.h b/src/unitd/utils.h index 6ab19ed..6ab19ed 100644 --- a/utils/utils.h +++ b/src/unitd/utils.h diff --git a/watchdog.c b/src/unitd/watchdog.c index 04f682e..f462d00 100644 --- a/watchdog.c +++ b/src/unitd/watchdog.c @@ -15,6 +15,9 @@ * GNU General Public License for more details. */ +#include "unitd.h" +#include "watchdog.h" + #include <linux/watchdog.h> #include <sys/ioctl.h> @@ -26,8 +29,6 @@ #include <libubox/uloop.h> -#include "unitd.h" -#include "watchdog.h" #define WDT_PATH "/dev/watchdog" diff --git a/watchdog.h b/src/unitd/watchdog.h index 6c4bc6a..6c4bc6a 100644 --- a/watchdog.h +++ b/src/unitd/watchdog.h |