X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=contrib%2Fpackage%2Ffreifunk-watchdog%2Fsrc%2Fwatchdog.h;h=3aa8876400be61369d73d26802d07e805f16886b;hp=6d9ccf82c6f830e90946070167371900f78ed73a;hb=41d2b33087da393453c45f5d923d690c88ee5474;hpb=cc8da1a01855c8a0b8ff6d4e909d742c12700f7b diff --git a/contrib/package/freifunk-watchdog/src/watchdog.h b/contrib/package/freifunk-watchdog/src/watchdog.h index 6d9ccf82c..3aa887640 100644 --- a/contrib/package/freifunk-watchdog/src/watchdog.h +++ b/contrib/package/freifunk-watchdog/src/watchdog.h @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * - * Copyright (C) 2009 Jo-Philipp Wich + * Copyright (C) 2009 Jo-Philipp Wich */ #include @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -51,15 +52,12 @@ /* How to call myself in the logs */ #define SYSLOG_IDENT "Freifunk Watchdog" +/* Process error action */ +#define PROC_ACTION curr_proc->initscript, curr_proc->initscript, "restart" + /* Wifi error action */ #define WIFI_ACTION "/sbin/wifi", "/sbin/wifi" -/* Crond error action */ -#define CRON_ACTION "/etc/init.d/cron", "/etc/init.d/cron", "restart" - -/* SSHd error action */ -#define SSHD_ACTION "/etc/init.d/dropbear", "/etc/init.d/dropbear", "restart" - /* Watchdog device */ #define WATCH_DEVICE "/dev/watchdog" #define WATCH_SHUTDOWN 'V' @@ -67,7 +65,7 @@ /* System load error action and treshold */ #define LOAD_TRESHOLD 15.00 -#define LOAD_ACTION "/sbin/reboot" +#define LOAD_ACTION "/sbin/reboot", "/sbin/reboot" /* Fallback binary name (passed by makefile) */ #ifndef BINARY @@ -84,7 +82,7 @@ struct wifi_tuple { }; /* structure to hold tuple-list and uci context during iteration */ -struct uci_itr_ctx { +struct uci_wifi_iface_itr_ctx { struct wifi_tuple *list; struct uci_context *ctx; }; @@ -92,6 +90,23 @@ struct uci_itr_ctx { typedef struct wifi_tuple wifi_tuple_t; +/* process name/exec tuples */ +struct process_tuple { + char process[PATH_MAX + 1]; + char initscript[PATH_MAX + 1]; + int restart; + struct process_tuple *next; +}; + +/* structure to hold tuple-list and uci context during iteration */ +struct uci_process_itr_ctx { + struct process_tuple *list; + struct uci_context *ctx; +}; + +typedef struct process_tuple process_tuple_t; + + /* ioctl() helper (stolen from iwlib) */ static inline int iw_ioctl(int skfd, /* Socket to the kernel */ @@ -107,22 +122,20 @@ iw_ioctl(int skfd, /* Socket to the kernel */ } /* fork() & execl() helper */ -#define EXEC(x) \ - do { \ - switch(fork()) \ - { \ - case -1: \ - syslog(LOG_CRIT, "Unable to fork child: %s", \ - strerror(errno)); \ - \ - break; \ - \ - case 0: \ - execl(x, NULL); \ - syslog(LOG_CRIT, "Unable to execute action: %s", \ - strerror(errno)); \ - \ - return 1; \ - } \ +#define EXEC(x) \ + do { \ + switch(fork()) \ + { \ + case -1: \ + syslog(LOG_CRIT, "Unable to fork child: %s", \ + strerror(errno)); \ + break; \ + \ + case 0: \ + execl(x, NULL); \ + syslog(LOG_CRIT, "Unable to execute action: %s", \ + strerror(errno)); \ + return 1; \ + } \ } while(0)