Skip to content

Commit 4d4770e

Browse files
committed
add voipblock app
1 parent cbc77a2 commit 4d4770e

File tree

6 files changed

+118
-3
lines changed

6 files changed

+118
-3
lines changed

decompressed/gui_file/etc/modgui_scripts/01_prereq.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ move_env_var() {
77
subpart="gui app var"
88

99
gui_entities="autoupgrade randomcolor autoupgrade_hour firstpage gui_skin new_ver outdated_ver autoupgradeview gui_hash update_branch"
10-
app_entities="xupnp_app blacklist_app telstra_webui transmission_webui aria2_webui amule_webui luci_webui"
10+
app_entities="xupnp_app voipblock_for_mmpbx voipblock_for_asterisk blacklist_app telstra_webui transmission_webui aria2_webui amule_webui luci_webui"
1111
var_entities="isp ppp_mgmt ppp_realm_ipv6 ppp_realm_ipv4 encrypted_pass check_obp reboot_reason_msg"
1212

1313
touch /etc/config/modgui

decompressed/gui_file/etc/modgui_scripts/04_config.sh

+15-1
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,22 @@ create_gui_type() {
153153
uci set modgui.app.xupnp_app="0"
154154
fi
155155
fi
156+
if [ ! "$(uci get -q modgui.app.voipblock_for_mmpbx)" ]; then
157+
if [ -f /etc/firewall.voipblock ]; then
158+
uci set modgui.app.voipblock_for_mmpbx="1"
159+
else
160+
uci set modgui.app.voipblock_for_mmpbx="0"
161+
fi
162+
fi
163+
if [ ! "$(uci get -q modgui.app.voipblock_for_asterisk)" ]; then
164+
if [ -d /usr/share/asterisk/agi-bin/voipblock ]; then
165+
uci set modgui.app.voipblock_for_asterisk="1"
166+
else
167+
uci set modgui.app.voipblock_for_asterisk="0"
168+
fi
169+
fi
156170
if [ ! "$(uci get -q modgui.app.blacklist_app)" ]; then
157-
if [ -d /etc/asterisk ]; then
171+
if [ -f /www/docroot/modals/mmpbx-contacts-modal.lp.orig ]; then
158172
uci set modgui.app.blacklist_app="1"
159173
else
160174
uci set modgui.app.blacklist_app="0"

decompressed/gui_file/usr/share/transformer/mappings/uci/modgui.map

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ local modgui_app = {
2020
config = config_modgui,
2121
section = "app",
2222
type = "app",
23-
options = { "xupnp_app","blacklist_app","telstra_webui","transmission_webui","aria2_webui","amule_webui","luci_webui","specific_app" },
23+
options = { "xupnp_app","voipblock_for_mmpbx","voipblock_for_asterisk","blacklist_app","telstra_webui","transmission_webui","aria2_webui","amule_webui","luci_webui","specific_app" },
2424
}
2525

2626
mapper("uci_1to1").registerSimpleMap(modgui_app)

decompressed/gui_file/usr/share/transformer/scripts/appInstallRemoveUtility.sh

+57
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,63 @@ app_aria2() {
399399
esac
400400
}
401401

402+
app_voipblock_for_mmpbx() {
403+
install() {
404+
curl -s https://repository.macoers.com/voipblock/voipblock.sh | ash -s tch_install_for_mmpbx
405+
uci set modgui.app.voipblock_for_mmpbx="1"
406+
uci commit modgui
407+
}
408+
remove() {
409+
curl -s https://repository.macoers.com/voipblock/voipblock.sh | ash -s tch_uninstall_for_mmpbx
410+
uci set modgui.app.voipblock_for_mmpbx="0"
411+
uci commit modgui
412+
}
413+
414+
case $1 in
415+
install)
416+
install
417+
;;
418+
remove)
419+
remove
420+
;;
421+
*)
422+
echo "Unsupported action"
423+
return 1
424+
;;
425+
esac
426+
}
427+
428+
app_voipblock_for_asterisk() {
429+
install() {
430+
[ "$(uci get -q modgui.app.blacklist_app)" = "1" ] && {
431+
curl -s https://repository.macoers.com/voipblock/voipblock.sh | ash -s tch_switch_to_voipblock
432+
uci set modgui.app.blacklist_app="0"
433+
} || {
434+
curl -s https://repository.macoers.com/voipblock/voipblock.sh | ash -s tch_install_for_asterisk
435+
}
436+
uci set modgui.app.voipblock_for_asterisk="1"
437+
uci commit modgui
438+
}
439+
remove() {
440+
curl -s https://repository.macoers.com/voipblock/voipblock.sh | ash -s tch_uninstall_for_asterisk
441+
uci set modgui.app.voipblock_for_asterisk="0"
442+
uci commit modgui
443+
}
444+
445+
case $1 in
446+
install)
447+
install "$2"
448+
;;
449+
remove)
450+
remove
451+
;;
452+
*)
453+
echo "Unsupported action"
454+
return 1
455+
;;
456+
esac
457+
}
458+
402459
app_blacklist() {
403460
install() {
404461
install_from_github Ansuel/blacklist master normal "$2"

decompressed/gui_file/www/cards/009_extensions.lp

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ if marketing_version >= 16.3 then
2525
mapParams.luci_webui = "uci.modgui.app.luci_webui"
2626
mapParams.blacklist_application = "uci.modgui.app.blacklist_app"
2727
end
28+
mapParams.voipblock_for_mmpbx = "uci.modgui.app.voipblock_for_mmpbx"
29+
mapParams.voipblock_for_asterisk = "uci.modgui.app.voipblock_for_asterisk"
2830
if cputype:match("mips") then
2931
mapParams.amule_webui = "uci.modgui.app.amule_webui"
3032
end

decompressed/gui_file/www/docroot/modals/applications-modal.lp

+42
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ local app_list = {
1212
"luci",
1313
"aria2",
1414
"transmission",
15+
"voipblock_for_mmpbx",
16+
"voipblock_for_asterisk",
1517
"blacklist",
1618
"xupnp",
1719
"telstra",
@@ -54,6 +56,8 @@ if marketing_version >= 16.3 then
5456
mapParams.luci_webui = "uci.modgui.app.luci_webui"
5557
mapParams.blacklist_application = "uci.modgui.app.blacklist_app"
5658
end
59+
mapParams.voipblock_for_mmpbx = "uci.modgui.app.voipblock_for_mmpbx"
60+
mapParams.voipblock_for_asterisk = "uci.modgui.app.voipblock_for_asterisk"
5761
if cputype:match("mips") then
5862
mapParams.amule_webui = "uci.modgui.app.amule_webui"
5963
end
@@ -203,6 +207,44 @@ if StateParams["transmission_webui"] ~= nil then
203207
html[#html+1] = "</div>"
204208
end
205209

210+
if StateParams["voipblock_for_mmpbx"] ~= nil then
211+
html[#html+1] = '<div class="span3" style="margin-right:.5rem;margin-left:.5rem;">'
212+
html[#html+1] = "<fieldset>"
213+
html[#html+1] = '<legend>' .. T"Voipblock for mmpbx" .. '</legend>'
214+
html[#html+1] = ui_helper.createAlertBlock(T"This will install Voipblock for mmpbx", info_box)
215+
html[#html+1] = T"State: "
216+
html[#html+1] = "<strong>" .. T"The Voipblock for mmpbx is " .. StateParams["voipblock_for_mmpbx"] .. T" installed" .. "</strong><br/>"
217+
html[#html+1] = "<br/>"
218+
html[#html+1] = "<br/>"
219+
if mapParams["voipblock_for_mmpbx"] and mapParams["voipblock_for_mmpbx"] == "1" then
220+
html[#html+1] = ui_helper.createSimpleButton(T"Remove".." Voipblock for mmpbx", "fa fa-times-circle", btn_table.voipblock_for_mmpbx.remove)
221+
else
222+
html[#html+1] = ui_helper.createSimpleButton(T"Install".." Voipblock for mmpbx", "fa fa-download", btn_table.voipblock_for_mmpbx.install)
223+
end
224+
html[#html+1] = "</fieldset>"
225+
html[#html+1] = "<br/>"
226+
html[#html+1] = "</div>"
227+
end
228+
229+
if StateParams["voipblock_for_asterisk"] ~= nil then
230+
html[#html+1] = '<div class="span3" style="margin-right:.5rem;margin-left:.5rem;">'
231+
html[#html+1] = "<fieldset>"
232+
html[#html+1] = '<legend>' .. T"Voipblock for asterisk" .. '</legend>'
233+
html[#html+1] = ui_helper.createAlertBlock(T"This will install Voipblock for asterisk", info_box)
234+
html[#html+1] = T"State: "
235+
html[#html+1] = "<strong>" .. T"The Voipblock for asterisk is " .. StateParams["voipblock_for_asterisk"] .. T" installed" .. "</strong><br/>"
236+
html[#html+1] = "<br/>"
237+
html[#html+1] = "<br/>"
238+
if mapParams["voipblock_for_asterisk"] and mapParams["voipblock_for_asterisk"] == "1" then
239+
html[#html+1] = ui_helper.createSimpleButton(T"Remove".." Voipblock for asterisk", "fa fa-times-circle", btn_table.voipblock_for_asterisk.remove)
240+
else
241+
html[#html+1] = ui_helper.createSimpleButton(T"Install".." Voipblock for asterisk", "fa fa-download", btn_table.voipblock_for_asterisk.install)
242+
end
243+
html[#html+1] = "</fieldset>"
244+
html[#html+1] = "<br/>"
245+
html[#html+1] = "</div>"
246+
end
247+
206248
if StateParams["blacklist_application"] ~= nil then
207249
btn_table.blacklist.installempty = {
208250
button = {

0 commit comments

Comments
 (0)