Skip to content

Commit

Permalink
webif: add uimods
Browse files Browse the repository at this point in the history
  • Loading branch information
fda77 committed Nov 5, 2023
1 parent 652d8bb commit d29ebdf
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 13 deletions.
8 changes: 8 additions & 0 deletions config/ui/freetz.in
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ menu "Additional informations"
help
This selects curl and uses it for encrypted https connections.

config FREETZ_ADD_UIMODS
bool "Add FOS UI-Modules"
depends on FREETZ_AVM_HAS_CTLMGR_CTL
default y if FREETZ_SHOW_EXPERT
default n
help
Adds fos ui-modules management to webif, category 'system'.

config FREETZ_ADD_INACTIVE_SYSTEM
bool "Show inactive firmware"
depends on ( FREETZ_AVM_HAS_FWLAYOUT_6 && (FREETZ_AVM_HAS_BLK_DEV_LOOP_BUILTIN || FREETZ_REPLACE_MODULE_AVAILABLE) )
Expand Down
44 changes: 39 additions & 5 deletions make/pkgs/mod/files/root/usr/mww/cgi-bin/exec.d/uimods.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
if [ "$REQUEST_METHOD" != POST ]; then
echo "Status: 302 Found"
echo "Location: $(href mod uimods)"
exit
fi

eval "$(modcgi mod:key:val uimods)"
M="${UIMODS_MOD}"
K="${UIMODS_KEY}"
V="${UIMODS_VAL}"
X="settings/$K"

# redirect stderr to stdout so we see output in webif
exec 2>&1

cgi_begin 'uimods ...'
echo '<pre>Processing ...'
echo "<pre>"
echo "Processing ..."
echo
echo "mod := $M"
echo "key := $K"
echo
if [ -z "$M" -o -z "$K" ] ; then
echo "Miserable failure, mod and/or key could not be empty."
echo "abort."
else
. /var/env.mod.daemon

old="$(ctlmgr_ctl r "$M" "$X")"
echo "old --> $old"

echo "new --> $V"
ack="$(ctlmgr_ctl w "$M" "$X" -- "$V")"
echo "ack --> $ack"

. /var/env.mod.daemon
#
echo "done."
chk="$(ctlmgr_ctl r "$M" "$X")"
echo "chk --> $chk"

echo
[ "$V" != "$chk" ] && echo "failed." || echo "done."
fi
echo '</pre>'
back_button mod system
back_button mod uimods
cgi_end
128 changes: 124 additions & 4 deletions make/pkgs/mod/files/root/usr/mww/cgi-bin/uimods.cgi
Original file line number Diff line number Diff line change
@@ -1,11 +1,131 @@
#!/bin/sh

. /usr/lib/libmodcgi.sh

cgi --id=uimods
cgi_begin "$(lang de:"FOS UI-Module" en:"FOS UI-Modules")"

#

# for x in $(ctlmgr_ctl u | sed '1,2d'); do echo; ctlmgr_ctl u $x; done | tee uimods.txt
uimods_listing() {
cat << EOX
avm_pa:enable 0|1 AVM Packet Accelerator
box:allow_security_report_with_manufacturer 0|1 Ihre FRITZ!Box ist f&uuml;r AVM erreichbar, um ausgew&auml;hlte Diagnosedaten oder eine Diagnosezusammenfassung abzurufen.
box:allow_background_comm_with_manufacturer 0|1 FRITZ!Box sucht periodisch nach Updates
box:allow_cross_domain_comm 0|1 Bei Aufruf von www.avm.de darf AVM ger&auml;tespezifische Daten Ihrer FRITZ!Box auslesen
box:button_events_disable 0|1 Tastensperre
box:signed_firmware 0|1 Nagt mit Link zu hilfe_nichtsigniert.html in der Diagnose und macht sonstwas damit
boxusers:twofactor_auth_enabled 0|1 Nervige Zwei-Faktor Authentifizierung
emailnotify:crashreport_mode to_support_only|disabled_by_user Fehlerberichte automatisch an AVM senden
eth_ports:eee_off_for_all_ports 0|1 Energy Efficient Ethernet DEAKTIVIEREN
meshd:loop_prevention_state 0|1 Netzwerkschleifenverhinderung
sar:gpon_serial
sar:Annex A|B
sar:vlan_id
sar:MaxDownstreamRate
sar:MaxUpstreamRate
sar:DownstreamMarginOffset -4|-3|-2|-1|0|1|2|3|4
sar:UpstreamMarginOffset -4|-3|-2|-1|0|1|2|3|4
tr369:enable 0|1 Fernadministration des LAN durch den Provider
tr069:LabSupportEnable 0|1
tr069:LabUploadReqEnable 0|1
tr069:ACSInitiation_enable 0|1
tr069:suppress_autoFWUpdate_notify 0|1
tr069:fwupdate_available 0|1|2
tr069:upload_enable 0|1
tr069:FWdownload_enable 0|1
updatecheck:auto_update_mode update_all|update_important|check neue FRITZ!OS-Versionen automatisch installieren
webui:expertmode 0|1
webui:ata_hidden 0|1
webui:lanbridges_gui_hidden 0|1
webui:voip_2ndPVC_hidden 0|1
webui:country_gui_hidden 0|1
webui:sid_timeout_minutes 20
wlan:ap_enabled 0|1 Wlan AP 1 (2,4 Ghz)
wlan:ap_enabled_scnd 0|1 Wlan AP 2 (5 GHz)
wlan:ap_enabled_thrd 0|1 Wlan AP 3
wlan:wps_enable 0|1 Wi-Fi Protected Setup
wlan:guest_ap_enabled 0|1 Wlan Guest
EOX
}

