Hello!
I am trying to change the value of the 'ro.config.tima' property from 1 to 0 using a boot script and resetprop,
I made a file in /data/adb/post-fs-data.d called 'resetprop.sh' and I put this into it:
Code:
#!/system/bin/sh
resetprop ro.config.tima 0
Then, I gave it execution permissions and rebooted, only to see that the value was still 1...
So I tried again, but this time I added other properties to that file to make sure that the script was running:
Code:
#!/system/bin/sh
resetprop ro.config.tima 0
resetprop ro.boot.warranty_bit 1
resetprop ro.warranty_bit 1
When I rebooted, the other properties changed from 0 to 1; while, the 'ro.config.tima' property stayed at 1.
I then tried a third time, this time I did the exact same thing but put the file in /data/adb/service.d instead, I rebooted and got the same result, the other properties changed to 1 and 'ro.config.tima' stayed at 1.
So then, I tried the "MagiskHide Props Config" Module but when I install it, it causes my whole system to crash and then my device restarts/reboots (Over and over again until I remove the module with TWRP).
Edit: My device is an SM-T350 (Samsung Galaxy Tab A)
Is there any way I can get this property to change to 0 Systemless-ly? Any help would be appreciated.
First try running the command in a terminal emulator. If that changes the value you can try adding a delay to the script before it executes the resetprop command (use service.d).
Didgeridoohan said:
First try running the command in a terminal emulator. If that changes the value you can try adding a delay to the script before it executes the resetprop command (use service.d).
Click to expand...
Click to collapse
When I type it in a Terminal emulator it changes to 0,
So how long of a delay should I add?
JJcoder said:
When I type it in a Terminal emulator it changes to 0,
So how long of a delay should I add?
Click to expand...
Click to collapse
Start with sleep 60 and if that works you can try 30 and so on until you find a value that works and you're comfortable with.
Didgeridoohan said:
Start with sleep 60 and if that works you can try 30 and so on until you find a value that works and you're comfortable with.
Click to expand...
Click to collapse
Thanks, I will let you know if it works.
Didgeridoohan said:
Start with sleep 60 and if that works you can try 30 and so on until you find a value that works and you're comfortable with.
Click to expand...
Click to collapse
Unfortunately, it did not work. Is there anything else I can try? This is what I have in the 'resetprop.sh' file located in /data/adb/service.d:
Code:
#!/system/bin/sh
sleep 60
resetprop ro.config.tima 0
JJcoder said:
Unfortunately, it did not work. Is there anything else I can try? This is what I have in the 'resetprop.sh' file located in /data/adb/service.d:
Code:
#!/system/bin/sh
sleep 60
resetprop ro.config.tima 0
Click to expand...
Click to collapse
If 60 doesn't work, try a longer time...
Didgeridoohan said:
If 60 doesn't work, try a longer time...
Click to expand...
Click to collapse
I tried 100, 300, 500, even 1000 and none of them have worked...
How much longer do I have to go? Or am I going to have to do something else?
Try something like this:
Code:
LOC="/data/media/0/tima_test.txt"
echo "$(date +"%H:%M:%S")" > $LOC
resetprop -v ro.config.tima 0 >> $LOC
until [ "$(getprop ro.config.tima)" == 1 ]; do
sleep 1
done
echo "$(date +"%H:%M:%S")" >> $LOC
resetprop -v ro.config.tima 0 >> $LOC
getprop ro.config.time >> $LOC
That is pure untested air code, but in theory it should let us know if the prop value resets to 1 sometime after boot, and when it happens. If nothing else, it might give us some info on what happens when resetprop runs on that prop (but unless something is wrong it'll likely not show anything).
All the info should be in the tima_test.txt file on your internal storage. Wait a good while before you check it...
Related
Im running a userinit file for the cyanogen 3.91 rom and if tried to run it with now success. it just shows 000 on the swap when i run free. and when i try to run cat /proc/ramzswap it says that no such directory exists,
this is the userinit.sh
#!/system/bin/sh
# $Id: userinit.sh,v 1.2 2009/07/17 01:11:25 noah Exp $
# Do not change the #! above and expect that shell to invoke this script at
# boot, because a2sd forcibly calls this with /system/bin/sh.
PATH=/system/xbin/bb:$PATH
# Currently our busybox build uses the "small" modprobe and insmod,
# which don't support parameter arguments. (The usage string lies.)
uname_r=`uname -r`
moddir=`find /system/modules -type d -name $uname_r`
insmod=/system/bin/insmod
if $insmod $moddir/compcache/xvmalloc.ko &&
$insmod $moddir/compcache/ramzswap.ko disksize_kb=32768
then
sysctl -w vm.swappiness=40
mknod /dev/ramzswap0 b 253 0
swapon /dev/ramzswap0
fi
exit;
# eof
yeah dude im getting the same problem. Ive asked everywhere and no one can help. the only difference i notice are the two lines (exit; # eof) at the end of yours.
EDIT:
DUDE, just got it to work, this is what to do:
go here: http://forum.xda-developers.com/showthread.php?t=537236
download the text file.
open the text file delete everything and paste this in:
Code:
#!/system/bin/sh
# $Id: userinit.sh,v 1.2 2009/07/17 01:11:25 noah Exp $
# Do not change the #! above and expect that shell to invoke this script at
# boot, because a2sd forcibly calls this with /system/bin/sh.
PATH=/system/xbin/bb:$PATH
# Currently our busybox build uses the "small" modprobe and insmod,
# which don't support parameter arguments. (The usage string lies.)
uname_r=`uname -r`
moddir=`find /system/modules -type d -name $uname_r`
insmod=/system/bin/insmod
if $insmod $moddir/compcache/xvmalloc.ko &&
$insmod $moddir/compcache/ramzswap.ko disksize_kb=32768
then
sysctl -w vm.swappiness=40
mknod /dev/ramzswap0 b 253 0
swapon /dev/ramzswap0
fi
save it and close it
rename it userinit.sh and type this in adb:
Code:
adb push userinit.sh /system/sd
adb shell chmod 755 /system/sd/userinit.sh (not sure if needed being safe)
adb shell reboot
hope that helps
did you get it to work on 3.91?
ive tried everything and still swap is 0 0 0 0
I'm not an expert in the whole compcache thing I haven't followed it but doesn't "free" in terminal show swap, not compcache? I believe "cat /proc/ramzswap" shows compcache compression..
alritewhadeva said:
I'm not an expert in the whole compcache thing I haven't followed it but doesn't "free" in terminal show swap, not compcache? I believe "cat /proc/ramzswap" shows compcache compression..
Click to expand...
Click to collapse
"free" shows the swap file total, used and free. ramzswap goes more indepth
ubernicholi said:
"free" shows the swap file total, used and free. ramzswap goes more indepth
Click to expand...
Click to collapse
ah ok. Thanks for the clarification.
i tried the cat /proc/ramzswap and it said the file or directory could not be found
Compache DOES NOT WORK ON 3.9.1
I want to make an echo command with magisk on boot
echo 0 > /sys/class/leds/button-backlight/max_brightness
so that it is applied on boot automatically
how to do that ?
thanks in advance
Just put your script in
Code:
/magisc/.core/service.d
and set execution permissions.
Since you want to edit sys files, you will need root permission. An example script would be (brightness.sh) :
Code:
#!/system/bin/sh
su -c 'echo 0 > /sys/class/leds/button-backlight/max_brightness'
Note :
If you want to execute your script at another boot stage you should have a look at this
pec0ra said:
Just put your script in
Code:
/magisc/.core/service.d
and set execution permissions.
Since you want to edit sys files, you will need root permission. An example script would be (brightness.sh) :
Code:
#!/system/bin/sh
su -c 'echo 0 > /sys/class/leds/button-backlight/max_brightness'
Note :
If you want to execute your script at another boot stage you should have a look at this
Click to expand...
Click to collapse
Can you tell what the -c flag in your example script is for?
Yaseen_the_Gamer said:
Can you tell what the -c flag in your example script is for?
Click to expand...
Click to collapse
https://github.com/topjohnwu/Magisk/blob/master/docs/tools.md#su
It's to use su directly in the command, basically.
Although in this case it's technically unnecessary since all Magisk boot scripts are run with superuser access.
Dear Community, dear Developers outside..
I'm using Magisk 14.0 on a Redmi Note 4 Snapdragon and super satisfied with it.
I just want to make simple changes like changing the lowmemorykiller minfree parameters - just like an init.d script in Kernel Adiutor..
Most of the commands are effective - but some of them are not..
This is what I want to apply for example:
chmod 666 /sys/module/lowmemorykiller/parameters/minfree
chown root /sys/module/lowmemorykiller/parameters/minfree
echo '7283,14566,21849,28928,36415,43698' > /sys/module/lowmemorykiller/parameters/minfree
..but does not work..
But these, for example.. these are working just fine:
echo '30' > /proc/sys/vm/swappiness
echo '0' > /sys/module/lowmemorykiller/parameters/enable_adaptive_lmk
echo '80' > /proc/sys/vm/overcommit_ratio
echo '400' > /proc/sys/vm/vfs_cache_pressure
echo '2430' > /proc/sys/vm/extra_free_kbytes
echo '4096' > /proc/sys/kernel/random/write_wakeup_threshold
echo '1024' > /sys/block/mmcblk0/queue/read_ahead_kb
echo '0' > /sys/block/mmcblk0/queue/iostats
echo '1' > /sys/block/mmcblk0/queue/add_random
echo '1024' > /sys/block/mmcblk1/queue/read_ahead_kb
echo '0' > /sys/block/mmcblk1/queue/iostats
echo '1' > /sys/block/mmcblk1/queue/add_random
swapoff /dev/block/zram0 > /dev/null 2>&1
echo '1' > /sys/block/zram0/reset
echo '0' > /sys/block/zram0/disksize
echo '1' > /sys/block/zram0/max_comp_streams
echo '524288000' > /sys/block/zram0/disksize
mkswap /dev/block/zram0 > /dev/null 2>&1
swapon /dev/block/zram0 > /dev/null 2>&1
echo '4096' > /proc/sys/kernel/random/read_wakeup_threshold
echo '4096' > /proc/sys/vm/min_free_kbytes
echo '0' > /proc/sys/vm/oom_kill_allocating_task
echo '90' > /proc/sys/vm/dirty_ratio
echo '70' > /proc/sys/vm/dirty_background_ratio
I do know that all I have to do is to put my script to one of these dirs - depending on when I want to run the scripts:
/magisk/.core/service.d
/magisk/.core/post-fs-data.d
But, as I mentioned - most of them has effect, some of them has no..
Any comment, any suggestion is more than appreciated.
Thank you!
[SOLVED] - solution is in post #5
Desperate bump..
I searched for help docs for service.d and post-fs-data.d but counldn't find them, can I ask you when each folder is executed, also does the scripts inside them must have .sh extension or not ?
I want to restart my systemui after boot complete, can you tell me if this script is ok ?
Code:
#!system/bin/sh
sleep 20
su
pkill -l TERM -f com.android.systemui
ps : the pkill command works fine after an "su" in terminal emulator
sorry for the offtopic !
@sheraro
https://github.com/topjohnwu/Magisk/blob/master/docs/README.MD
First of all: the solution for my issue was a simple sleep 30 in the services.sh to delay the start.. and I used an auxiliary file as well to make the changes (called from services.sh with 30sec delay, copied with the update-binary file directly, set permission to 0777 via config.sh) after that is all started working..
sheraro said:
I searched for help docs for service.d and post-fs-data.d but counldn't find them, can I ask you when each folder is executed, also does the scripts inside them must have .sh extension or not ?
I want to restart my systemui after boot complete, can you tell me if this script is ok ?
Code:
#!system/bin/sh
sleep 20
su
pkill -l TERM -f com.android.systemui
ps : the pkill command works fine after an "su" in terminal emulator
sorry for the offtopic !
Click to expand...
Click to collapse
So, second thing, @sheraro, I think you should delete the command su from your script because Magisk scripts are running as root anyway and if you issue su command it will start a shell with elevated privileges - an interactive shell, not what you want here, a sudo like command.. it works in the terminal because it is interactive but in the shell script if you start su it starts an interactive shell and it halts your script because it won't exit the shell you started.. and the next command will never run.. if you know what I mean.. but you don't need it anyway, because - as I mentioned - it is running as root anyway. +1: The syntax of the shebang is bad in your example, it is missing an exclamation mark. Can you re-test it like this:
Code:
#!/system/bin/sh
sleep 20
pkill -l TERM -f com.android.systemui
exit 0
.sh extension is not needed, the thing is: you have to set the correct permission in the config.sh like this:
Code:
set_permissions() {
# Default permissions, don't remove them
set_perm_recursive $MODPATH 0 0 0777 0777
[..omitted..]
Thing is: the files must have execute priv. and you can execute them like
Code:
$MODDIR/./desiredfilename
in the services.sh script.
Hope this helps.
crok.bic said:
.sh extension is not needed, the thing is: you have to set the correct permission in the config.sh like this:
Code:
set_permissions() {
# Default permissions, don't remove them
set_perm_recursive $MODPATH 0 0 0777 0777
[..omitted..]
Thing is: the files must have execute priv. and you can execute them like
Code:
$MODDIR/./desiredfilename
in the services.sh script.
Hope this helps.
Click to expand...
Click to collapse
I'm just pasting my script in service.d only, set permissions manually to 0777, corrected !#/system typo, removed su command, but no luck...
Where's services.sh and config.sh ?
sheraro said:
I'm just pasting my script in service.d only, set permissions manually to 0777, corrected !#/system typo, removed su command, but no luck...
Where's services.sh and config.sh ?
Click to expand...
Click to collapse
Reading your comment I think you are not developing a Magisk module, do you?
I do and this is why you have no idea where is config.sh, services.sh and the others I think.
If you just want to have some kind of "init.d script" support and run the script in your own phone *only* then your script should be in the folder /magisk/.core/service.d and it should have execute permission. That's all what you need - probably the sleep 20 is not enough, increase it to sleep 30 for instance.
If this is still not enough info I would suggest to read the Magisk documentation thoroughly (linked in post #4) and if you still stuck I suggest you to open your own thread, describe your problem thoroughly (what is your goal? what would you like to achive? how did you already try? what is happening but should not or not happening but you think it should happen? you know what I mean..) and ask the community. Probably you will be able to solve your issue in minutes/hours.
I changed it to sleep 100, same problem, you're right I should create a new thread for this.
I have a theme installed that mimics oreo style, but the systemUI is not themed until it's restarted, so I thought about a script executed after boot, anyway thanks for your help
It seems that sleep will delay the run of other modules' service.sh. is there any solution that will not affect other module?
nicorg3221 said:
It seems that sleep will delay the run of other modules' service.sh. is there any solution that will not affect other module?
Click to expand...
Click to collapse
I don't experience this behavior - what you described is the post-fs-data behavior.
I did the trick with a separate ("auxiliary") file and tried to explain how in post #5 but let me try again:
- created a file in the module's common folder (I gave the name `tweak`)
- this file starts with a shebang (it's a script..) and continues with a sleep 30 then comes my commands..
- then copied the file from the module to the Magisk module directory into /magisk/$MODDIR with the module file META-INF/com/google/android/update-binary (I added it to the copy section, manually.. I know, I know, it should work automagically anyway, but did not work and I was fed up with the coding, so hardcoded it.. sorry)
- I set the default file permission to 0777 in config.sh (yes, 0777, this is loose AF but works.. and I don't really care, the file contains code that can make the device *better* and has no suid bit set, so there is only little to no room to harm anything..)
- then I included a call in my module's common/service.sh like $MODDIR/./tweak to start my script
- when the tweak script starts it will start with the sleep 30 so implements the delay.. BUT!
- Because services.sh files from the modules are called parallelly by Magisk (by default, by it's nature, by it's code.. you got it) my module does not delays others - but still has the delay.
Hope this helps.
sheraro said:
I changed it to sleep 100, same problem, you're right I should create a new thread for this.
I have a theme installed that mimics oreo style, but the systemUI is not themed until it's restarted, so I thought about a script executed after boot, anyway thanks for your help
Click to expand...
Click to collapse
Pleased to help you - but honestly, if the only task you need is to kill and restart systemUI then I would do it via init.d script run by an app that mimics init.d scripting, or using a kernel that supports init.d scripts (if only you want to use that theme). It's just less complex for you I think, but honestly, a simple script file that has execute permission in /magisk/.core/services.d/ gives you 100% the same solution.
crok.bic said:
I don't experience this behavior - what you described is the post-fs-data behavior.
I did the trick with a separate ("auxiliary") file and tried to explain how in post #5 but let me try again:
- created a file in the module's common folder (I gave the name `tweak`)
- this file starts with a shebang (it's a script..) and continues with a sleep 30 then comes my commands..
- then copied the file from the module to the Magisk module directory into /magisk/$MODDIR with the module file META-INF/com/google/android/update-binary (I added it to the copy section, manually.. I know, I know, it should work automagically anyway, but did not work and I was fed up with the coding, so hardcoded it.. sorry)
- I set the default file permission to 0777 in config.sh (yes, 0777, this is loose AF but works.. and I don't really care, the file contains code that can make the device *better* and has no suid bit set, so there is only little to no room to harm anything..)
- then I included a call in my module's common/service.sh like $MODDIR/./tweak to start my script
- when the tweak script starts it will start with the sleep 30 so implements the delay.. BUT!
- Because services.sh files from the modules are called parallelly by Magisk (by default, by it's nature, by it's code.. you got it) my module does not delays others - but still has the delay.
Hope this helps.
Click to expand...
Click to collapse
I have my script in starting in .Core. Maybe that's the problem
nicorg3221 said:
I have my script in starting in .Core. Maybe that's the problem
Click to expand...
Click to collapse
..then it is in the wrong dir.. it is clearly described in the Magisk documentation.
I have researched a bit. I think you can use getprop sys.boot_completed to check if boot is completed. We should run init.d scripts after boot is completed instead of just wait for 30/100 seconds.
I place all my init.d scripts I want to run in /magisk/.core/service.d/init.d.
Then, I have a service.d script [exec_init_d.sh] in /magisk/.core/service.d. Magisk will run exec_init_d.sh when boot.
exec_init_d.sh will wait for sys.boot_completed and run all the files in /magisk/.core/service.d/init.d after boot completed
exec_init_d.sh
Code:
#!/system/bin/sh
# Please don't hardcode /magisk/modname/... ; instead, please use $MODDIR/...
# This will make your scripts compatible even if Magisk change its mount point in the future
MODDIR=${0%/*}
# This script will be executed in late_start service mode
# More info in the main Magisk thread
if [ "$1" != "1" ]; then
$0 1 &
log -p i -t Magisk "start new instance to let Magisk boot stages proceed"
exit
fi
#param
RUNLOG=0
RETRY_INTERVAL=5 #in seconds
MAX_RETRY=60
EXEC_WAIT=3 #in seconds
INIT_D_DIR=$MODDIR/init.d
LOG_PATH=$MODDIR/debug.log
#init
retry=${MAX_RETRY}
#wait for boot completed
log -p i -t Magisk "wait for boot completed"
while (("$retry" > "0")) && [ "$(getprop sys.boot_completed)" != "1" ]; do
sleep ${RETRY_INTERVAL}
((retry--))
done
if (("$retry" == "0")); then
log -p i -t Magisk "boot not completed within maximum number of retry"
else
log -p i -t Magisk "boot completed"
fi
sleep ${EXEC_WAIT}
log -p i -t Magisk "init.d execution started from ${INIT_D_DIR}"
if (("${RUNLOG}" == "1")); then
/data/magisk/busybox run-parts $INIT_D_DIR &> $LOG_PATH
log -p i -t Magisk "init.d execution output written to $LOG_PATH"
else
/data/magisk/busybox run-parts $INIT_D_DIR
fi
log -p i -t Magisk "init.d execution completed"
Magisk v19.3 on lineageos 16.0 for wt86047
trying to create my first module, no files to replace, just one task: run a remove.sh script
I put following two lines in ./common/service.sh , but there's no file created after boot , seems the service.sh itself never be run at all.
echo -e "\n------------${MODPATH}----------------------------" >> /sdcard/s.txt >&1
sh ./remove.sh
LATESTARTSERVICE=true in ./install.sh --YES
./META-INF/com/google/android/update-binary updated --YES
./module.prop edited --YES
the module installed with no error --YES
manual run remove.sh successfully in terminal after reboot --YES
called from service.sh --NO
need help, THANK YOU!
attached remove.sh
Code:
#!/system/bin/sh
DIRFILE="/sdcard/dir"
if [ -f "$USRFILE" ];then
while IFS= read -r LINE
do
if [ -n "${LINE}" ];then
...
...
fi
I haven't looked at what might be your issue, but you don't need a module for that... Just place your remove.sh script in /data/adb/service.d and give it execution permission.
Didgeridoohan said:
I haven't looked at what might be your issue, but you don't need a module for that... Just place your remove.sh script in /data/adb/service.d and give it execution permission.
Click to expand...
Click to collapse
thanks. but it doesn't work either.
When I manually run the script from terminal, it prompt 'Permission denied.'
But it works after execute 'su' first.
Is this the reason? But how could I authorise root right to the script since it doesn't pop dialogbox at all.
Again, I haven't looked at your script at all, but...
Any scripts run by Magisk at boot will run with superuser permission. That's not your issue...
Might be that the script has to run after boot is completed (if it works while booted but not during boot). You can look for the sys.boot_completed and when it's changed to 1 you can let the script execute.
I use this code in my modules, if it can help
Code:
_SLEEPBOOT=60
# ...
RETRY_INTERVAL=${_SLEEPBOOT} #in seconds
MAX_RETRY=30
retry=${MAX_RETRY}
while (("$retry" > "0")) && [ "$(getprop sys.boot_completed)" != "1" ]; do
sleep ${RETRY_INTERVAL}
((retry--))
done
Didgeridoohan said:
Again, I haven't looked at your script at all, but...
Any scripts run by Magisk at boot will run with superuser permission. That's not your issue...
Might be that the script has to run after boot is completed (if it works while booted but not during boot). You can look for the sys.boot_completed and when it's changed to 1 you can let the script execute.
Click to expand...
Click to collapse
Code:
# Wait for boot to complete
until [ "$(getprop sys.boot_completed)" ]
do
sleep 2
done
insert this code to script but still not work...
after all, found the solution:
don't use '/sdcard/, use '/storage/emulated/0/' instead, don't know why
funnypc said:
Code:
# Wait for boot to complete
until [ "$(getprop sys.boot_completed)" ]
do
sleep 2
done
insert this code to script but still not work...
after all, found the solution:
don't use '/sdcard/, use '/storage/emulated/0/' instead, don't know why
Click to expand...
Click to collapse
Might have worked if you had checked for sys.boot_completed = 1.
But yeah, /sdcard isn't available during boot. To be even more sure it'll work you could use /data/media/0 instead. That's always available (as long as /data is accessible).
Didgeridoohan said:
Might have worked if you had checked for sys.boot_completed = 1.
But yeah, /sdcard isn't available during boot. To be even more sure it'll work you could use /data/media/0 instead. That's always available (as long as /data is accessible).
Click to expand...
Click to collapse
though the script can work alone , I still want make it a module so that could install/disable easier with magisk gui than terminal.
currently I'm add a 'bypass' mode while script load, if volume key pressed repeatly. (like xposed does) but the code can only work after unlock, it seems the getevent can't work after system reboot, before keyguard unlocked. any workaround? thx!
Code:
#!/system/bin/sh
KEYSTRING="KEY_VOLUME"
KEYREPEAT=1
KEYCOUNTS=0
until [ "$(getprop sys.boot_completed)" ]
do
sleep 2
done
setenforce Permissive
echo 300 > /sys/class/timed_output/vibrator/enable
sleep 0.3
for i in `seq 1 4`;
do
EVENT=$(timeout 1 getevent -l -q -c 1)
RESULT=`echo $EVENT | grep -c $KEYSTRING`
input keyevent mouse
if [ "$RESULT" -gt 0 ] ;then
KEYCOUNTS=`expr $KEYCOUNTS + $RESULT`
echo 100 > /sys/class/timed_output/vibrator/enable
fi
done
if [ "$KEYCOUNTS" -gt "$KEYREPEAT" ] ;then
echo 1000 > /sys/class/timed_output/vibrator/enable
fi
Simple, just put your code in the service.sh file of the module instead of a separate script file...
Didgeridoohan said:
Simple, just put your code in the service.sh file of the module instead of a separate script file...
Click to expand...
Click to collapse
can't work. so I put the keypress detection part in a standalone script for debug. just script in service.d folder, not pack to module yet.
if I run the script manually in terminal after keyguard unlocked, everything works as I want
but not when keyguard locked status just after reboot.
funnypc said:
can't work. so I put the keypress detection part in a standalone script for debug. just script in service.d folder, not pack to module yet.
if I run the script manually in terminal after keyguard unlocked, everything works as I want
but not when keyguard locked status just after reboot.
Click to expand...
Click to collapse
I mean the code from your remove.sh file, not the key detecting stuff... That way you can disable the module from the Manager and also from TWRP (or other custom recovery) by placing a disable file in the module directory or enabling Magisk Core Only Mode by placing a .disable_magisk file in /cache.
Hello, everyone.
In order to avoid an XY problem, I would like to introduce the actual problem first.
I need to run a script each time network changes. Android automatically changes quite a few settings when network changes, and because I need to have some of them set to specific values, I need to tweak them each time something happens.
How would I like to proceed:
There is a sysprop setting that changes each time network changes: sys.radio.cellular.netId.
Naturally, I would like to hook my script to that property change.
Android init system seems to provide such an option: init.rc syntax allows to subscribe to a property change using the
Code:
on property:propname=*
syntax.
Seems easy:
Add a custom_network.rc
Bash:
on property:sys.radio.cellular.netId=*
start custom_network
service custom_network /bin/custom_network.sh
user root
seclabel u:r:magisk:s0
oneshot
Add a file /bin/custom_network.sh:
Bash:
#/system/bin/sh
echo "TODO"
The above is essentially following this guide: https://android.stackexchange.com/q...run-an-executable-on-boot-and-keep-it-running
So, I created a magisk module, added the files above to the $MODDIR/system/etc/init, and $MODDIR/system/bin directories.
Then I added the following lines to the customize.sh:
Bash:
set_perm $MODPATH/system/bin/custom_network.sh 0 0 0755
set_perm $MODPATH/bin/custom_network.sh 0 0 0755
chown 0.0 $MODPATH/system/etc/init/custom_network.rc
chmod 0644 $MODPATH/system/etc/init/custom_network.rc
chcon u:object_r:system_file:s0 $MODPATH/system/etc/init/custom_network.rc
However, this does not work. The service custom_network does not appear in the getprop | grep svc list, and cannot be started with setprop ctl.start "custom_network".
Is it true that in order for _any_ custom rc files, the system boot image must be patched?
If yes, is there a manual how to do so?
If no, then what am I doing wrong here?
Furthermore, if patching the boot image cannot be avoided, is there a manual on how to do this with minimal pain?
On the other hand, is there a way to avoid adding a custom init service entirely, and add a network listener by some other means?
Did you figure it out?
I don't believe init services get a stdout.
You need to write to either /dev/kmsg or logcat.
You can test your service with start custom_network.
You could also listen for uevents:
Code:
s=socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
Although I'm not sure what you're looking for is there.
I was mostly looking for feedback by someone also wanting to patch the init.rc: I'm still trying to understand the cascade of events causing adbd to be started twice in boot, to find and modify the rc script responsible for the first time it's started and use instead a patched adbd
csdvrx said:
I was mostly looking for feedback by someone also wanting to patch the init.rc: I'm still trying to understand the cascade of events causing adbd to be started twice in boot, to find and modify the rc script responsible for the first time it's started and use instead a patched adbd
Click to expand...
Click to collapse
have you figured it out ? i have the same issue , i am trying to create a file at /system/etc/init folder