Skip to content

Commit 6a78132

Browse files
committed
luci-app-mosdns: disable service restarts following rule updates
Signed-off-by: sbwml <admin@cooluc.com>
1 parent bb1b78e commit 6a78132

7 files changed

Lines changed: 9 additions & 46 deletions

File tree

luci-app-mosdns/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=luci-app-mosdns
4-
PKG_VERSION:=1.7.0
4+
PKG_VERSION:=1.7.1
55
PKG_RELEASE:=1
66

77
LUCI_TITLE:=LuCI Support for mosdns

luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,7 @@ return view.extend({
391391
if (value == formvalue) {
392392
return;
393393
}
394-
return fs.write('/etc/mosdns/rule/cloudflare-cidr.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n')
395-
.then(function (i) {
396-
return fs.exec('/etc/init.d/mosdns', ['restart']);
397-
});
394+
return fs.write('/etc/mosdns/rule/cloudflare-cidr.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
398395
});
399396
};
400397

luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
'require fs';
44
'require ui';
55
'require view';
6-
'require rpc';
7-
8-
var callRestart = rpc.declare({
9-
object: 'luci.mosdns',
10-
method: 'restart'
11-
});
126

137
return view.extend({
148
render: function () {
@@ -274,19 +268,9 @@ return view.extend({
274268
},
275269

276270
handleSaveApply: function (ev) {
277-
var m = this.map;
278-
onclick = L.bind(this.handleSave, this, m);
279-
return callRestart()
280-
.then(function (res) {
281-
if (res && res.code === 0) {
282-
window.location.reload();
283-
} else {
284-
ui.addNotification(null, E('p', _('Failed to restart mosdns: %s').format(res.output || 'Unknown error')));
285-
}
286-
})
287-
.catch(function (e) {
288-
ui.addNotification(null, E('p', _('Failed to restart mosdns: %s').format(e.message)));
289-
});
271+
return this.handleSave(ev).then(function() {
272+
window.location.reload();
273+
});
290274
},
291275
handleReset: null
292276
});

luci-app-mosdns/root/etc/init.d/mosdns

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -822,10 +822,7 @@ start_service() {
822822
fi
823823
fi
824824

825-
[ "$update_list" -eq 1 ] && {
826-
sleep 3
827-
$MOSDNS_SCRIPT update_adlist
828-
} &
825+
[ "$update_list" -eq 1 ] && $MOSDNS_SCRIPT update_adlist &
829826
}
830827

831828
stop_service() {

luci-app-mosdns/root/usr/share/mosdns/mosdns.uc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,10 @@ switch (action) {
315315
case "update":
316316
update_geodat();
317317
update_adlist();
318-
exec_sys('/etc/init.d/mosdns restart');
318+
v2dat_dump();
319319
break;
320320
case "update_adlist":
321-
if (update_adlist()) {
322-
exec_sys('/etc/init.d/mosdns restart');
323-
}
321+
update_adlist();
324322
break;
325323
case "v2dat_dump":
326324
v2dat_dump();

luci-app-mosdns/root/usr/share/rpcd/acl.d/luci-app-mosdns.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"clean_log",
1919
"flush_cache",
2020
"get_version",
21-
"print_log",
22-
"restart"
21+
"print_log"
2322
]
2423
},
2524
"uci": [ "mosdns" ]

luci-app-mosdns/root/usr/share/rpcd/ucode/luci.mosdns

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ function exec_sys(cmd) {
3434
return { code: code, stdout: stdout || "" };
3535
}
3636

37-
function restart_mosdns() {
38-
let p = popen('(sleep 1; /etc/init.d/mosdns restart) >/dev/null 2>&1 &', 'r');
39-
if (p) p.close();
40-
}
41-
4237
function get_logfile_path_internal() {
4338
let uci_cursor = cursor();
4439
uci_cursor.load('mosdns');
@@ -124,13 +119,6 @@ const methods = {
124119
return { error: res.stdout };
125120
}
126121
}
127-
},
128-
129-
restart: {
130-
call: function() {
131-
restart_mosdns();
132-
return { code: 0, output: "mosdns is restarting in background." };
133-
}
134122
}
135123
};
136124

0 commit comments

Comments
 (0)