mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Add cpu scale frequency configuration
This commit is contained in:
parent
c5916d5454
commit
183bef4a8b
4 changed files with 92 additions and 0 deletions
|
@ -78,6 +78,30 @@ function settings_add()
|
|||
ucic:save("firewall")
|
||||
ucic:commit("firewall")
|
||||
|
||||
-- Set CPU scaling minimum frequency
|
||||
local scaling_min_freq = luci.http.formvalue("scaling_min_freq") or ""
|
||||
if scaling_min_freq ~= "" then
|
||||
ucic:set("openmptcprouter","settings","scaling_min_freq",scaling_min_freq)
|
||||
ucic:save("openmptcprouter")
|
||||
ucic:commit("openmptcprouter")
|
||||
end
|
||||
|
||||
-- Set CPU scaling maximum frequency
|
||||
local scaling_max_freq = luci.http.formvalue("scaling_max_freq") or ""
|
||||
if scaling_max_freq ~= "" then
|
||||
ucic:set("openmptcprouter","settings","scaling_max_freq",scaling_max_freq)
|
||||
ucic:save("openmptcprouter")
|
||||
ucic:commit("openmptcprouter")
|
||||
end
|
||||
|
||||
-- Set CPU governor
|
||||
local scaling_governor = luci.http.formvalue("scaling_governor") or ""
|
||||
if scaling_governor ~= "" then
|
||||
ucic:set("openmptcprouter","settings","scaling_governor",scaling_governor)
|
||||
ucic:save("openmptcprouter")
|
||||
ucic:commit("openmptcprouter")
|
||||
end
|
||||
|
||||
-- Done, redirect
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin/system/openmptcprouter/settings"))
|
||||
return
|
||||
|
|
|
@ -20,6 +20,40 @@
|
|||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% if nixio.fs.access("/sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq") then %>
|
||||
<fieldset class="cbi-section" id="system">
|
||||
<legend><%:Systems settings%></legend>
|
||||
<div class="cbi-section-descr"></div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Minimum scaling CPU frequency%></label>
|
||||
<div class="cbi-value-field">
|
||||
<input type="text" name="scaling_min_freq" class="cbi-input-text" value="<%=tonumber((luci.sys.exec("echo /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq")):match("%d+"))%>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Maximum scaling CPU frequency%></label>
|
||||
<div class="cbi-value-field">
|
||||
<input type="text" name="scaling_max_freq" class="cbi-input-text" value="<%=tonumber((luci.sys.exec("echo /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq")):match("%d+"))%>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Scaling governor%></label>
|
||||
<div class="cbi-value-field">
|
||||
<select class="cbi-input-select" name="scaling_governor">
|
||||
<%
|
||||
governor=luci.sys.exec("cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor")
|
||||
available_governors=luci.sys.exec("cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_governors")
|
||||
for gov in string.gmatch(available_governors, "[^%s]+") do
|
||||
%>
|
||||
<option value="<%=gov%>" <% if governor == gov then %>selected="selected"<% end %>>
|
||||
<%
|
||||
end
|
||||
%>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cbi-page-actions">
|
||||
<input type="hidden" name="token" value="<%=token%>" />
|
||||
|
|
27
luci-app-openmptcprouter/root/etc/init.d/openmptcprouter
Executable file
27
luci-app-openmptcprouter/root/etc/init.d/openmptcprouter
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=5
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
start_service() {
|
||||
local scaling_min_freq scaling_max_freq
|
||||
config_load openmptcprouter
|
||||
config_get scaling_min_freq settings scaling_min_freq
|
||||
[ -n "$scaling_min_freq" ] && {
|
||||
echo $scaling_min_freq > /sys/devices/system/cpu/cpufreq/policy*/scaling_min_freq
|
||||
}
|
||||
config_get scaling_max_freq settings scaling_max_freq
|
||||
[ -n "$scaling_max_freq" ] && {
|
||||
echo $scaling_max_freq > /sys/devices/system/cpu/cpufreq/policy*/scaling_max_freq
|
||||
}
|
||||
config_get scaling_governor settings scaling_governor
|
||||
[ -n "$scaling_governor" ] && {
|
||||
echo $scaling_governor > /sys/devices/system/cpu/cpufreq/policy*/scaling_governor
|
||||
}
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
rc_procd start_service
|
||||
return 0
|
||||
}
|
7
luci-app-openmptcprouter/root/etc/uci-defaults/openmptcprouter
Executable file
7
luci-app-openmptcprouter/root/etc/uci-defaults/openmptcprouter
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
uci -q batch <<-EOF
|
||||
delete ucitrack.@openmptcprouter[-1]
|
||||
add ucitrack openmptcprouter
|
||||
set ucitrack.@openmptcprouter[-1].init=openmptcprouter
|
||||
commit ucitrack
|
||||
EOF
|
Loading…
Add table
Add a link
Reference in a new issue