uimods_request() {
uimods_listing | while read -r a b; do
modul="${a%%:*}"
uikey="${a#$modul:}"
[ "$uikey" == "${uikey//\//\ }" ] && uikey="settings/$uikey"
echo -n "$modul $uikey "
done
}

uimods_table() {
local oldhr=""
uimods_result="$(ctlmgr_ctl r -v $(uimods_request))"
uimods_listing | sort | while read -r a vals desc; do
modul="${a%%:*}"
uikey="${a#$modul:}"
[ "$uikey" == "${uikey//\//}" ] && uikey="settings/$uikey"
[ "$oldhr" != "$modul" ] && table_head "$modul" "$oldhr" && oldhr="$modul"
saved="$(echo "$uimods_result" | sed -n "s,^${modul}:${uikey} = ,,p")"
table_line "$modul" "$uikey" "$saved" "$vals" "$desc"
done
table_end
}


table_begin() {
local modul="$1"
sec_begin "$modul"
echo "<table>"
# echo "<th align='left'>Key</th>"
# echo "<th align='left'>Value</th>"
# echo "<th align='left'>Change</th>"
}

table_head() {
local modul="$1"
local oldhr="$2"
[ -n "$oldhr" ] && table_end
table_begin "$modul"
}

table_line() {
local modul="$1"
local uikey="$2"
local saved="$3"
local vals="$4"
local desc="$5"
local short="${uikey##*/}"
local htmlid="uimod_${modul}__${short}"
local listid="dlist_${modul}__${short}"
local disabled=""
[ "${uikey%%/*}" != "settings" ] && disabled="disabled"
[ -n "$saved" -a -n "$vals" ] && items="$saved|$vals" || items="$saved$vals"

echo "<tr>"
echo "<form action='/cgi-bin/exec.cgi/uimods' method='post'>"

echo "<td width='400'><b>$short</b></td>"

echo "<td width='150'><input type='text' list='$listid' name='val' id='$htmlid' value='$saved' /> <datalist id='$listid'>"
for x in $(echo "$items" | sed 's/|/\n/g' | sort -u); do echo "<option value='$x'>"; done
echo "</datalist></td>";

echo "<input type='hidden' name='mod' value='$modul'>"
echo "<input type='hidden' name='key' value='$short'>"

echo "<td width='100'><center> <input type='submit' name='cmd' value='&nbsp;$(lang de:"&auml;ndern" en:"change")&nbsp;' $disabled> </center></td>"

echo "</form>"
echo "</tr>"

echo "<tr><td colspan='2'><font size=-2><i>${desc:+&num; $desc}</i></font></td></tr>"
}

table_end() {
echo "</table>"
sec_end
}


cgi_begin "$(lang de:"FOS UI-Module" en:"FOS UI-Modules")"
uimods_table
cgi_end

5 changes: 1 addition & 4 deletions make/pkgs/mod/mod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ $(PKG)_EXCLUDED += $(if $(FREETZ_BUSYBOX_TELNETD),,etc/init.d/rc.telnetd usr/lib
$(PKG)_EXCLUDED += $(if $(or $(call not-y,$(EXTERNAL_ENABLED)),$(EXTERNAL_DOWNLOADER)),usr/lib/cgi-bin/mod/conf/40-external.sh etc/init.d/rc.external etc/external.pkg)
$(PKG)_EXCLUDED += $(if $(EXTERNAL_ENABLED),,/usr/mww/cgi-bin/update/external.cgi /usr/mww/cgi-bin/update/do_external.cgi)
#$(PKG)_EXCLUDED += $(if $(FREETZ_AVM_HAS_FWLAYOUT_7),usr/mww/cgi-bin/update/)
$(PKG)_EXCLUDED += $(if $(FREETZ_AVM_HAS_CTLMGR_CTL),,usr/mww/cgi-bin/uimods.cgi usr/mww/cgi-bin/exec.d/uimods.sh)

# TODO
$(PKG)_EXCLUDED += usr/mww/cgi-bin/uimods.cgi usr/mww/cgi-bin/exec.d/uimods.sh
$(PKG)_EXCLUDED += $(if $(FREETZ_ADD_UIMODS),,usr/mww/cgi-bin/uimods.cgi usr/mww/cgi-bin/exec.d/uimods.sh)

$(PKG)_EXCLUDED += $(if $(FREETZ_BUSYBOX_FEATURE_WTMP),,usr/lib/cgi-bin/mod/conf/60-utmp_wtmp.sh)
$(PKG)_EXCLUDED += $(if $(and $(call not-y,$(FREETZ_AVM_HAS_AVMSERVICES_PRELOAD)),$(FREETZ_TARGET_IPV6_SUPPORT)),,usr/lib/cgi-bin/mod/conf/90-ipv6.sh)
Expand Down

2 comments on commit d29ebdf

@aus-sua
Copy link

@aus-sua aus-sua commented on d29ebdf Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vielen Dank für das Erstellen des Unterpunktes im Freetz-NG-webIf.
=B^)

@fda77
Copy link
Author

@fda77 fda77 commented on d29ebdf Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schön dass es dir gefällt. Es gibt bestimmt noch viele Variablen die gefunden werden wollen
zb mit https://freetz-ng.github.io/freetz-ng/wiki/60_Development/uimods.html#alle-variablen

Please sign in to comment.