luci-app-mosdns: Add logs print support for "custom configuration"

This commit is contained in:
sbwml 2022-07-12 03:39:13 +08:00
parent ed1bba13e4
commit ad77fbee68
3 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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