I'm going to apologize up front if this isn't the right place to ask about this... if not, please point me in the right direction.
I have a Mac Pro 2013 in a relative's basement, acting as my offsite backup target. I have a four-bay thunderbolt enclosure with four drives in it, configured as a RAID-10 set with Apple RAID. I've been using Apple RAID on my home backup server for years, and it has worked flawlessly. The downside for an offsite server is that if a disk or raid set fails, there are no notifications. One disk in a mirrored pair can fail and the volume(s) just keep on chugging along, because the other disk is still healthy. This is something I would notice fairly quickly on my home server, but is not something I'd be likely to notice on a remote server for a long while.
I thought I could easily fix this problem by writing a shell script to check the health of the RAID sets and send me a text notification if anything was amiss. I wrote the script, and set up a notification using osascript (AppleScript) to message me with my iCloud e-mail address as sender and my cell phone number as the recipient. I tested it, and it worked like a charm. HOWEVER, when I set up the launchd job to run the script at specified times, it all worked EXCEPT the text message. The texts work fine when I'm logged in and manually run the shell script. The texts do not work when the screen is locked, even if I'm logged in.
Google's AI suggested a few tweaks, but none worked. Then it concluded that osascript calls to Messages can't possibly work if the screen is locked. It suggested I use msmtp, sending the notification as an e-mail to my mobile provider's email-to-SMS service. I installed msmtp, attempted to get this working, and discovered that my mobile provider (AT&T) discontinued their email-to-SMS service last year. Apparently all providers are discontinuing this kind of thing to cut down on SPAM.
Then the AI suggested I use one of the commercial services that do email-to-SMS. Unfortunately these are all either subscription services, way-too-expensive, or both. I don't want to send 1000 SMS messages per month; I want to send an occasional message if something is wrong on a remote server. Outside of testing to ensure it works, I wouldn't be surprised if I didn't get one of these texts in an entire year. (My script only sends a notification if something is wrong with the health of the RAID set or the disks.)
The last suggestion made by Google AI is, quote: "To send an iMessage via a local webhook while your screen is locked, bypass the AppleScript GUI limitation by running a tiny, headless server locally on your Mac." It suggests BlueBubbles for this purpose. BlueBubbles is an application designed to run on a Mac and send iMessages for Android users, so their texts are fully compatible with Apple's iMessage protocol and therefore show up in their app in blue text bubbles, as they would on an iPhone.
I haven't tried this yet, because every time I've tried one of the AI's suggestions before now, it hasn't worked out. This SEEMS like it should be simple... is there something I'm missing here?
(ETA: To clarify, I mean that it seems like sending a text notification via some scripted action should be simple. And it *is* simple using AppleScript as described above, as long as I'm logged in and manually running the script. But if I want the script to run when the screen is locked, on a schedule, and for the text notification to work, do I really have to be jumping through all these hoops?)
I have a Mac Pro 2013 in a relative's basement, acting as my offsite backup target. I have a four-bay thunderbolt enclosure with four drives in it, configured as a RAID-10 set with Apple RAID. I've been using Apple RAID on my home backup server for years, and it has worked flawlessly. The downside for an offsite server is that if a disk or raid set fails, there are no notifications. One disk in a mirrored pair can fail and the volume(s) just keep on chugging along, because the other disk is still healthy. This is something I would notice fairly quickly on my home server, but is not something I'd be likely to notice on a remote server for a long while.
I thought I could easily fix this problem by writing a shell script to check the health of the RAID sets and send me a text notification if anything was amiss. I wrote the script, and set up a notification using osascript (AppleScript) to message me with my iCloud e-mail address as sender and my cell phone number as the recipient. I tested it, and it worked like a charm. HOWEVER, when I set up the launchd job to run the script at specified times, it all worked EXCEPT the text message. The texts work fine when I'm logged in and manually run the shell script. The texts do not work when the screen is locked, even if I'm logged in.
Google's AI suggested a few tweaks, but none worked. Then it concluded that osascript calls to Messages can't possibly work if the screen is locked. It suggested I use msmtp, sending the notification as an e-mail to my mobile provider's email-to-SMS service. I installed msmtp, attempted to get this working, and discovered that my mobile provider (AT&T) discontinued their email-to-SMS service last year. Apparently all providers are discontinuing this kind of thing to cut down on SPAM.
Then the AI suggested I use one of the commercial services that do email-to-SMS. Unfortunately these are all either subscription services, way-too-expensive, or both. I don't want to send 1000 SMS messages per month; I want to send an occasional message if something is wrong on a remote server. Outside of testing to ensure it works, I wouldn't be surprised if I didn't get one of these texts in an entire year. (My script only sends a notification if something is wrong with the health of the RAID set or the disks.)
The last suggestion made by Google AI is, quote: "To send an iMessage via a local webhook while your screen is locked, bypass the AppleScript GUI limitation by running a tiny, headless server locally on your Mac." It suggests BlueBubbles for this purpose. BlueBubbles is an application designed to run on a Mac and send iMessages for Android users, so their texts are fully compatible with Apple's iMessage protocol and therefore show up in their app in blue text bubbles, as they would on an iPhone.
I haven't tried this yet, because every time I've tried one of the AI's suggestions before now, it hasn't worked out. This SEEMS like it should be simple... is there something I'm missing here?
(ETA: To clarify, I mean that it seems like sending a text notification via some scripted action should be simple. And it *is* simple using AppleScript as described above, as long as I'm logged in and manually running the script. But if I want the script to run when the screen is locked, on a schedule, and for the text notification to work, do I really have to be jumping through all these hoops?)
Last edited: