Browse Source

update: demo of update signal

dev
Dnomd343 2 years ago
parent
commit
a8c6ef5a2d
  1. 12
      src/applet/crontab.c
  2. 15
      src/cleardns.c

12
src/applet/crontab.c

@ -1,13 +1,23 @@
#include <stdlib.h>
#include "process.h"
#include "config.h"
#include "logger.h"
#include "sundry.h"
#include "system.h"
process* assets_load(assets_config *info) { // load assets update options
log_info("assets test ok");
// TODO: update assets process
// TODO: save cron exp in `/var/spool/cron/crontabs/root`
log_info("Crontab exp -> `%s %s`", info->cron, "update.sh");
char *cron = string_join(info->cron, " kill -14 1");
log_info("Crontab exp -> `%s`", cron);
save_file("/var/spool/cron/crontabs/root", cron);
free(cron);
return process_init("Crontab", "crond");
}

15
src/cleardns.c

@ -41,6 +41,10 @@ char* init(int argc, char *argv[]) { // return config file
return config;
}
void signal_test() {
log_info("Get alarm signal");
}
int main(int argc, char *argv[]) { // ClearDNS service
char *config_file = init(argc, argv);
@ -48,6 +52,17 @@ int main(int argc, char *argv[]) { // ClearDNS service
LOG_LEVEL = LOG_DEBUG;
log_info("ClearDNS server start (%s)", VERSION);
signal(SIGALRM, signal_test);
assets_config demo;
demo.cron = "* * * * *";
process *crontab = assets_load(&demo);
process_exec(crontab);
for (;;) {
pause();
}
return 0;
// process *test = process_init("TEST", "lls");
// process *test = process_init("TEST", "ls");

Loading…
Cancel
Save