Autostart Mautrix/iMessage BlueBubbles Connector at Boot Using Cron
Important!
Follow the setup guide here created by @ampersandru and @matchstick.
For autostart with launchd follow this guide by @shadowdrake:beeper.com.
Creating a script to start the bridge
My script to start the bridge will be located in /Users/Shared/start-bridge.sh
The script is as follows: be sure to run chmod +x ./start-bridge.sh
to make it executable. This script also assumes bbctl is already in your path from following the setup guide.
Replace your_password
with your actual BlueBubbles password. Be sure to also enter the correct name of your bbctl executable.
I'm using ping here as a way to delay the start of the server until the Mac has fully booted up, if you have a newer or faster Mac you can possibly adjust the number of pings or remove this line.
Setting up cron
- Grant Full Disk Access to
cron
see here:
https://medium.com/vunamhung/granting-full-disk-access-to-cron-29d2267fbe62 - Grant Full Disk Access to
Terminal.app
Now open a terminal window and run:
echo $path
Make note of this output, this is everything in your path and will be important soon.
Now in the same Terminal window type:
export EDITOR=nano
- This can be skipped if you are wise enough to know how to exit vi 😉
Now finally type: crontab -e
Paste the following in obviously you'll want to modify PATH
with what is in your path while keeping the same syntax. You'll also want to modify the location of your bridge start script to where it resides on your system. I personally keep mine alongside bbctl.
Once you are sure everything is working after rebooting and testing edit the crontab and remove:
>> /Users/Shared/cron.log 2>&1
This is so the log file doesn't grow unbounded. For debugging purposes it can always be added back in the future. To see if the bridge is running check Activity Monitor for bbctl-<your-version> etc.
Here's a bonus shell script to restart your bridge without a command window:
Run chmod +x
on this script prior to usage. Change paths relevant to your setup.
Restart-Bridge.sh
Obviously change for your architecture and paths.
Special thanks to @matchstick for help with this guide.