Skip to content
Permalink
Browse files

apps: move specific apps outside gui package

Gui package now doesn't include specific app. User needs to manually install them if the modem doesn't have connection.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
  • Loading branch information
Ansuel committed Jul 29, 2019
1 parent c9b9dd1 commit be6ab73324160e623b9db47b7c0758236a7b449f
Showing with 411 additions and 35 deletions.
  1. +16 −17 decompressed/gui_file/etc/modgui_scripts/02_specific.sh
  2. +2 −0 decompressed/gui_file/usr/share/transformer/commitapply/rpc_system.ca
  3. +1 −0 decompressed/gui_file/usr/share/transformer/mappings/rpc/system.modgui.map
  4. +1 −1 decompressed/gui_file/usr/share/transformer/mappings/uci/modgui.map
  5. +38 −2 decompressed/gui_file/usr/share/transformer/scripts/appInstallRemoveUtility.sh
  6. +156 −9 decompressed/gui_file/www/docroot/modals/modgui-modal.lp
  7. BIN decompressed/telnet_support-specificDGA/bin/busybox_telnet
  8. BIN decompressed/{telnet_support-specificTG789 → upgrade-pack-specificDGA}/bin/busybox_telnet
  9. 0 decompressed/{upnpfix-specificDGA → upgrade-pack-specificDGA}/etc/hotplug.d/iface/50-miniupnpd
  10. 0 decompressed/{dlnad_supprto-specificDGA → upgrade-pack-specificDGA}/etc/init.d/dlnad
  11. 0 decompressed/{upnpfix-specificDGA → upgrade-pack-specificDGA}/etc/init.d/miniupnpd
  12. 0 decompressed/{telnet_support-specificDGA → upgrade-pack-specificDGA}/etc/init.d/telnet
  13. 0 decompressed/{upnpfix-specificDGA → upgrade-pack-specificDGA}/etc/uci-defaults/99-miniupnpd
  14. +54 −0 decompressed/upgrade-pack-specificDGA/setup.sh
  15. 0 decompressed/{dlnad_supprto-specificDGA/etc/config → upgrade-pack-specificDGA/tmp}/dlnad_orig
  16. 0 decompressed/{telnet_support-specificDGA/etc/config → upgrade-pack-specificDGA/tmp}/telnet_orig
  17. BIN decompressed/{wgetfix-specificDGA → upgrade-pack-specificDGA/tmp}/wget_1.17.1-1_brcm63xx-tch.ipk
  18. BIN decompressed/{dlnad_supprto-specificDGA → upgrade-pack-specificDGA}/usr/bin/dlnad
  19. BIN decompressed/{dlnad_supprto-specificDGA → upgrade-pack-specificDGA}/usr/lib/libCdsObjects.so
  20. 0 decompressed/{upnpfix-specificDGA → upgrade-pack-specificDGA}/usr/lib/opkg/info/upnpd.conffiles
  21. 0 decompressed/{upnpfix-specificDGA → upgrade-pack-specificDGA}/usr/lib/opkg/info/upnpd.control
  22. BIN decompressed/{upnpfix-specificDGA → upgrade-pack-specificDGA}/usr/sbin/miniupnpd
  23. 0 decompressed/{upnpfix-specificDGA → upgrade-pack-specificDGA}/usr/share/miniupnpd/firewall.include
  24. 0 ...ed/{upnpfix-specificDGA → upgrade-pack-specificDGA}/usr/share/transformer/commitapply/uci_upnp.ca
  25. BIN decompressed/upgrade-pack-specificTG789/bin/busybox_telnet
  26. 0 decompressed/{telnet_support-specificTG789 → upgrade-pack-specificTG789}/etc/init.d/telnet
  27. +46 −0 decompressed/upgrade-pack-specificTG789/setup.sh
  28. 0 decompressed/{telnet_support-specificTG789/etc/config → upgrade-pack-specificTG789/tmp}/telnet_orig
  29. BIN decompressed/upgrade-pack-specificTG800/bin/busybox_telnet
  30. +46 −0 decompressed/upgrade-pack-specificTG800/etc/init.d/telnet
  31. +46 −0 decompressed/upgrade-pack-specificTG800/setup.sh
  32. +2 −0 decompressed/upgrade-pack-specificTG800/tmp/telnet_orig
  33. +3 −6 inizialize_gui.sh
