• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

Execute a script at boot

Search This thread

sverza

Senior Member
Jan 15, 2008
277
39
Hello, I'd like to execute a easy script at every boot of the phone so basically I've placed the script in the folder
/sbin/.magisk/img/.core/service.d/doze.disable.sh
I've tried also putting it in
/sbin/.magisk/img/.core/post-fs-data.d/doze.disable.sh
but even if the magisk log reports the script was executed... it isn't executed.

The script has the purpose to completely disable the doze and it has root/root and all r/w/x permissions

The content is
#!/system/bin/sh
su -c 'dumpsys deviceidle disable'

The magisk log is attached

Where am I wrong??
Or, how I can execute the script every boot?

Samsung S7 with The Galaxy Project OREO

Thanks
 

Attachments

  • magisk_log_20190129_093143.log
    1.4 KB · Views: 328

Didgeridoohan

Senior Moderator / Dev Committee / Dev Relations
Staff member
May 31, 2012
11,701
12,623
Gothenburg
Google Nexus 4
Nexus 6
A couple of things:
  1. You don't need to call su in the boot script. It's being executed by Magisk, which always has superuser access...
  2. post-fs-data.d might be too early. Try moving it to service.d instead. Depending on when that's being set during boot, you might also have to add a delay as to when the command is being run.
 

sverza

Senior Member
Jan 15, 2008
277
39
A couple of things:
  1. You don't need to call su in the boot script. It's being executed by Magisk, which always has superuser access...
  2. post-fs-data.d might be too early. Try moving it to service.d instead. Depending on when that's being set during boot, you might also have to add a delay as to when the command is being run.

Thanks,
1) I've tried also without calling the su option but without success. So I tried also calling it
2) after checking the script in the service.d didn't work I tried puttin it also in post-fs-data.d
... yes, I've tried different ways.

So something like this (considering 10 seconds)?
#!/system/bin/sh
sleep 10
dumpsys deviceidle disable
 

[email protected]

Senior Member
Jan 18, 2019
57
3
I'm running into this same problem, Magisk is saying it was executed but the process is not running. Here is my script in
/sbin/.magisk/img/.core/service.d/customboot.sh

The script runs fine when i run it via ssh but it never works on boot?

Code:
#!/system/bin/sh

sleep 30

/data/data/com.termux/files/usr/bin/rclone mount gDRIVE: /data/media/0/Movies \
 --config=/storage/sda1/tools/rclone/rclone.conf \
 --allow-non-empty \
 --allow-other \
 --dir-cache-time 72h \
 --cache-workers 6 \
 --debug-fuse \
 -v \
 --daemon
 
Last edited:

[email protected]

Senior Member
Jan 18, 2019
57
3
Have you tried running it on device (not trough ssh)? How about putting the command on one line?


hmm you found something interesting, when I launch termux and try to launch it from there directly off the device it doesn't work:

su
sh /sbin/.magisk/img/.core/service.d/customboot.sh

however there are no errors or anything like that. the command is not running in the processes I see via top (when i run the command thru ssh the process shows) and the log I designed only shows the sleep command and rclone command no other errors:

exec > /sbin/.magisk/img/.core/service.d/test.log 2>&1
set -x

I'm stuck at this point any ideas

edit--i figured it out it was a problem within rclone itself strangely enough it hda a dependency that didn't load till later
 
Last edited:

[email protected]

Senior Member
Jan 18, 2019
57
3
So now that I figured out I'm missing an environmental variable does anyone know how I can add a custom program as an environmental variable to Android or Magisk so that when my bootscript runs it calls the right programs and fix "executable file not found in $PATH"

figured it out:

#!/system/bin/sh
PATH=$PATH:<directory you want to add>
<rest of script>
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    It is causing delayed notification on some apps.
    Oreo
    Credit @return_of_0ctobot

    while [ "$(getprop sys.boot_completed)" != 1 ];
    do sleep 1;
    done

    Much more universal ... And does not require trial and error to find boot completed
    1
    A couple of things:
    1. You don't need to call su in the boot script. It's being executed by Magisk, which always has superuser access...
    2. post-fs-data.d might be too early. Try moving it to service.d instead. Depending on when that's being set during boot, you might also have to add a delay as to when the command is being run.
    1
    Something like that might work, yes. Have you made sure that the command works at all on your device? If it does it's likely a matter of finding the correct delay...
    1
    It seems it is working now, thanks for the tip "delay"
    1
    It seems it is working now, thanks for the delay tip

    No worries. Been there, done that, pulled my hair out in frustration... :laugh: