diff --git a/luci-app-mosdns/luasrc/controller/mosdns.lua b/luci-app-mosdns/luasrc/controller/mosdns.lua index 87a6b92..52f9634 100644 --- a/luci-app-mosdns/luasrc/controller/mosdns.lua +++ b/luci-app-mosdns/luasrc/controller/mosdns.lua @@ -26,9 +26,9 @@ function act_status() end function get_log() - luci.http.write(luci.sys.exec("[ -f $(uci -q get mosdns.mosdns.logfile) ] && cat $(uci -q get mosdns.mosdns.logfile)")) + luci.http.write(luci.sys.exec("cat $(/usr/share/mosdns/log_path.sh)")) end function clear_log() - luci.sys.call("cat /dev/null > $(uci -q get mosdns.mosdns.logfile)") + luci.sys.call("cat /dev/null > $(/usr/share/mosdns/log_path.sh)") end diff --git a/luci-app-mosdns/root/etc/init.d/mosdns b/luci-app-mosdns/root/etc/init.d/mosdns index af7b8a1..91b4049 100755 --- a/luci-app-mosdns/root/etc/init.d/mosdns +++ b/luci-app-mosdns/root/etc/init.d/mosdns @@ -81,7 +81,7 @@ start_service() { delcron setcron init_yaml - cat /dev/null > $(uci -q get mosdns.mosdns.logfile) + cat /dev/null > $(/usr/share/mosdns/log_path.sh) procd_open_instance mosdns procd_set_param command $PROG start -c "$CONF" procd_set_param user root diff --git a/luci-app-mosdns/root/usr/share/mosdns/log_path.sh b/luci-app-mosdns/root/usr/share/mosdns/log_path.sh new file mode 100755 index 0000000..93dca38 --- /dev/null +++ b/luci-app-mosdns/root/usr/share/mosdns/log_path.sh @@ -0,0 +1,9 @@ +#!/bin/bash -e + +configfile=$(uci -q get mosdns.mosdns.configfile) +if [ "$configfile" = "/etc/mosdns/config.yaml" ]; then + uci -q get mosdns.mosdns.logfile +else + [ ! -f /etc/mosdns/config_custom.yaml ] && exit 1 + cat /etc/mosdns/config_custom.yaml | grep -A 3 log | grep file | awk -F ":" '{print $2}' | sed 's/\"//g;s/ //g' +fi