A robust script that leverages Termux:Boot to automatically start the Brevent server via Shizuku on device startup.
- Reliable Startup: Intelligently waits for Shizuku to be ready before attempting to launch Brevent.
- Safe Timeouts: Prevents the script from waiting indefinitely. It will exit gracefully if Shizuku or Brevent fail to start in a timely manner.
- Detailed Logging: Every action is logged to a file, making troubleshooting simple.
- Customizable: Easily change timeout durations or the path to your
rishexecutable. - Instance Locking: Prevents multiple instances of the script from running simultaneously.
The script follows a simple, automated workflow when your device boots up:
- Boot Trigger:
Termux:Bootautomatically executes the script. - Wait for Shizuku: The script polls for the Shizuku service, waiting until it's fully initialized and ready to accept commands.
- Launch Brevent: Once Shizuku is active, the script uses
rish(Shizuku's command-line interface) to start the Brevent server. - Confirm & Exit: The script monitors for a success message from Brevent and then exits.
Follow these steps carefully to get the script running.
First, ensure you have the following applications installed and properly configured on your device:
Warning: Make sure these apps are installed and working correctly before proceeding.
This script needs to use rish, the tool that lets Termux talk to Shizuku.
-
Export
rishFiles:- In the Shizuku app, go to the Use Shizuku in terminal apps section.
- Tap Export files to copy
rishandrish_shizuku.dexto your Termux home directory.
-
Move and Configure
rish: Run the following commands in Termux to move the files to a standard location and configure them for use with Termux.# Create the target directory if it doesn't exist mkdir -p "$HOME/.local/bin" # Move the files mv "$HOME/rish" "$HOME/.local/bin/rish" mv "$HOME/rish_shizuku.dex" "$HOME/.local/bin/rish_shizuku.dex" # IMPORTANT: Set the Application ID for Termux # This command replaces the 'PKG' placeholder inside the rish script with Termux's package name. sed -i 's/PKG/com.termux/' "$HOME/.local/bin/rish" echo "✅ rish setup complete."
-
(Recommended) Add to PATH: To make it easier to run
rishmanually, add it to your shell'sPATH.# Add the local bin directory to your .bashrc file echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc # Apply the changes to your current session source ~/.bashrc
(If you use a different shell, please add the local bin directory to your PATH according to your shell's configuration method.)
Place the script in the Termux:Boot startup directory.
# Create the Termux boot directory if it doesn't exist
mkdir -p "$HOME/.termux/boot/"
# Download the script from GitHub into that directory
curl -L "https://raw.githubusercontent.com/myuverr/auto-brevent-starter.sh/main/auto-brevent-starter.sh" -o "$HOME/.termux/boot/auto-brevent-starter.sh"
# Grant the script execute permissions
chmod +x "$HOME/.termux/boot/auto-brevent-starter.sh"
echo "✅ Script installed successfully!"That's it! Reboot your device. Termux:Boot will run the script, which will wait for Shizuku and then start Brevent.
Manual Activation: You can manually run the script at any time to start the Brevent service without rebooting. This is useful if the service stops for any reason.
~/.termux/boot/auto-brevent-starter.sh
You can easily tweak the script's behavior by editing the constants at the top of the file.
Open the script with a text editor (e.g., nvim or any other text editor you prefer): nvim ~/.termux/boot/auto-brevent-starter.sh
Here are the most common variables to change:
RISH_PATH: Change this if yourrishexecutable is not in the default location.# Default: readonly RISH_PATH="$HOME/.local/bin/rish"
SHIZUKU_WAIT_TIMEOUT_MINUTES: How long the script waits for Shizuku (in minutes).# Default: 5 minutes readonly SHIZUKU_WAIT_TIMEOUT_MINUTES=5
BREVENT_LAUNCH_TIMEOUT_SECONDS: How long the script waits for Brevent to confirm its launch (in seconds).# Default: 60 seconds readonly BREVENT_LAUNCH_TIMEOUT_SECONDS=60
If something goes wrong, the log file is the first place to look.
- Log File Location:
~/.local/state/auto_brevent/script.log - View the Log:
cat ~/.local/state/auto_brevent/script.log - View the Log in Real-time:
tail -f ~/.local/state/auto_brevent/script.log
This project is licensed under the WTFPL.