From be38a7233b6e538fb7550e709e9068ef417c760e Mon Sep 17 00:00:00 2001 From: Kenneth Johansson Date: Mon, 21 Sep 2015 16:01:46 +0200 Subject: [PATCH] Creashlog: handle default values. --- crashlog/files/etc/init.d/crashlog | 13 +++++++++++++ crashlog/files/sbin/logcore | 14 +++++++++++++- iwatchdog/files/etc/init.d/iwatchdog | 27 +++++++++++++++++++++++---- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/crashlog/files/etc/init.d/crashlog b/crashlog/files/etc/init.d/crashlog index ca030050c..fbfccb3be 100755 --- a/crashlog/files/etc/init.d/crashlog +++ b/crashlog/files/etc/init.d/crashlog @@ -23,6 +23,15 @@ send_log() done } +fill_in_default() +{ + /sbin/uci add system log + /sbin/uci rename system.@log[-1]=crashlog + /sbin/uci set system.crashlog.enable=no + /sbin/uci set system.crashlog.server="crash.inteno.se" + /sbin/uci commit +} + boot() { # is crashlog enabled ? @@ -31,6 +40,10 @@ boot() 0|no|NO|false|FALSE) exit 0 ;; + "") + fill_in_default + exit 0 + ;; esac # is this boot a result from a crash ? diff --git a/crashlog/files/sbin/logcore b/crashlog/files/sbin/logcore index d65bd2bfd..72c31673d 100755 --- a/crashlog/files/sbin/logcore +++ b/crashlog/files/sbin/logcore @@ -15,15 +15,27 @@ alive() fi } +fill_in_default() +{ + /sbin/uci add system log + /sbin/uci rename system.@log[-1]=corelog + /sbin/uci set system.corelog.enable=no + /sbin/uci set system.corelog.server="crash.inteno.se" + /sbin/uci commit +} # is corelog enabled ? enable=$(/sbin/uci get system.corelog.enable) case $enable in - 0|no|NO|false|FALSE|"") + 0|no|NO|false|FALSE) # drain core file from kernel cat >/dev/null exit 0 ;; + "") + fill_in_default + exit 0 + ;; esac server=$(/sbin/uci get system.corelog.server) diff --git a/iwatchdog/files/etc/init.d/iwatchdog b/iwatchdog/files/etc/init.d/iwatchdog index 52f5c3428..81392fff5 100644 --- a/iwatchdog/files/etc/init.d/iwatchdog +++ b/iwatchdog/files/etc/init.d/iwatchdog @@ -7,11 +7,30 @@ USE_PROCD=1 NAME=iwatchdog PROG=/sbin/iwatchdog +fill_in_default() +{ + /sbin/uci add system log + /sbin/uci rename system.@log[-1]=watchdog + /sbin/uci set system.watchdog.enable=no + /sbin/uci commit +} + start_service() { - procd_open_instance - procd_set_param command "$PROG" - procd_set_param respawn - procd_close_instance + enable=$(/sbin/uci get system.watchdog.enable) + case $enable in + 0|no|NO|false|FALSE) + exit 0 + ;; + "") + fill_in_default + exit 0 + ;; + esac + + procd_open_instance + procd_set_param command "$PROG" + procd_set_param respawn + procd_close_instance } #stop() {