Skip to content

Commit

Permalink
add voipblock app
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancYescO committed Sep 20, 2021
1 parent cbc77a2 commit 4d4770e
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 3 deletions.
2 changes: 1 addition & 1 deletion decompressed/gui_file/etc/modgui_scripts/01_prereq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ move_env_var() {
subpart="gui app var"

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

touch /etc/config/modgui
Expand Down
16 changes: 15 additions & 1 deletion decompressed/gui_file/etc/modgui_scripts/04_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,22 @@ create_gui_type() {
uci set modgui.app.xupnp_app="0"
fi
fi
if [ ! "$(uci get -q modgui.app.voipblock_for_mmpbx)" ]; then
if [ -f /etc/firewall.voipblock ]; then
uci set modgui.app.voipblock_for_mmpbx="1"
else
uci set modgui.app.voipblock_for_mmpbx="0"
fi
fi
if [ ! "$(uci get -q modgui.app.voipblock_for_asterisk)" ]; then
if [ -d /usr/share/asterisk/agi-bin/voipblock ]; then
uci set modgui.app.voipblock_for_asterisk="1"
else
uci set modgui.app.voipblock_for_asterisk="0"
fi
fi
if [ ! "$(uci get -q modgui.app.blacklist_app)" ]; then
if [ -d /etc/asterisk ]; then
if [ -f /www/docroot/modals/mmpbx-contacts-modal.lp.orig ]; then
uci set modgui.app.blacklist_app="1"
else
uci set modgui.app.blacklist_app="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ local modgui_app = {
config = config_modgui,
section = "app",
type = "app",
options = { "xupnp_app","blacklist_app","telstra_webui","transmission_webui","aria2_webui","amule_webui","luci_webui","specific_app" },
options = { "xupnp_app","voipblock_for_mmpbx","voipblock_for_asterisk","blacklist_app","telstra_webui","transmission_webui","aria2_webui","amule_webui","luci_webui","specific_app" },
}

mapper("uci_1to1").registerSimpleMap(modgui_app)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,63 @@ app_aria2() {
esac
}

app_voipblock_for_mmpbx() {
install() {
curl -s https://repository.macoers.com/voipblock/voipblock.sh | ash -s tch_install_for_mmpbx
uci set modgui.app.voipblock_for_mmpbx="1"
uci commit modgui
}
remove() {
curl -s https://repository.macoers.com/voipblock/voipblock.sh | ash -s tch_uninstall_for_mmpbx
uci set modgui.app.voipblock_for_mmpbx="0"
uci commit modgui
}

case $1 in
install)
install
;;
remove)
remove
;;
*)
echo "Unsupported action"
return 1
;;
esac
}

app_voipblock_for_asterisk() {
install() {
[ "$(uci get -q modgui.app.blacklist_app)" = "1" ] && {
curl -s https://repository.macoers.com/voipblock/voipblock.sh | ash -s tch_switch_to_voipblock
uci set modgui.app.blacklist_app="0"
} || {
curl -s https://repository.macoers.com/voipblock/voipblock.sh | ash -s tch_install_for_asterisk
}
uci set modgui.app.voipblock_for_asterisk="1"
uci commit modgui
}
remove() {
curl -s https://repository.macoers.com/voipblock/voipblock.sh | ash -s tch_uninstall_for_asterisk
uci set modgui.app.voipblock_for_asterisk="0"
uci commit modgui
}

case $1 in
install)
install "$2"
;;
remove)
remove
;;
*)
echo "Unsupported action"
return 1
;;
esac
}

