This week I read a post about the death of the Boeing whistleblower, and how Boeing might have suicided him.

I don’t care about if the rumors are true or not, however someone mentioned in the comments that in such situations one should always have a Dead Man Switch.

For those who don’t know a Dead Man Switch is basically an action TBD in case you die, like leaking documents, send messages/emails, kill a server etc . . .

The concept tickled me a bit, and I decided I want to build a similar system for myself. No, I am not in danger but I would like to send last goodbyes to friends and family. I think it would be cool concept.

How would you go and build such service?

I thinking of using a VPS to do the actions because it would be running for a while before my debit card gets cancelled.

The thing that is bugging me out is the trigger, I will not put that responsibility onto someone that’s cheating, so it would have to be something which can reliably tell I am dead and has to run regularly.

Where is what I come up with :

  • Ask a country association through email if am I am dead.

  • Check if I haven’t logged out on my password manager in a week. If it’s even possible.

TLDR; Give me ideas on how to build a DEAD MAN SWITCH and what triggers should I use.

  • Eager Eagle@lemmy.world
    link
    fedilink
    English
    arrow-up
    11
    ·
    9 months ago
    #!/bin/bash
    
    SERVICE="irl_heartbeat"
    LOGFILE="/var/log/heartbeat_monitor.log"
    EMAIL="friends_and_family@example.com"
    SUBJECT="Alert: irl_heartbeat service stopped"
    BODY="See y'all in hell"
    
    if systemctl is-active --quiet $SERVICE; then
        echo "$(date "+%Y-%m-%d %H:%M:%S") - $SERVICE is running" >> $LOGFILE
    else
        LAST_ACTIVE=$(systemctl show $SERVICE --property=InactiveExitTimestamp | cut -d'=' -f2)
        CURRENT_TIME=$(date +%s)
        LAST_ACTIVE_TIME=$(date -d "$LAST_ACTIVE" +%s)
        DIFF=$(( (CURRENT_TIME - LAST_ACTIVE_TIME) / 60 ))
    
        if [ "$DIFF" -gt 20 ]; then
           echo "$BODY" | mail -s "$SUBJECT" $EMAIL
           echo "$(date "+%Y-%m-%d %H:%M:%S") - Email alert sent: $SERVICE has been inactive for more than $DIFF minutes" >> $LOGFILE
        else
           echo "$(date "+%Y-%m-%d %H:%M:%S") - No alert sent. $SERVICE has been inactive for $DIFF minutes, which is less than the threshold of 20 minutes." >> $LOGFILE
        fi
    fi
    
    

    pls test it accordingly before use