@@ -5,7 +5,7 @@ import { fetchIsConfigFile } from './common.js';
55
66async function getSelectedAlgorithm ( prefix ) {
77 try {
8- const { stdout : algo } = await exec ( `ls ${ router_state . moduleInformation . moduleDir } /${ prefix } _* 2>/dev/null | xargs -n 1 basename | head -n1 | awk -F_ '{print $NF}'` ) ;
8+ const { stdout : algo } = await exec ( `su -c " ls ${ router_state . moduleInformation . moduleDir } /${ prefix } _* 2>/dev/null | xargs -n 1 basename | head -n1 | awk -F_ '{print $NF}'" ` ) ;
99 switch ( prefix )
1010 {
1111 case "wlan" :
@@ -58,7 +58,7 @@ const fetchAvailableAlgorithms = async (force = false) => {
5858 try {
5959 if ( router_state . available_algorithms . length == 0 || force )
6060 {
61- const { stdout : output } = await exec ( 'cat /proc/sys/net/ipv4/tcp_available_congestion_control' ) ;
61+ const { stdout : output } = await exec ( 'su -c cat /proc/sys/net/ipv4/tcp_available_congestion_control' ) ;
6262 if ( output ) {
6363 // Split by whitespace and convert each into an object
6464 router_state . available_algorithms = output . trim ( ) . split ( / \s + / ) . map ( algo => algo ) ;
@@ -107,18 +107,18 @@ export async function initSettings() {
107107
108108 try
109109 {
110- await exec ( `rm -f ${ router_state . moduleInformation . moduleDir } /wlan_*` ) ;
111- await exec ( `rm -f ${ router_state . moduleInformation . moduleDir } /rmnet_data_*` ) ;
112- await exec ( `rm -f ${ router_state . moduleInformation . moduleDir } /kill_connections` ) ;
113- await exec ( `rm -f ${ router_state . moduleInformation . moduleDir } /initcwnd_initrwnd` ) ;
110+ await exec ( `su -c rm -f ${ router_state . moduleInformation . moduleDir } /wlan_*` ) ;
111+ await exec ( `su -c rm -f ${ router_state . moduleInformation . moduleDir } /rmnet_data_*` ) ;
112+ await exec ( `su -c rm -f ${ router_state . moduleInformation . moduleDir } /kill_connections` ) ;
113+ await exec ( `su -c rm -f ${ router_state . moduleInformation . moduleDir } /initcwnd_initrwnd` ) ;
114114
115- await exec ( `touch ${ router_state . moduleInformation . moduleDir } /wlan_${ settings . wifiAlgorithm } && chmod 644 ${ router_state . moduleInformation . moduleDir } /wlan_${ settings . wifiAlgorithm } ` ) ;
116- await exec ( `touch ${ router_state . moduleInformation . moduleDir } /rmnet_data_${ settings . cellularAlgorithm } && chmod 644 ${ router_state . moduleInformation . moduleDir } /rmnet_data_${ settings . cellularAlgorithm } ` ) ;
115+ await exec ( `su -c touch ${ router_state . moduleInformation . moduleDir } /wlan_${ settings . wifiAlgorithm } && chmod 644 ${ router_state . moduleInformation . moduleDir } /wlan_${ settings . wifiAlgorithm } ` ) ;
116+ await exec ( `su -c touch ${ router_state . moduleInformation . moduleDir } /rmnet_data_${ settings . cellularAlgorithm } && chmod 644 ${ router_state . moduleInformation . moduleDir } /rmnet_data_${ settings . cellularAlgorithm } ` ) ;
117117 if ( settings . killOnChange )
118- await exec ( `touch ${ router_state . moduleInformation . moduleDir } /kill_connections && chmod 644 ${ router_state . moduleInformation . moduleDir } /kill_connections` ) ;
118+ await exec ( `su -c " touch ${ router_state . moduleInformation . moduleDir } /kill_connections && chmod 644 ${ router_state . moduleInformation . moduleDir } /kill_connections" ` ) ;
119119
120120 if ( settings . setInitcwndInitrwndOnChange )
121- await exec ( `touch ${ router_state . moduleInformation . moduleDir } /initcwnd_initrwnd && chmod 644 ${ router_state . moduleInformation . moduleDir } /initcwnd_initrwnd` ) ;
121+ await exec ( `su -c " touch ${ router_state . moduleInformation . moduleDir } /initcwnd_initrwnd && chmod 644 ${ router_state . moduleInformation . moduleDir } /initcwnd_initrwnd" ` ) ;
122122
123123 console . log ( 'Applied settings:' , settings ) ;
124124
@@ -146,7 +146,7 @@ export async function initSettings() {
146146 var res = await applySettings ( ) ;
147147 if ( res == 0 )
148148 {
149- const { errno : output } = await exec ( `touch ${ router_state . moduleInformation . moduleDir } /force_apply && chmod 644 ${ router_state . moduleInformation . moduleDir } /force_apply` ) ;
149+ const { errno : output } = await exec ( `su -c " touch ${ router_state . moduleInformation . moduleDir } /force_apply && chmod 644 ${ router_state . moduleInformation . moduleDir } /force_apply" ` ) ;
150150 if ( output == 0 )
151151 toast ( "Wait for 5s to reflect changes!" ) ;
152152 }
0 commit comments