To run an ADB command automatically when your LineageOS 23.2 device starts, you need to place your command in a script that runs at boot. Here’s how you can do it:
You need to create a script that contains your ADB command. Since you have adb root access, you can place this script in a location that runs at boot, such as /data/local/userinit.d/ or /system/etc/init.d/ (if supported by your ROM).
bash#!/system/bin/sh # Wait for ADB to be ready while ! getprop sys.boot_completed | grep -q 1; do sleep 1 done # Your ADB command here your_adb_command_here
Replace your_adb_command_here with the actual command you want to run.
Save the script to a file, for example /data/local/userinit.d/your_script.sh.
Make sure the script is executable:
bashchmod 755 /data/local/userinit.d/your_script.sh
/system/etc/init.d/, you can also place the script there.init.d directory or by searching for related settings in your ROM’s configuration.If your device is rooted and you have Magisk installed, you can use the Magisk Boot Scripts module or create a custom module to run your script at boot.
After setting up, reboot your device and check if the command runs as expected. You can verify by checking logcat:
bashadb logcat | grep "your_script"
adb root is enabled before the script runs. You may need to add adb root as the first command in your script if it requires root access.chmod 755).