this post was submitted on 22 Mar 2024
101 points (97.2% liked)

Programming

17407 readers
107 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

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.

you are viewing a single comment's thread
view the rest of the comments
[–] eager_eagle@lemmy.world 11 points 7 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