@@ -87,18 +87,8 @@ apply_specific_TG800_package() {
fi
}

apply_specific_TG789_package() {
logger_command "Extracting telnet_support-specificTG789/tg799.tar.bz2 ..."
if [ -f /tmp/telnet_support-specificTG789.tar.bz2 ]; then
bzcat /tmp/telnet_support-specificTG789.tar.bz2 | tar -C / -xf -
fi
}

apply_specific_TG799_package() {
logger_command "Extracting telnet_support-specificTG789/tg799.tar.bz2 ..."
if [ -f /tmp/telnet_support-specificTG789.tar.bz2 ]; then
bzcat /tmp/telnet_support-specificTG789.tar.bz2 | tar -C / -xf -
fi
install_specific() {
/usr/share/transformer/scripts/appInstallRemoveUtility.sh install specific_app $1
}

ledfw_extract() {
@@ -205,11 +195,20 @@ remove_downgrade_bit() {
device_type="$(uci get -q env.var.prod_friendly_name)"
kernel_ver="$(cat /proc/version | awk '{print $3}')"

logger_command "Applying specific model fixes..."
[ -z "${kernel_ver##3.4*}" ] && [ -z "${device_type##*DGA413*}" ] && apply_specific_DGA_package
[ -z "${kernel_ver##3.4*}" ] && [ -z "${device_type##*TG789*}" ] && apply_specific_TG789_package
[ -z "${kernel_ver##3.4*}" ] && [ -z "${device_type##*TG799*}" ] && apply_specific_TG799_package
[ -z "${kernel_ver##3.4*}" ] && [ -z "${device_type##*TG800*}" ] && apply_specific_TG800_package
if ping -q -c 1 -W 1 8.8.8.8 >/dev/null 2>&1; then
logger_command "Applying specific model fixes..."
[ -z "${kernel_ver##3.4*}" ] && [ -z "${device_type##*DGA413*}" ] && install_specific DGA
[ -z "${kernel_ver##3.4*}" ] && [ -z "${device_type##*TG789*}" ] && install_specific TG789
[ -z "${kernel_ver##3.4*}" ] && [ -z "${device_type##*TG799*}" ] && install_specific TG789
[ -z "${kernel_ver##3.4*}" ] && [ -z "${device_type##*TG800*}" ] && install_specific TG800
uci set modgui.app.specific_app="1"
else
logger_command "No connection detected, install specific upgrade pack manually!"
uci set modgui.app.specific_app="0"
fi

uci commit modgui

[ -z "${device_type##*DGA4130*}" ] && ledfw_extract "DGA"
[ -z "${device_type##*DGA4132*}" ] && ledfw_extract "DGA"
[ -z "${device_type##*DGA4131*}" ] && ledfw_extract "DGA4131"
@@ -35,5 +35,7 @@
^rpc%.system%.modgui%.app%.remove_xupnp /usr/share/transformer/scripts/appInstallRemoveUtility.sh remove xupnp
^rpc%.system%.modgui%.app%.install_telstra /usr/share/transformer/scripts/appInstallRemoveUtility.sh install telstra
^rpc%.system%.modgui%.app%.remove_telstra /usr/share/transformer/scripts/appInstallRemoveUtility.sh remove telstra
^rpc%.system%.modgui%.app%.specific_app /usr/share/transformer/scripts/appInstallRemoveUtility.sh install specific_app
^rpc%.system%.modgui%.app%.specific_app /usr/share/transformer/scripts/appInstallRemoveUtility.sh remove specific_app

^rpc%.system%.modgui%.debuglog%.start /usr/share/transformer/scripts/generate-debug-file.sh dev
@@ -418,6 +418,7 @@ local app_list = {
"xupnp",
"telstra",
"amule",
"specific_app",
}

for _, app in ipairs(app_list) do
@@ -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" },
options = { "xupnp_app","blacklist_app","telstra_webui","transmission_webui","aria2_webui","amule_webui","luci_webui","specific_app" },
}

mapper("uci_1to1").registerSimpleMap(modgui_app)
@@ -2,10 +2,24 @@

device_type="$(uci get -q env.var.prod_friendly_name)"

# 1st arg : directory
# 2nd arg : pkg name
# 3rd arg : raw or normal. Raw is used to download specific file from specific dir
install_from_github(){
curl -sLk https://github.com/$1/tarball/$2 --output /tmp/$2.tar.gz
mkdir /tmp/$2
tar -xzf /tmp/$2.tar.gz -C /tmp/$2

if [ $3 == "raw" ]; then
if [ ! -f /tmp/$2.tar.bz2 ]; then
curl -sLk https://raw.githubusercontent.com/$1/$2 --output /tmp/$2.tar.bz2
fi
bzcat /tmp/$2.tar.bz2 | tar -C /tmp/$2 -xzf -
else
if [ ! -f /tmp/$2.tar.gz ]; then
curl -sLk https://github.com/$1/tarball/$2 --output /tmp/$2.tar.gz
fi
tar -xzf /tmp/$2.tar.gz -C /tmp/$2
fi

rm /tmp/$2.tar.gz
cd /tmp/$2/*
chmod +x ./setup.sh
@@ -289,6 +303,25 @@ app_xupnp() {
set_transformer "rpc.system.modgui.scriptRequest.state" "Complete"
}

install_specific_files() {

install() {
install_from_github Ansuel/gui-dev-build-auto/master/modular upgrade-pack-specific$3 raw
}
remove() {
echo "Specific files cannot be removed. Reset the router instead."
return 1
}

if [ $1 == "install" ]; then
install
else
remove
fi

set_transformer "rpc.system.modgui.scriptRequest.state" "Complete"
}

call_app_type() {
case "$2" in
transmission)
@@ -312,6 +345,9 @@ call_app_type() {
blacklist)
app_blacklist $1 $3
;;
specific_app)
install_specific_files $1 $3
;;
*)
echo "Provide a valid APP_NAME" 1>&2
return 1
@@ -124,6 +124,42 @@ local function upgradeguistatus()
ngx.exit(ngx.HTTP_OK)
end

local function getSupportedModel()
local friendly_name = proxy.get("uci.env.var.prod_friendly_name")[1].value

if friendly_name:match("DGA4130") or friendly_name:match("DGA4132") then
return "DGA"
elseif friendly_name:match("TG789") or friendly_name:match("TG799") then
return "TG789"
elseif friendly_name:match("TG800") then
return "TG800"
end

return
end

local function installspecificapp()

local device = getSupportedModel()

local fwupgrade_location = "/tmp/"

-- flush the web template cache
lp.flush()

local dl = untaint(fwupgrade_location) .. "upgrade-pack-specific" .. device .. ".tar.bz2"

local rcv_ok, rcv_errno, rcv_errmsg = receive_file(dl, 'name="upgradefile"')

proxy.set("rpc.system.modgui.scriptRequest.state","Requested")
proxy.set("rpc.system.modgui.app.specific_app", "1")
proxy.set("uci.modgui.app.specific_app","1")
proxy.apply()

ngx.print('{ "success":"true" }')
ngx.exit(ngx.HTTP_OK)
end

local function scriptRequestStatus()
local upgradegui_path = "rpc.system.modgui.scriptRequest."
local state = proxy.get(upgradegui_path.."state")[1].value
@@ -140,7 +176,7 @@ local function scriptRequestStatus()
ngx.exit(ngx.HTTP_OK)
end

local function resetreboot(path, value)
local function sendcmd(path, value)
proxy.set(path, value)
ngx.header.content_type = "application/json"
ngx.print('{ "success":"true" }')
@@ -155,19 +191,31 @@ if ngx.req.get_method() == "POST" then
if action == "upgradeguifile" then
return upgradeguifile()
end
if action == "installspecificapp" then
return installspecificapp()
end
local action = ngx.req.get_post_args().action
if action == "system_reset_gui" then
return resetreboot("rpc.system.modgui.utility.resetgui", "1")
return sendcmd("rpc.system.modgui.utility.resetgui", "1")
end
if action == "system_upgrade_gui" then
proxy.set("rpc.system.modgui.upgradegui.state", "Requested")
return resetreboot("rpc.system.modgui.upgradegui.start", "1")
return sendcmd("rpc.system.modgui.upgradegui.start", "1")
end
if action == "system_install_specificapp" then
proxy.set("rpc.system.modgui.scriptRequest.state","Requested")
proxy.set("rpc.system.modgui.app.specific_app", "1")
proxy.set("uci.modgui.app.specific_app","1")
proxy.apply()

ngx.exit(ngx.HTTP_OK)
return
end
if action == "system_remove_root" then
return resetreboot("rpc.system.modgui.utility.removeroot", "1")
return sendcmd("rpc.system.modgui.utility.removeroot", "1")
end
if action == "system_reset_config" then
return resetreboot("rpc.system.modgui.utility.resetconfig", "1")
return sendcmd("rpc.system.modgui.utility.resetconfig", "1")
end
elseif ngx.req.get_method() == "GET" then
local action = ngx.req.get_uri_args().action
@@ -183,6 +231,8 @@ local content = {
outdated_ver = "uci.modgui.gui.outdated_ver",
new_ver = "uci.modgui.gui.new_ver",
upgradegui_logstep = "rpc.system.modgui.upgradegui.log_step",
specific_app = "uci.modgui.app.specific_app",
telstra_gui = "uci.modgui.app.telstra_webui",
}

content_helper.getExactContent(content)
@@ -198,9 +248,7 @@ local gui_skin_firstpage_page = {
{ "cards", T"Cards" },
}

local telstra_gui = proxy.get("uci.modgui.app.telstra_webui")

if telstra_gui and ( telstra_gui[1].value == "1" ) then
if content.telstra_gui == "1" then
table.insert(gui_skin_firstpage_page, { "telstra", T"Telstra" })
end

@@ -372,10 +420,63 @@ ngx.print('\
html[#html + 1] = ui_helper.createAlertBlock(T"Update failed. Please try again.", upload_gui_fail)
html[#html + 1] = ui_helper.createAlertBlock(T"Uploading file. Please wait...", upload_gui_alert)
html[#html + 1] = ui_helper.createAlertBlock(T"Updating file. Please wait...", updating)

html[#html + 1] = '</form>'
ngx.print(html)

if content.specific_app ~= "" then

local html = {}

local upload_specific_app = {
button = {
class = "import-specificapp custom-handler",
id = "btn-import-specificapp"
}
}

local upload_specificapp_fail = {
alert = {
class = "alert-error hide",
id = "upgrade-specificapp-fail"
}
}
local install_specificapp = {
group = {
class = "wait-for-reset"
},
button = {
id = "btn-install-specificapp",
class = "custom-handler"
}
}

html[#html + 1] = '<form class="form-horizontal" id="form-import-specificapp" method="post" action="modals/modgui-modal.lp?action=installspecificapp" enctype="multipart/form-data">'
html[#html + 1] = '<legend>'.. T"Specific App" ..'</legend>'
html[#html + 1] = ui_helper.createAlertBlock(T"Specific App are package that adds additional function to the modem, like telnet support or some fix to default package", info_box)
if content.specific_app == "1" then
html[#html + 1] = ui_helper.createLabel(T"State", T"Specific App are already Installed", basic)
else
html[#html + 1] = ui_helper.createButton(T"Install", T"Install Specific App Online", "icon-refresh", install_specificapp)

local device = getSupportedModel()

html[#html + 1] = ui_helper.createAlertBlock(T"If you don't have connection, specific app can be downloaded here ( https://raw.githubusercontent.com/Ansuel/gui-dev-build-auto/master/modular/upgrade-pack-specific"..device..".tar.bz2 ) and installed manually here.", info_box)
html[#html + 1] = '<div class="control-group">'
html[#html + 1] = format('<label class="control-label">%s</label>', T"Upload Specific App")
html[#html + 1] = '<div class="controls">'
html[#html + 1] = '<input type="file" name="specificapp" id="file-specificapp" accept=".bz2">&nbsp;'
html[#html + 1] = ui_helper.createSimpleButton(T"Install", "icon-shield", upload_specific_app)
html[#html + 1] = ui_helper.createAlertBlock(T"Update failed. Please try again.", upload_specificapp_fail)
html[#html + 1] = '</div></div>'
end
html[#html + 1] = '</form>'

ngx.print(html)

end

local html = {}
html[#html + 1] = '<form class="form-horizontal">'
html[#html + 1] = '<div class="RemoveOnUpgrade">'
html[#html + 1] = '<legend>' .. T"Advanced Reset" .. '</legend>'
local reset_gui = {
@@ -695,6 +796,52 @@ ngx.print('\
});\
return false;\
});\
\
$("#btn-install-specificapp").on("click", function()) {\
$.post(target,{action: "system_install_specificapp", CSRFtoken: $("meta[name=CSRFtoken]").attr("content")},"","json");\
tch.showProgress("Installing...");\
scriptRequestStatusAjax();\
});\
\
$(".import-specificapp").on("click", function() {\
var nofile_msg = $("#upgrade-specificapp-fail");\
var wrongext_msg = $("#upgrade-specificapp-fail");\
nofile_msg.addClass("hide");\
if ($("#file-specificapp").val() == "") {\
nofile_msg.removeClass("hide");\
nofile_msg[0].scrollIntoView();\
return false;\
};\
\
var validExtensions = [\'bz2\'];\
var fileName = $("#file-specificapp").val();\
\
var fileNameExt = fileName.substr(fileName.lastIndexOf(".") + 1);\
if ($.inArray(fileNameExt, validExtensions) == -1){\
wrongext_msg.removeClass("hide");\
wrongext_msg[0].scrollIntoView();\
return false;\
};\
var fileSize = $("#file-specificapp")[0].files[0].size;\
var importing_msg = $("#upload-specificapp-alert");\
var _this = $(this).parents(".control-group");\
importing_msg.removeClass("hide");\
importing_msg[0].scrollIntoView();\
\
$.fileUpload($("#form-import-specificapp"), {\
params: { CSRFtoken: $("meta[name=CSRFtoken]").attr("content") },\
completeCallback: function(form, response) {\
if (response.success) {\
tch.showProgress("Installing...");\
scriptRequestStatusAjax();\
} else {\
importing_msg.addClass("hide");\
$("#upgrade-specificapp-fail").removeClass("hide");\
}\
}\
});\
return false;\
});\
');
if ngx.req.get_uri_args().action and ngx.req.get_uri_args().action == "manualguiupgrade" then
ngx.print('\
Binary file not shown.
File renamed without changes.

2 comments on commit be6ab73

@Ghost9090

This comment has been minimized.

Copy link

Ghost9090 replied Jul 30, 2019

@Ansuel i tasti dentro impostazioni gui funzionano non va né i reset e neanche del root

@Ghost9090

This comment has been minimized.

Copy link

Ghost9090 replied Jul 30, 2019

@Ansuel neanche forza aggiornamento e aggiorna gui

Please sign in to comment.
You can’t perform that action at this time.