this post was submitted on 02 Mar 2025
121 points (96.9% liked)

Selfhosted

43130 readers
1292 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS
 

Almost forgot before going to bed but I feel bi-weekly is a good rhythm for this.

Let us know what you set up lately, what kind of problems you currently think about or are running into, what new device you added to your homelab or what interesting service or article you found.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 4 points 17 hours ago* (last edited 17 hours ago)

Bash is a really great shell, but consider trying out a functional shell scripting language like Elvish (which is also a shell). Syntatically it's pretty similar and not hard to pickup, but it's stupid powerful. A cool example is updating different servers via ssh in parallel using a servers.json file;

[
  {"name": "server.com", "user": "root", "identity": "~/.ssh/private_key0", "cmd": "apt update; apt upgrade -y"},
  {"name": "serverb.com", "user": "root", "identity": "~/.ssh/private_key1", "cmd": "pacman -Syu"},
  {"name": "serverc.com", "user": "root", "identity": "~/.ssh/private_key2", "cmd": "apk update; apk upgrade"}
]

and a little elvish magic;

var hosts = (from-json < servers.json)
peach {|h|
  ssh $h[user]@$h[name] -i $h[identity] $h[cmd] > ssh-$h[name].log
} $hosts

Just run the script and boom, done. You can even swap out peach which is parallel each for each if you want to do each command procedurally--but I really love using peach, especially with file operations over many different files. Linux is fast, but peach is fuckin' crazy fast. Especially for deleting files (fd -e conf -t file | peach {|x| rm $x }, or one thing that I do is extract internal subs (so they play on my chromecast) in my Jellyfin server, using elvish makes it really fast;

fd -e mkv | peach {|x| ffmpeg -i $x -map 0:s:0 $x.srt }

Find all *.mkv files, pass the filenames through ffmpeg (using peach) and extract the first subtitle as filename.mkv.srt. Takes only about a few seconds to do thousands and thousands of video files. I highly recommend it for home-labbers.


Pretty dumb example, but peach is like 6x faster;

❯ time { range 0 1000 | each {|x| touch $x.txt }}
5.2591751s
❯ time { range 0 1000 | peach {|x| touch $x.txt }}
776.2411ms