oO.o's Neverending Tech Blog

Not visible at all when it’s on the shelf so I left it. Maybe I’ll fix it one day, but not worth the time right now.

I bet you could find something like this from Germany. Can’t imagine what it would cost to import from US. Already kind of expensive.

1 Like

Yeah, these kind of metal drawers are quite common stuff so it shouldn’t be too difficult to find similar product here.

1 Like

I compiled dwm on CentOS 8 Stream. Figuring that out took all of 10 minutes. This might be my first distro hop.

3 Likes

This is my 3-tiered drive capacity email alert config script.

# weekly email alerts at 80% capacity

printf "%s" '#!/usr/bin/env bash

# safety first
set -euo pipefail
#set -x # debug
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

OVER_THRESHOLD="$(df  --local                 \
                      --output=target,pcent   \
                      --exclude-type tmpfs    \
                      --exclude-type devtmpfs |
                    egrep "[8-9][[:digit:]]%$|100%$")"

[ -z "${OVER_THRESHOLD:-}" ] ||
  printf "%s" "Subject: $(hostname -f) - Filesystem Capacity Warning
  The following filesystems are over 80% capacity:

  ${OVER_THRESHOLD}" |
    sendmail -F "storage@$(hostname -f) root"

exit $?' |
  sudo tee "/etc/cron.weekly/60-fs-80-capacity" >/dev/null

sudo chmod 755 "/etc/cron.weekly/60-fs-80-capacity"

# daily email alerts at 90% capacity

sed 's/\[8-9\]/9/
     s/80%/90%/'                         \
    "/etc/cron.weekly/60-fs-80-capacity" |
  sudo tee "/etc/cron.daily/60-fs-90-capacity" >/dev/null

sudo chmod 755 "/etc/cron.daily/60-fs-90-capacity"

# hourly email alerts at 98% capacity

sed 's/\[\[:digit:\]\]/[8-9]/
     s/90%/98%/'                         \
    "/etc/cron.daily/60-fs-90-capacity" |
  sudo tee "/etc/cron.hourly/60-fs-98-capacity" >/dev/null

sudo chmod 755 "/etc/cron.hourly/60-fs-98-capacity"
6 Likes

Fucking pipefail, God damn you sexy beast.

Legit pro

4 Likes

Ryzen + non-shit keyboard Macbook Air 2020 fingers crossed…

3 Likes

@nx2l you have a legacy now.

4 Likes

I’m so happy we pushed for that shirt.

Can’t wait to order it.

6 Likes

He’s the one that said it, so its funny he didnt know right away what I was talking about.

3 Likes

I think it’s also from something though.

Maybe it’s an old meme




That appears to be the original source.

1 Like

“Who said it better”

FInally happened. Solus has failed me.

sudo eopkg search sendmail
sudo eopkg search postfix
sudo eopkg search exim

Nada. How do I send myself email alerts?

Must have typo’d which mail before, Gnu mail is actually installed. I’d still prefer sendmail though since that’s what I use in all my scripts (for portability funny enough).

Wait, can Gnu mail even send anything externally? Idk, I’ll figure it out later.


Also just found the --grep= option in journalctl man page and thought, “hey, don’t have to pipe to grep, small win,” but alas…

Compiled without pattern matching support

That appears to be the case on Ubuntu as well, so maybe that’s normal? Funny that someone decided pattern matching was just one dependency too many for systemd… gotta draw the line somewhere I guess.

2 Likes

journalctl -g does work in CentOS 8.

1 Like

Script of the day: archive data onto tape and cloud.

Edit: updated to its final form. lto tapes and rclone are both very quirky…

2 Likes

So ran into a weird issue using sed to replace single quotes in a string.

This appeared to work great with everything except a single quote, in which case, it would append the replacement string to the end. No error code or anything.

$ ILLEGAL_CHAR="'"
$ OCTAL=00047
$ echo "My Family's Vacation" | sed "s/\\${ILLEGAL_CHAR}/\[${OCTAL}\]/g"
My Family's Vacation[00047]

If I don’t escape the character variable, it works:

$ ILLEGAL_CHAR="'"
$ OCTAL=00047
$ echo "My Family's Vacation" | sed "s/${ILLEGAL_CHAR}/\[${OCTAL}\]/g"
My Family[00047]s Vacation

Testing this on macOS, it behaves correctly in both instances. The above behavior is in current CentOS 7.

Since I do need to escape some illegal char values and failing to do so does result in an error code, my solution is to basically try-catch it.

$ ILLEGAL_CHAR="'"
$ OCTAL=00047
$ echo "My Family's Vacation" | { sed "s/${ILLEGAL_CHAR}/\[${OCTAL}\]/g" 2>/dev/null || sed "s/\\${ILLEGAL_CHAR}/\[${OCTAL}\]/g"; }
My Family[00047]s Vacation
2 Likes

That’s interesting. :confused:

Sed has some interesting characteristics, I guess.

1 Like

Also… are while loops like this supposed to run once even on no input?

while read thing; do
  #runs once anyway with an empty string
done <<< "$( 
  #do stuff that results in no output
)"

I need to order myself plaque that says “STOP! Just do it in Python.”

1 Like

This is the correct answer.

3 Likes

Never thought “copy files from a hard drive to a tape and upload to Google Drive” would turn into a 370 line shell script…

5 Likes

Just hash every file and use that as the name, save a lookup table somewhere. All problems solved :smiley:

1 Like