app_blacklist() {
install() {
install_from_github Ansuel/blacklist master normal "$2"
Expand Down
2 changes: 2 additions & 0 deletions decompressed/gui_file/www/cards/009_extensions.lp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ if marketing_version >= 16.3 then
mapParams.luci_webui = "uci.modgui.app.luci_webui"
mapParams.blacklist_application = "uci.modgui.app.blacklist_app"
end
mapParams.voipblock_for_mmpbx = "uci.modgui.app.voipblock_for_mmpbx"
mapParams.voipblock_for_asterisk = "uci.modgui.app.voipblock_for_asterisk"
if cputype:match("mips") then
mapParams.amule_webui = "uci.modgui.app.amule_webui"
end
Expand Down
42 changes: 42 additions & 0 deletions decompressed/gui_file/www/docroot/modals/applications-modal.lp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ local app_list = {
"luci",
"aria2",
"transmission",
"voipblock_for_mmpbx",
"voipblock_for_asterisk",
"blacklist",
"xupnp",
"telstra",
Expand Down Expand Up @@ -54,6 +56,8 @@ if marketing_version >= 16.3 then
mapParams.luci_webui = "uci.modgui.app.luci_webui"
mapParams.blacklist_application = "uci.modgui.app.blacklist_app"
end
mapParams.voipblock_for_mmpbx = "uci.modgui.app.voipblock_for_mmpbx"
mapParams.voipblock_for_asterisk = "uci.modgui.app.voipblock_for_asterisk"
if cputype:match("mips") then
mapParams.amule_webui = "uci.modgui.app.amule_webui"
end
Expand Down Expand Up @@ -203,6 +207,44 @@ if StateParams["transmission_webui"] ~= nil then
html[#html+1] = "</div>"
end

if StateParams["voipblock_for_mmpbx"] ~= nil then
html[#html+1] = '<div class="span3" style="margin-right:.5rem;margin-left:.5rem;">'
html[#html+1] = "<fieldset>"
html[#html+1] = '<legend>' .. T"Voipblock for mmpbx" .. '</legend>'
html[#html+1] = ui_helper.createAlertBlock(T"This will install Voipblock for mmpbx", info_box)
html[#html+1] = T"State: "
html[#html+1] = "<strong>" .. T"The Voipblock for mmpbx is " .. StateParams["voipblock_for_mmpbx"] .. T" installed" .. "</strong><br/>"
html[#html+1] = "<br/>"
html[#html+1] = "<br/>"
if mapParams["voipblock_for_mmpbx"] and mapParams["voipblock_for_mmpbx"] == "1" then
html[#html+1] = ui_helper.createSimpleButton(T"Remove".." Voipblock for mmpbx", "fa fa-times-circle", btn_table.voipblock_for_mmpbx.remove)
else
html[#html+1] = ui_helper.createSimpleButton(T"Install".." Voipblock for mmpbx", "fa fa-download", btn_table.voipblock_for_mmpbx.install)
end
html[#html+1] = "</fieldset>"
html[#html+1] = "<br/>"
html[#html+1] = "</div>"
end

if StateParams["voipblock_for_asterisk"] ~= nil then
html[#html+1] = '<div class="span3" style="margin-right:.5rem;margin-left:.5rem;">'
html[#html+1] = "<fieldset>"
html[#html+1] = '<legend>' .. T"Voipblock for asterisk" .. '</legend>'
html[#html+1] = ui_helper.createAlertBlock(T"This will install Voipblock for asterisk", info_box)
html[#html+1] = T"State: "
html[#html+1] = "<strong>" .. T"The Voipblock for asterisk is " .. StateParams["voipblock_for_asterisk"] .. T" installed" .. "</strong><br/>"
html[#html+1] = "<br/>"
html[#html+1] = "<br/>"
if mapParams["voipblock_for_asterisk"] and mapParams["voipblock_for_asterisk"] == "1" then
html[#html+1] = ui_helper.createSimpleButton(T"Remove".." Voipblock for asterisk", "fa fa-times-circle", btn_table.voipblock_for_asterisk.remove)
else
html[#html+1] = ui_helper.createSimpleButton(T"Install".." Voipblock for asterisk", "fa fa-download", btn_table.voipblock_for_asterisk.install)
end
html[#html+1] = "</fieldset>"
html[#html+1] = "<br/>"
html[#html+1] = "</div>"
end

if StateParams["blacklist_application"] ~= nil then
btn_table.blacklist.installempty = {
button = {
Expand Down

0 comments on commit 4d4770e

Please sign in to comment.