Comment on Go Private?

<- View Parent
trk@aussie.zone ⁨1⁩ ⁨week⁩ ago

Is it possible to automate? I looked at the Lamington docs briefly and it looked like it uses a file to store config. Thought if the config file was a symlink it would make it easy to change config to be private / be public.

Like this every 30 minutes or whatever.

#!/bin/bash

THRESHOLD=1.5

CMD_HIGH="echo ln -sfn /blah/blah/config.json /blah/blah/config.json.private"
CMD_LOW="echo ln -sfn /blah/blah/config.json /blah/blah/config.json.public"

CPU_CORES=$(nproc)

LOAD_15MIN=$(uptime | awk -F'[a-z]:' '{print $2}' | awk -F', ' '{print $3}' | tr -d ' ')

if (( $(echo "$LOAD_15MIN > $THRESHOLD" | bc -l) )); then
    echo "[$(date)] High Load Detected - Current: $LOAD_15MIN, Threshold: $THRESHOLD"
    echo "[$(date)] Taking Lamington private........ "
    eval "$CMD_HIGH"
else
    echo "[$(date)] Normal Load Detected - Current: $LOAD_15MIN, Threshold: $THRESHOLD"
    echo "[$(date)] Returning Lamington to public... "
    eval "$CMD_LOW"
fi

source
Sort:hotnewtop