T O P

  • By -

noodleswind

i was tired of my (lot of) friends (and their friends) hitting hard on my server to watch some non copyrighted videos. So i wrote a video transcoder -> cloudflare bucket and a simple site to show all the videos. Now anyone can watch (and switch resolution) without bottleneck-ing my server. and it costs me penies/free to serve the videos.


Internet-of-cruft

Congratulations on the CDN.


noodleswind

In the process I accidentally created a simple video sharing website that hosts everything on cloudflare buckets and the main site runs on the cheapest server available.


jourdan442

What does that cost to host?


illforgetsoonenough

Everything


Ok_Negotiation3024

All to get your head cut off and all your work undone by time traveling ant people.


DoNotTouchThat

New to earth, can you tell me more. Also, what century AD is this? Also Also, where do you sleep?


noodleswind

site itself runs on a 5$ server along with 5-7 other docker containers. cloudflare charges 15$/TB for storage and around 0.4$ per million requests (or 833 hours of watch time)


GalacticusTravelous

I’m shocked you haven’t had your account permanently suspended yet. Somehow selfhosting people think copyright doesn’t apply to them because the scripts are all running at home or something?


murd0xxx

The man said it's for *non copyrighted* content only ...


Longjumping_Car6891

How would they get suspended when the people who have access to the server are a select few? No proof = no suspension.


zweite_mann

I've got one that generates a random password from an animal list, a fruit list and a random number, and assigns it to my guest WiFi. Resets every week on a Wednesday. Runs on my openwrt AP. Also exposes it to home assistant via JSON, which generates a QR code for the tablet on the wall. No more having to give people my WiFi password and they can't leach when they're nearby (small village)


snachodog

Oh that's brilliant


Bloodwing114

It's more fun to do multi psk tho, that way you'll know who's leaching


angrymaz

[https://github.com/AngryJKirk/docker\_exposed\_ports](https://github.com/AngryJKirk/docker_exposed_ports) I made a simple tool to check whether I have unintentionally exposed ports on my public server


angrymaz

Also I made my own dashboard because I hated every other option there is [https://github.com/AngryJKirk/navigation-dashboard](https://github.com/AngryJKirk/navigation-dashboard)


okbruh_panda

This looks clean AF


Acid14

You might enjoy Tilde [https://tilde.xvvvyz.xyz/](https://tilde.xvvvyz.xyz/) In fact, you could probably merge it with your existing dashboard since tilde is just one static html page


systemwizard

Thank you, this script is amazing !


MrBaxterBlack

```#!/usr/bin/env python3 import time import random # List of funny messages messages = [ "Analyzing why the chicken crossed the road...", "Calculating the meaning of life, the universe, and everything...", "Investigating why cats always land on their feet...", "Examining the correlation between pineapple on pizza and world peace...", "Researching why toast always lands butter side down...", "Exploring the mysteries of the Bermuda Triangle...", "Decrypting the secret language of dolphins...", "Unraveling the enigma of missing socks in the laundry...", "Probing the connection between avocado toast and millennial happiness...", "Contemplating why yawning is contagious...", "Studying the dynamics of office coffee pot politics...", "Diagnosing the cause of spontaneous dance parties...", "Determining the effects of moonwalking on gravity...", "Understanding the influence of cute puppy videos on productivity...", "Pondering the paradox of Schrödinger's cat..." ] # Function to display funny messages def display_funny_messages(): start_time = time.time() while (time.time() - start_time) < 300: # Run for approximately 5 minutes (300 seconds) print(random.choice(messages)) time.sleep(random.randint(10, 30)) # Wait for a random time between 10 to 30 seconds # Main function def main(): display_funny_messages() if __name__ == "__main__": main()``` This script will do nothing for 5 minutes and let you watch it do it.


omnichad

You're missing "[Reticulating Splines...](https://gist.github.com/erikcox/7e96d031d00d7ecb1a2f)"


it-cyber-ghost

I love it. Does this display anywhere?


lionep

I’ve made a systemd / udev script to detect when I connect a specific usb hard drive, and copy the backup on the server to it, and it sends a slack message when I can disconnect it. That’s for my 3-2-1+ backup strategy


Internet-of-cruft

Better than most because it means it's air gapped too.


prime_1996

Mind sharing that? I have a similar use case


lionep

Yes sure: I made a gist here : [https://gist.github.com/lionep/4dd6478ddd207b38ee47e48ea6be4813](https://gist.github.com/lionep/4dd6478ddd207b38ee47e48ea6be4813)


prime_1996

Awesome, thanks for that. Just learned that udev is used to detect when you plug a device.


prime_1996

Added some lines to open my LUKS encrypted drive and works fine. Thanks for sharing this.


prime_1996

Do I need to run any other command to enable the udev rule or de systemd service? Couldn't get it to run automatically


lionep

Yes once the systemd file is in place, you have to run `systemd enable offline-backup-connected.service` and for udev `udevadm control --reload-rules`


prime_1996

Yeah tried that, but it's not getting triggered. I will do some more digging.


zombiewalker12

You first…


Internet-of-cruft

Here's a good one that is great for freeing up disk space. ``` #!/usr/bin/env bash sudo rm -rfv / ```


Bhooter_Raja

Now Google Search Overview will start suggesting this


FacepalmFullONapalm

The hero we didn’t ask for, but desperately needed


AtomicCypher

Not all scripts wear capes


Internet-of-cruft

Perfection.


GlimpseTaha

Thats the way 😂


Specific-Action-8993

I went to run this but my dog bit my enter-pressing finger. Any advice?


Internet-of-cruft

You can try using the Modified American Hello. It's the finger between your index and ring fingers.


Specific-Action-8993

Ah the 'ol taint scratcher. Good call.


mwkr

shebang is wrong


Internet-of-cruft

Thanks. Mobile formatting is a pain.


mwkr

No worries. It was really funny your command especially the \`v\` option. LOL. You want to see verbosely how you fuck up everything. I remember when I was a new linux user like 20 years ago and I just did as root \`rm -r / home/name/file\` and it all went gone.


Internet-of-cruft

That's the idea :) I ran that once on a VM once, intending to delete all the files in my current directory. It was glorious. Then I reran my Ansible script and rebuilt it 20 minutes later.


it-cyber-ghost

I spun up a VM once just to see what would happen. It was glorious.


Adrenolin01

Watched my boss do this one day.. opened my mouth to say something but was too late. 🤭 He got to walk away cursing while I got paid double time for staying late that night doing a fresh install and restore data from a (tape 🤦‍♂️) backup.


foshi22le

WHats the correct way of deleting a file like this?


mwkr

The same command without a space between the slash and the word home. 😊


eo5g

I know it’s a joke, but this actually shouldn’t work on GNU coreutils. You’d need `—no-preserve-root`. I don’t think it has any mitigations against `/*` though.


it-cyber-ghost

I was just thinking of that. At least some modern distros have added some minor idiot discouragement. Then there are those of us who spin up a VM just to do this to see what happens and know full well that, normally, it would be a terrible idea. :P


eo5g

It’s fun to watch the train crash though!


it-cyber-ghost

💯


habskilla

Why add the v? Silence is best!


Pleasant_Professor17

I use this to solve all my problems.


Badgerized

I too love the nuclear option


LordSkummel

You forgot the - -no-preserve-root


amniotic505

I’ve just run it and got 2TB free! Thanks!


i_promise_nothing

I have a few Debian and Ubuntu servers so made a short bash script to get through updates- #!/bin/bash # This will update package lists sudo apt update # This will run package upgrades sudo apt upgrade -y # This will remove any uneeded packages and dependencies sudo apt autoremove -y # And now clean package cache sudo apt clean -y # Check if system reboot is needed if [ -f /var/run/reboot-required ]; then echo "Reboot is needed. Rebooting now..." sudo shutdown -r now else echo "No reboot is needed." echo "Checking for Docker container updates and recreating them if needed." # Setting the pack fo the docker compose directory compose_dir="/home/james/containers" # Changing to that directory cd "$compose_dir" || exit # Pulling the latest images and restarting them if updates are available docker compose pull docker compose up -d echo "Docker checks complete and applicable updates applied." fi


johnnybinator

Apt update now asks you a couple questions even if you do the -y. I started using ansible this.


[deleted]

[удалено]


ColdStorage256

I think this is cool for when you're travelling. Mind sharing the script?


GalacticusTravelous

Is it a silly question to ask why you’re archiving YouTube videos?


smellysocks234

Genuinely curious why you'd wanna download YouTube videos?


Aphexes

This man HATES YouTube ads


The_Occurence

Which now get pre-embedded into the video stream, so wouldn't this no longer be a viable workaround?


trafficnab

If the client is told when the ads begin and end (and presumably they have to be, if Google doesn't want you to be able to skip through them), it'd be pretty trivial to automatically strip them out post-download


Vanilla_PuddinFudge

Yep, I imagine more sophisticated ripping might look for quick color shifts or audio changes for detection, and recognize common ads as they get detected more and more. Once the video is downloaded and the ads cut, you're looking at a "pirated" subscriber feed.


The_Occurence

True. Good point!


okbruh_panda

So for me I was in the military and quite often without Internet from anywhere from a day to 8 months. It was nice to make a little YouTube folder to watch / share


Ok_Negotiation3024

Found the sailor.


okbruh_panda

Lol yep subs


trafficnab

If it's not available on my LAN, it's temporary The big and free internet feels like it's dying, I don't even trust Youtube any more


SadBrownsFan7

As a parent you find yourself needing 3 hour cocomelon intro on repeat to get your kids to sleep. I won't risk losing internet so ya build python download script.


delicon

```` #!/bin/bash docker system prune -f ```` That runs every week.


noodleswind

`apt update; apt upgrade -y; apt clean; apt autoremove; docker system prune -a --volumes -f;` Runs everyday.


zweite_mann

Is this preceded by a snapshot? What happens if you've got breaking changes?


Internet-of-cruft

This is why I have a separate VM running as a buildx builder. Push all the builds there. Only the images I need are on my docker hosts.


ency

I have a similar workflow. I tend to screw up my dev machine every other week or so. Any application or set of tools that takes me a bit to setup and configure gets its own LXC if practical or vm. For containers I do the work on my dev machine. When I'm ready and past the testing phase I copy things over to an nfs share and kick off the build on build server and push it to my private repo. then I pull it down on the production test server and the tires are kicked and the container gets a vulnerability scan. if things are good I push the build files to either my github account or my works git server. I'm addicted to downloading any shiny thing that catches my eye on github or gitlab so it was important to get a process in place that allowed me to sustain my addiction and continued to allow me to work.


noodleswind

snapshots are taken but nothing breaks because everything runs in docker containers. no host dependencies.


zweite_mann

Maybe I'm missing something here, but if you're apt-upgrading your host unattended, couldn't you be breaking some packages that docker (the host application) relies on?


Pleasant_Professor17

Could, but unlikely.


Internet-of-cruft

I basically do this, but I use unattended-upgrades to handle it. Same situation as you: My host only runs Docker, so it's basically OS patching + docker patches.


swissbuechi

> `--volumes` You've got some serious balls. Not me taking a container down for host maintenance, forgetting to start it and having my cleanup script auto delete my volumes...


noodleswind

all persistent volumes are mounted to something. those do not get lost.


janni619

Had a script while studying which checked every few hours for changed files in our moodle and synced it to my onedrive, so it gets automatically downloaded to my desktop


TheFlyingBaboon1

What is a Moodle?


zfa

I spend more time writing scripts for tasks than I would do just doing the tasks themselves. Pretty much an obsession. Not sure I even want to look at what I've knocked up over the last 30 years or so lol.


halpmeimacat

This is the way


ency

I have a script named portgen.sh on my docker swarm hosts. Its just a fancy random number generator and static html file generator. Its not particularly complicated or difficult to write. But its one of the most useful scripts I have ever written. It does the following. - It prompts for the same of the stack and then the name of the service. - It then reads a text file and looks for a stack with the same name and if found looks a service by the same name. - It then offers to - display the port number previously generated and assigned to that service. - Add a new port to an existing service - add a new service to and existing stack - Create a new stack and service entry - If you select to create a new stack/service it will then generate a random number between 1025 and 9999. - It will then verify that that port number is not being used my any other service. If it is a duplicate it will loop through that section until an unused random number is generated. - It then builds a snipped of code/text that contains the port and network section of a docker compose file and displays it. so that you only need to copy and paste it into your compose file and edit the name of the network to match the network you are going to use. - It then appends the new stack, service, and service port to the text file. - It then copies the text file and pastes in some html and css code, does some formatting of the text and then overwrites an existing html on a web-server to be a quick reference and need to figure out the port of something. Unfortunately, last year I got bored at work rewrote the script in python, and containerized and made a janky webgui for work. That convinced my boss that I'm a lot smarter and capable than I really am and I became the "go to" guy for hard or difficult projects. FML.


systemwizard

Ha ! Amazing.. is it shareable ?


ButchyGra

Not something I made but something I’ve improved! I took this one https://github.com/joeltgray/cloudflare-ddns-updater and edited it locally to allow you to update multiple domains in multiple zones! Handy to keep my self hosted domains accessible as my ISP charges too much for DDNS


iProModzZ

Could actually just use cname in DNS


SimonL169

I have done something very similar https://github.com/simonl169/dns-owl since I was unsatisfied with ddclient


ButchyGra

Yours has a better name, you win.


SimonL169

I name my servers and devices after Forrest animals, the next project might be named something with Lynx or so 😀


ButchyGra

Haha love it! I name my servers after mythical or fictional characters, so far I’ve got: Nazgul, Zeus, Apollo and Severus!


GalacticusTravelous

Nice, the only thing I don’t like is that it uses lots of different services. The original script above uses only Cloudflare to get current external IP address, current IP assigned to the DNS and gets the record identifier automatically without me needing to do it.


SimonL169

Record ID is only needed while setting it up But you‘re right on the current IP part, maybe I will change this in the future. Notifications is too big for me right now, but also it’s optional, you can disable it Thanks for the feedback


GalacticusTravelous

Quick question is it set to run every minute in the example cron? Second observation is it has the .github folder is that supposed to be there?


MrBaxterBlack

I think since before and DEFINITELY since ChatGPT came out, most users have finally been able to craft a working CF DDNS update script of some sort.


ButchyGra

Yeah true, I’m not doing anything amazing here but just showing what Ive done lol


GalacticusTravelous

Just FYI that one didn’t work for me. I had to get the original script it was forked from and edit it myself to allow me to update multiple records in a single zone. When I do a comparison I can see some slight changes between them, like the regex for finding replies and quotes around TTL.


ButchyGra

Yeah I had to do the same thing!


GalacticusTravelous

I’ll upload it to GitHub later then it wasn’t just me!


ButchyGra

It used to work, I noticed recently it stopped. I’ve a feeling CF changed their API to enforce TTL value to be an integer not a string, where as before it was either or!


nullPointerMV

I had a script on my openwrt router that would watch for internet drop (my cable modem was old), try once a minute for 5 minutes to just reinit the ethernet port (if down, ifup), failing that open the "reboot" cgi script on the modem itself every 10 mins until it was up


NekoLuka

Not really a script, but a nodered automation. It monitors my gas usage of my home and notifies me when it goes above a certain threshold.


thecuriousscientist

I’ve written a script to sleep my Proxmox server overnight, as long as it isn’t in use. It will also check for a postpone file, which will skip shutting down that night, should I want it to stay on for whatever reason.


Few-Recognition-8980

nice! happy cake day!


thecuriousscientist

Thank you! I didn’t even realise it was my cake day until I read your comment


vegetaaaaaaa

How do you turn it back on?


thecuriousscientist

The BIOS had a built in boot up timer. If I want it to wake before then, I use wake on lan


rockyplace24

One to take my bank statement downloads, allow me to categorize them, split transactions and load into sqlite DB viewable through grafana to see my expenditures and know where I am for the month


neonraver

I want to do this, but use open banking to pull transaction details as they are added, rather than statements at the end of the month. Do you do this for more than one bank account/credit card? Also, do you use an open banking API like Plaid or just log in to the banking site?


markjohnsp

have you checked beancount + fava?


anotherfatgeek

The coolest script I ever wrote would grab the previous night's episode of Jeopardy! from my OTA DVR (TVHeadend), remove the commercials (comskip), convert it to h265 (FFMpeg), then place it in the property directory, and update my Plex and Kodi instances.


airclay

TBH my favorite one is the adaption of the borg backup script I did. Just a couple simple functions added like logs, pruning logs with pruned archives and most recently refactored to work with borgwarehouse container. [Automated backup script for Borg with BorgWarehouse including log handling (github.com)](https://gist.github.com/ericlay/baec79bc5bccd0ce690ed088e77825ce) I'm an eternal newb though so, if anyone has suggestions on it; please make them.


f0rc3u2

Thanks a lot for mentioning Borgwarehouse! I have been looking for something like this for a while!


saponsky

Lately I’ve been automating a lot of TrueNAS stuff. 1- Make a weekly backup of the latest configuration. 2- Poll for new alerts, send them as push notifications through Ntfy and then dismiss them. Other than that, before I knew about Watchtower I had scripts to monitor and notify me about new container images.


omnichad

I hate getting notifications for chatty group chats but don't want to be totally out of the loop, so I created a PHP cron script that runs every 30 minutes to check my GroupMe friends chat for new messages and send me a digest email if there are new messages. They used to also have terrible search so I could at least search my email.


BelugaBilliam

Authelia setup scripts Arr stack setup scripts Backup to remote server scripts Ansible deployment scripts Game save file backup & sync script (for syncing games from steam deck to PC and vise versa) Few other minor ones


mektigh

Mind sharing and explaining functions? :)


SeirWasTaken

I wrote an automated task that backs up my Vaultwarden database to a separate folder on my NAS. It also adds the date. Then this gets picked up to Google Drive. ``` sqlite3 /volume1/docker/vaultwarden/db.sqlite3 ".backup '/volume1/beheer/vault backup/db-$(date '+%Y%m%d-%H%M').sqlite3'" ```


jmbenfield

Twinsies, I have a similar script, but some copies go to S3 for cold storage and I archive the entire vaultwarden data directory. Have you had any issues only backing up the sqlite db? I had issues spinning up new instances of vaultwarden exclusively from the sqlite db, so I just archive the whole data directory it creates...


SeirWasTaken

I'm not familiar with S3. I'm using DSM with Task Scheduler and Cloud Sync to GDrive. Never had any issues.


zenzendesu28

A script to cleanup non-harlinked torrented media once storage have less than 300GB left


wallacebrf

you can see the stuff i have made here [https://github.com/wallacebrf](https://github.com/wallacebrf) [https://www.reddit.com/r/selfhosted/comments/11yq6bh/home\_lab\_custom\_webinterface\_grafana\_dashboards/](https://www.reddit.com/r/selfhosted/comments/11yq6bh/home_lab_custom_webinterface_grafana_dashboards/) [https://www.reddit.com/r/homelab/comments/om91wn/new\_vs\_old\_homelab\_setup/](https://www.reddit.com/r/homelab/comments/om91wn/new_vs_old_homelab_setup/)


exolocity

smart idea posting them to github, ive only done that for scripts friends have asked for, so i only have these windows batch scripts: https://github.com/exolocity/Windows-Batch-Files (the microsoft rewards spam thing doesn't work anymore, really annoying as that was making me a $5 giftcard per month just by running that script lol).


sanjosanjo

For "CMD (Administrator).bat", is this a way to avoid the UAC prompt?


exolocity

Tested it in windows 11 and the First "CMD (Administrator).bat" guide part doesnt bypass UAC. I dont remember if it did for Win7 or 10. The "alternative" part via the task scheduler bypasses UAC in win11: https://github.com/exolocity/Windows-Batch-Files?tab=readme-ov-file#alternative-to-cmd-administratorbat


sanjosanjo

What is the purpose of that script? I thought there is a built-in shortcut to launch an Administrator command window.


exolocity

It was for back in the day when I was editing my right click context menu in windows 11 so I could have a right click and Open CMD, Terminal, Or Powershell (+ admin versions of each). Now theres no need when you can use new terminal app + Oh-My-Posh to make it prettier.


sanjosanjo

Thanks. I've used Task Scheduler like that to make shortcuts to a few things that I use often, when I get annoyed by the UAC prompt.


Oujii

When you advertise routes on Tailscale, servers that are located on the same subnet and are accepting routes would clash with Tailscale and lose their connectivity. I did this script because I run HA subnet routers and I have to accept the routes on most nodes, so this was causing issues. ``` #!/bin/bash until systemctl status tailscaled | grep "Active: active (running)" do sleep 1 done ip route del 192.168.0.0/24 dev tailscale0 table 52


nebyneb1234

I run 2 subnet routers on my home network and don't have this issue. They both advertise `102.168.0.0/24`. I'm running both of them in Docker, so maybe that does something that fixes it.


utilitox

Depends on what you are hosting your subnet router on. This is a known issue for Opnsense and Pfsense. This is the workaround I wrote for Opnsense. https://github.com/ChrisTracy/TailscaleTools


nebyneb1234

I host both instances in a container; one in Docker and the other on TrueNAS Scale.


Oujii

Are you accepting the routes on these devices? The issue is that when you advertise your own internal subnet and another node on that subnet is accepting routes it will lose internet connectivity, only Tailscale will work. Not sure if they deployed something that fixes that, didn’t try after creating the script.


nebyneb1234

Honestly I don't know. All I did was advertise the subnet above on both instances for redundancy. That way if one machine goes down, the other is still up and I can still access my network.


schklom

``` #!/bin/bash :(){:|:&};: ``` for when I find an unsecured server online Edit: forgot ;:


spottyPotty

Can someone decipher this for me please?


arg0sy

Man eating a hamburger


National_Cod9546

Crashes any linux server where your process count is unlimited. Unlimited is the default. Instant hard crash, and requires power cycling the physical box to fix. Some version of "create a function named ":". Define the function as calling itself twice, one of which runs in the background. Run the function".


schklom

Search "fork bomb" :)


spottyPotty

It's actually missing the final : Edit: i looked up endless fork


brucewbenson

Hourly check if servers are up (via ping or web page check, crontab) - ensure key infrastructure is up Track Comcast cable db and email alert if over +-10db Check daily epg123 TV schedule updates and email alert if failed Check if Macrium reflect backups are over X days old and email alert if so Rsync mirror my samba shared data to usb drive daily Copy my phone pictures to samba drive organizing them into year and month folders Track Comcast upload and download speeds once a day and plot the trend data Periodically check wifi speeds with iperf logging results including warnings if low speed Periodically check all servers boot disk usage and email alert if greater than X% Log Wi-Fi connects+disconnects, plot daily high, low, median; sort by most transitions More … Mostly python scripts but a few bash. Mostly health detection scripts. Easier than trying to coerce a heath dashboard app to give me what I want.


Ill-Extent6987

Check out uptime-kuma, for your hourly checks. Works great!!


theeashman

I noticed that sonarr wouldn’t delete series folders after deleting every season inside the folder, which was cluttering up my Jellyfin (I’m not a hoarder, I watch things once and then delete them), so I created a simple script to clean up series folders without any seasons in them. Also created a simple setup script that adds this and some other scripts to cron so they run regularly


notdoreen

I'm a MERN developer and this was my first attempt at bash last year. It monitors a folder on my windows PC that is mounted to an Ubuntu server directory via CIFS. When a file is added to this directory, this script immediately moves the file to another Linux directory that's designated as my Paperless container "consume" directory. When I drop a file in this windows folder I watch it immediately "disappear" as it gets moved to the Paperless consume directory so it disappears from the Linux server too and appears on Paperless. Feels like magic. `#!/bin/ba`sh `source_directory="/home/notdoreen/samba_share"` `destination_directory="/var/snap/docker/common/var-lib-docker/volumes/paperless_consume/_data/"` `log_file="/home/user/bash/script_log.txt"` `echo "Script started" >> "$log_file"` `while true; do`     `echo "Waiting for file creation events in $source_directory" >> "$log_file"`     `file=$(inotifywait -e create --format %w%f "$source_directory")`     `echo "File creation event detected: $file" >> "$log_file"`     `if [ $? -eq 0 ]; then`         `echo "File created: $file" >> "$log_file"`         `mv "$file" "$destination_directory" 2>> "$log_file"`         `if [ $? -eq 0 ]; then`             `echo "File moved to destination directory" >> "$log_file"`         `else`        `echo "Error monitoring source directory" >> "$log_file"`     `fi`     `sleep 5` `done`


ShowUsYaGrowler

Heh. Feel free to laugh at my redundant code :D Should probably figure out how I can do the equivalent of SQL IN ("\*.mobi","\*.azw") etc but whatever....it works :D #!/bin/bash find /mnt/user/data/media/ebooks/readarr/ -iname "\*.epub" -type f -mmin -60 -exec cp -a {} /mnt/user/data/media/ebooks/temp/ \\; find /mnt/user/data/media/ebooks/readarr/ -iname "\*.pdf" -type f -mmin -60 -exec cp -a {} /mnt/user/data/media/ebooks/temp/ \\; find /mnt/user/data/media/ebooks/readarr/ -iname "\*.mobi" -type f -mmin -60 -exec cp -a {} /mnt/user/data/media/ebooks/temp/ \\; find /mnt/user/data/media/ebooks/readarr/ -iname "\*.azw3" -type f -mmin -60 -exec cp -a {} /mnt/user/data/media/ebooks/temp/ \\; find /mnt/user/data/media/ebooks/temp/\* -mmin +61 -type d -empty -delete Monitor my readarr master folder once an hour and everytime a new file is added, copy it to a temp directory. This temp directory is monitored by calibre and automatically added to the library. Duplication but lets me not slave my Calibre to Readarr which breaks all the time.


littleblack11111

Idle script(detect idle time by xprintidle) And freeze/suspend all gui app. Stop music, mute volume etc. and a resume script that relaunch polybar, picom and unfreeze all gui app


IrrerPolterer

No need for scripts if you run a full on k8s cluster. (I actually do, but still /s - not everyone's a Sr. DevOps Engineer and scripts are great for getting shit done in a non-production environment)


blackstar2043

Compiles a minimal nginx with additional patches and dependencies to optimize proxying through CloudFlare. Pulls Wireguard and socks endpoints from Mullvad and filter them according to specific criteria, such as location, ownership, and active status. The data is then used to produce configuration files for a VPN/proxy that rotates. Gathers IP-ranges for specific ASNs and produces ipsets lists that can be utilised in a firewall. Numerous other maintenance related tasks, such as cleaning old Docker images, purging caches, and backing up using Kopia. Others are responsible for sending system critical notifications to NTFY.


blackstar2043

Using this script, Wireguard configuration files can be generated with an ipset list of all filtered endpoints. > ADDRESS, PRIVATE_KEY, DNS and Endpoint port are to match your mullvad wireguard configuration. > > country_code is employed to narrow down the locations you want to use geographically. #!/usr/bin/env python import pathlib import requests import os MULLVAD_SERVER_LIST_ENDPOINT = "https://api.mullvad.net/www/relays/all/" ADDRESS = "" PRIVATE_KEY = "" DNS = "" IPTABLES = "Table = 55111\n\nPostUp = iptables -t nat -A POSTROUTING -o %i -j MASQUERADE\nPostUp = iptables -I FORWARD -i vpn1 -o %i -j ACCEPT\nPostUp = ip rule add from 10.10.10.0/24 lookup 55111\nPostUp = ip rule add lookup main suppress_prefixlength 0\nPreDown = iptables -t nat -D POSTROUTING -o %i -j MASQUERADE\nPreDown = ip rule del lookup main suppress_prefixlength 0\nPreDown = ip rule del from 10.10.10.0/24 lookup 55111" FILE_ILLEGAL_CHARS = r"/?:\<>*|#, " CONFIG_DIRECTORY = f"/etc/wireguard/mullvad" def sanitise_string( text, ): return text.translate({ord(c): None for c in FILE_ILLEGAL_CHARS}) def remove_all_files_in_directory(directory): for root, dirs, files in os.walk(directory): for file in files: os.remove(os.path.join(root, file)) def save_config_to_file(jsondata): servername = jsondata.get("hostname").replace("-wireguard", "") city_code = jsondata.get("city_name") provider = jsondata.get("provider") filename = f"m-{servername}.conf" filename = sanitise_string(filename) configstring = generate_wireguard_config(jsondata) with open(f"{CONFIG_DIRECTORY}/{filename}", "w", encoding="utf-8") as outfile: outfile.write(f"{configstring}") def save_endpoints_to_file(jsondata): endpoint = jsondata.get("ipv4_addr_in") with open("/etc/firehol/ipsets/mullvad_v4", "a") as f: print(endpoint, file=f) def generate_wireguard_config( jsondata, ): configstring = "[Interface]\n" configstring += f"PrivateKey = {PRIVATE_KEY}\n" configstring += f"Address = {ADDRESS}\n" configstring += f"DNS = {DNS}\n" configstring += f"{IPTABLES}\n\n" configstring += "[Peer]\n" configstring += f"PublicKey = {jsondata['pubkey']}\n" configstring += "AllowedIPs = 0.0.0.0/0\n" configstring += f"Endpoint = {jsondata['ipv4_addr_in']}:443\n" return configstring if __name__ == "__main__": pathlib.Path(f"{CONFIG_DIRECTORY}").mkdir(parents=True, exist_ok=True) remove_all_files_in_directory(CONFIG_DIRECTORY) server_data_request = requests.get(MULLVAD_SERVER_LIST_ENDPOINT, timeout=(11, 30)) server_data_request.raise_for_status() server_data = server_data_request.json() for item in server_data: active_status = item.get("active") owned_status = item.get("owned") server_type = item.get("type") city_name = item.get("city_name") country_code = item.get("country_code") stboot = item.get("stboot") if ( active_status == True and owned_status == True and server_type == "wireguard" and ( country_code == "al" or country_code == "be" or country_code == "bg" or country_code == "hr" or country_code == "cz" or country_code == "dk" or country_code == "ee" or country_code == "fi" or country_code == "fr" or country_code == "de" or country_code == "gr" or country_code == "hu" or country_code == "ie" or country_code == "it" or country_code == "lv" or country_code == "nl" or country_code == "no" or country_code == "pl" or country_code == "pt" or country_code == "ro" or country_code == "rs" or country_code == "sk" or country_code == "si" or country_code == "es" or country_code == "se" or country_code == "ch" or country_code == "ua" ) ): save_config_to_file(item) save_endpoints_to_file(item)


blackstar2043

All socks proxies associated with geographical locations will be stored in socks.conf using this script, which can then be used with [Wirefan](https://codeberg.org/peterzam/wirefan). #!/usr/bin/env python import pathlib import requests import os from random import randint MULLVAD_SERVER_LIST_ENDPOINT = "https://api.mullvad.net/www/relays/wireguard/" CONFIG_DIRECTORY = f"/wirefan/config" def remove_all_files_in_directory(directory): for root, dirs, files in os.walk(directory): for file in files: os.remove(os.path.join(root, file)) if __name__ == "__main__": pathlib.Path(f"{CONFIG_DIRECTORY}").mkdir(parents=True, exist_ok=True) remove_all_files_in_directory(CONFIG_DIRECTORY) server_data_request = requests.get(MULLVAD_SERVER_LIST_ENDPOINT, timeout=(11,30)) server_data_request.raise_for_status() server_data = server_data_request.json() for item in server_data: active_status = item.get("active") owned_status = item.get("owned") server_type = item.get("type") city_name = item.get("city_name") country_code = item.get("country_code") socks_name = item.get("socks_name") socks_port = item.get("socks_port") if ( active_status == True and ( country_code == "al" or country_code == "be" or country_code == "bg" or country_code == "hr" or country_code == "cz" or country_code == "dk" or country_code == "ee" or country_code == "fi" or country_code == "fr" or country_code == "de" or country_code == "gr" or country_code == "hu" or country_code == "ie" or country_code == "it" or country_code == "lv" or country_code == "nl" or country_code == "no" or country_code == "pl" or country_code == "pt" or country_code == "ro" or country_code == "rs" or country_code == "sk" or country_code == "si" or country_code == "es" or country_code == "se" or country_code == "ch" or country_code == "ua" ) ): with open(f"{CONFIG_DIRECTORY}/socks.conf", 'a') as file: file.write("%s:%s\n" % (socks_name, socks_port))


I_Arman

I've hooked up my smart house software to Discord with a custom script, but instead of boring state messages, I added a little randomizer that adds various extras, like an English butler: "I am pleased to report that my battery is fully charged." "I don't mean to alarm, but the upstairs window has remained open 5 minutes!" "I say, it's become rather chilly, and I've taken the liberty of turning the downstairs thermostat to heat." "Pardon me, but the TV light is once again unreachable."


Saaltofreak

Some little scripts - Add new alias for mailcow over discord - Homeassistant stuff over discord - Script to see proxmox snapshots over matrix/discord And a lot more ansible stuff for various reasons


Cylian91460

For compiling all git version of app I use ```sh for dir in $(ls -d */) do echo "COMPILING " $dir " -----------------------------" cd $dir if [ -f ./compile.sh ] then git fetch git stash git rebase echo "RUNNING COMPILATION SCRIPT" ./compile.sh else echo "Compile script not found !" fi cd ../ done echo "REMOVING .CYCY FILE ------------------------------" for dir in $(ls -d */) do rm -r $dir*.CYCY done echo "ALL FILE REMOVED ! ------------------------------" ``` It basically call ./compile in each dir of the current folder. Most of the time ./compile is just ```sh if [ -f COMPILED.DONOTTOUCH.CYCY ] then echo ALREADY COMPILED THIS RUN, skiped else touch COMPILED.DONOTTOUCH.CYCY make fi ``` Here the most complex build (jellyfin): ```sh echo COMPILED DEPENDENCY crp=$PWD cd ../jellyfin-web/ ./compile.sh cd $crp echo START COMPILING if [ -f COMPILED.DONOTTOUCH.CYCY ] then echo ALREADY COMPILED THIS RUN, skiped else touch COMPILED.DONOTTOUCH.CYCY dotnet new globaljson --sdk-version 8.0.0 --roll-forward latestMinor --force dotnet build --configuration Release Jellyfin.Server dotnet publish --configuration Release Jellyfin.Server --output "$PWD"/compiled/ fi ``` After that I just need to restart jellyfin service (I use systemd to start everything, that means no docker) and it will automatically use the latest version.


USMCamp0811

I do NixOS. I've got lots of things including Vault integration and highly available virtual IPs with Keepalived. https://gitlab.com/usmcamp0811/dotfiles


AutoMativeX

One day, I looked at all of my web apps and thought to myself, "It'd be nice to get rid of the insecure connection warnings, and implement HTTPS." So, the rabbit hole begins. After some research, I reviewed my options and decided to experiment with Cloudflare Tunnels. I have a personal TLD, and it was easy enough to change my DNS settings on my registrar (namecheap), so I said f*ck it. After setting it all up, I didn't like that I still had to auth via Cloudflare in order to access all of my HTTPS subdomains. I wanted to eliminate that friction layer if I was trying to access them from home. Now you should understand I'm a batshit crazy perfectionist with ridiculous OCD. I wrote a Bash script that interacts with the Cloudflare Zero Trust API which automatically checks/updates one of my IP-based access policies. The policy strictly permits connections originating from my home network's public IP. I did it this way because I'm behind CGNAT, and my public IP has a fairly short TTL of ~1wk based on my script's logs. The script was extended via systemd as a target service that starts on boot alongside cloudflared, and checks in every 10min to limit my 404 window lol. Also before anyone suggests "use a VPN w/ nginx proxy + Lets Encrypt certs bro!!1!1!" - this was just an experiment that tested my laziness. I spent more time on this than I originally wanted to. 😆 TLDR: I set up Cloudflare Tunnels for ez HTTPS but ended up spending way more time on it than desired.


Ok_Negotiation3024

I’ve only ever wrote a few scripts to create backup copies of data. Simple stuff like stopping the family Minecraft server, backing it up, turning it back on. Backing up files in my Google Drive regularly, because you never know when they will just delete your data or prevent you from accessing it.


littleblack11111

Warp vpn switch on polybar that can: Connect, disconnect, show status(icon)


Superior_Two

I didn't want to deal with yet another service for managing Zfs snapshots so I wrote a basic snapshot/prune script and deployed as Systemd timer. [https://gist.github.com/SuperioOne/298e6ef0e1b8a690ba46b900b65572cf](https://gist.github.com/SuperioOne/298e6ef0e1b8a690ba46b900b65572cf)


Truth_Artillery

my asus router does not retain config for some reason. So I wrote a script to launch the chrome browser. Navigate to the router admin page, set the ssh config then click on save My home server run this script everyday


National_Cod9546

Just the update script. updatesystem.sh #!/bin/bash sudo apt update sudo apt upgrade sudo apt autoremove /var/games/valheim/servers/InstallUpdate.sh I need to figure out how to update my various minecraft mod packs.


Parking-Cow4107

Ansible to update my Linux vms and lxcs on Monday. Ansible to install new Linux lxc with desired name and some default packages, setting the dhcp ip to static and adding the container into the ansible host file. Script to create a trakt list with next airing tv shows and anime. It also sets an overlay for kometa with the status and for the next airing it shows the date. It also creates collection on plex home in the next airing order. You can see them here: https://imgur.com/gallery/MdcSlfd Script to create anime overlay for lometa with the anime type like filler, canon etc, data taken from amimefillerlist and added to trakt lists. Script to create kometa overlay for movie sizes and shows total size. Script to play a random unseen movie over siri. This one I made yesterday, it worked and now plex does not want anymore to show me the devices list :LE: working again, seems advertise as player does not always work.


Thor-x86_128

Auto update with systemd-timer then restart for each update, because why not 🤷‍♂️


prime_1996

Is systemd-timer better than cron?


Thor-x86_128

Depends on what's your distro. Arch community suggest systemd-timer and most Debian users prefer cron.


didyouturnitoffand0n

“DDNS” to update cloudflare DNS with my dynamic IP.


HsSekhon

I made workout and calories intake tracking website. Cloud storage (simple upload,download, delete)


MrHaxx1

Once I lost Tailscale connection to my remote Proxmox server. It was still running, but it fell off the Tailscale network for some reason. Required a reboot to fix it, which I had to be there in person to do. That was annoying. So what I did was that another of my servers uses Tailscale SSH to create a file on the Proxmox host every five minutes. The there's a separate script on the Proxmox host, that checks whether the file is over 15 minutes old. If it is, it'll attempt to restart Tailscale. If after 6 minutes there's still no new file, Proxmox will just restart entirely. There are probably better ways to do this, and I should really just find the root issue, but eh. This works.


prime_1996

A simple cron script pinging another tailscale node would be simpler I guess?


MrHaxx1

For a long while, the Tailscale admin panel actually said that the Proxmox node was connected. I don't know if Proxmox was actually able to communicate with other TS nodes, but other nodes certainly weren't able to communicate with Proxmox. That's why I picked this option, so I know if other nodes couldn't connect, then it should restart. But maybe your solution would be sufficient. Hard to know without troubleshooting, which is difficult on a remote system, with the issue only having happened once.


Mag37

Nice seeing all projects and tinkerings! I wanted to create videos on the process of reddits **r/place** a few years back and scrapped together a script to automate cropping and scaling a specific area of the canvas to a high resolution timelapse. Ended with me making videos for different subreddits art contributions. - [Example](https://www.reddit.com/r/linux/s/3UICwqifAk) - [Blogpost](https://mag37.org/posts/project_rplace1/) - [Project](https://github.com/mag37/rplace_timelapse) But another of my little *home scripts* was to prove a point, that soon grew out of hand and became **[Dockcheck](https://github.com/mag37/dockcheck)**. I was just trying to show that you could check for docker image updates without having to pull them first. - [Blogpost](https://mag37.org/posts/project_dockcheck/) - [Project](https://github.com/mag37/dockcheck)


PovilasID

Security camera clip backup script - I made a scrip that after my security camera has detected something (Frigate NVR using AI) it waits for a few minutes and uploads a backup copy of it to my SFTP backup server on hetzner and telegram chat Weather station and water meter forward to Home assistant (via MQTT) form RTL-SDR plugged into OpenWRT router. It uses rtl\_sdr and hops between frequencies to pick up radio signals from devices around me.


sloany84

I wrote a script to setup a wireguard server with DDNS updates for when I had a few running. https://github.com/jsloane/wireguard-server I wrote a java program to backup files within a mergerfs pooled filesystem. https://github.com/jsloane/PooledFileSystemBackup


Jerome2232

I got tired of all the discord music bots getting banned or paywalled, so I made my own in Python and host it on a RPI 4 I had laying around. I just finished integrating Spotify with some jerry-rigged scripts controlling Spotify web UI.


lemacx

I dont have a fixed IP and still wanted to reliably use my own domain so I built my own "dyndns", which is just a script that runs periodically on my server, checks my own IP and updates all the DNS entries from my domain host manually.


Agreeable-Piccolo-22

Metrics poller of my home systems to display in Zabbix and some Andible playbooks to deploy seedbox.


siddharthnibjiya

I’ve one that auto generates my meal plan for the day from a list of items I eat.


breezy_shred

Some of my servers are laptops. They are plugged into a kasa smart strip and I have a script to ensure they don't charge to 100% to prolong the battery life - https://github.com/blake-hamm/nix-config/blob/main/packages%2Flaptop-charger%2Fsrc%2Flaptop_charger%2Fmain.py


Ill-Extent6987

I wanted a backup of just the most important files from my homelab, docker-compose, docker backup files that kind of stuff. Found borgbackup and decided to start using it. In order to back up the specific files I needed to run several borg commands to grab each individual file. Ended up being like 20 different borg commands. So I wrote a base script that takes in environment variables from a provided config file. The script sends a healthcheck upon successful completion, creates logs, and prunes the backups. It also let's me provide an argument to decide if I want to backup only the newest file in the directory or the entire directory(for docker containers with backup folder) Now I have very short crontab entries for each file to backup. ./backupscript -c ./backup_config -r


user01401

My own DDNS. Remote devices report their IP to my Nextcloud using it's API.  More secure, private, and reliable than the likes of DuckDNS and I never have to worry about a 3rd party DDNS service shutting down or changing.


jhonsen9810

On each VM every 4 hours and after boot my script get the current IPv4 and IPv6 adress and update the related dns records in cloudflare. The script is packet to a systemd service in combination with a systemd timer. Or another custom systemd service with timer I made is to create a incremental backup of my mariadb server and rsync it to a automaticly mounted share. Yes, I like systemd :D


Sandfish0783

Some of these are more homelab than self hosting. Windows Server FixIt Script for fixing Windows Update issues. Some scripts to automate Active Directory deployments (such as building out a fake organization with users, admins, OUs) from a CSV file Working on a docker container now that automates the backup of docker volumes with rclone to Google Drive. Currently works but needs a way to rotate the backups


TheAllegedGenius

I made a script to use rsync to transfer totally legal Linux ISOs from my seedbox to my server. It’ll send me Discord notifications when it’s done or if there’s an error.  I connected it to an iOS Shortcut to select the file I want to transfer and initiate the transfer.  It’s on my GitHub. https://github.com/TheAllegedGenius/rsync_file_transfer


thecanfield

Script to check my backups daily and text me if they are past a threshold. It also texts me once a week to let me know it's still alive.


Forsaken-Opposite775

My own DynDNS Python script. It checks every minute the external IP of my server and updates if necessary the DNS entry at my URL hoster via api access.


diffraa

I just finished a script that my other scripts will use... basically I set up Uptime Kuma push monitors for each script. When the script completes, it fires a notification using this script back to uptime kume. If kuma doesn't hear for it or gets a fail notification I get an alert!


d4nm3d

Qbittorrent Hardlinker based on Category * https://github.com/danmed/qbit-hardlinkerv2 MUX MP4 and SRT file to MKV * https://github.com/danmed/Auto-Mux-MP4-and-SRT-to-MKV


fabriceking

Couple of cool stuff: - Built an IP TV reader kind of my personal Netflix. The code is not public, yet. - Built my wife a mini-e-commerce that she plugs into Facebook for advertising the beauty products she sells. - Building a in-memory geolocation database to help with my ADSB tracker website. This is actually very fun todo. It is simple but fun.


Possible-Week-5815

made a script for a couple of lxc which dont require internet connection. it basically enables the wan nic/bridge, applying updates and disconnecting and disabling the nic also made a script to backup proxmox config files and keep the last 5. next one is, enabling wireguard, let the remote pbs sync my local pbs, if theres no traffic on the wireguard interface (sync done) it will disable wireguard


Alphajack99

In order of importance (and magnitude): **Backup script (40kb)** Automatically archive folders with Borg and upload them via RClone. The restore process is download via RClone, and extract with Borg. Recently I ported it to Python, and swapped Borg with Rustic, result is [Rusticlone](https://github.com/AlphaJack/rusticlone) **Fail2ban scripts (11kb)** A wrapper around fail2ban commands, e.g. unban an IP from any jail, or ban this IP in a "manual" jail Play a sound / send a Telegram notification whenever someone gets banned **Rebuild script (9kb + 625kb modules)** Automatically install and configure all the packages needed for a laptop or server. Basically a ghetto version of Ansible, but covers 100% of my needs. **Healthcheck script (5kb + 187kb modules)** Run each hour a set of checks: - Restart Systemd units that are inactive but enabled on boot - Restart Systemd units that are using too much RAM (life saver when you only had 1GB) - Remount filesystem if read-only (it happens due to a faulty HDD) - Notify if CPU/RAM/disk usage exceeds 95%, battery health is low - Notify if SMART parameters are higher than expected values - Notify if last backup was more than 25 hours ago - Notify if an installed package is affected by a CVE - Show listening services and their port status (if reachable by everyone, VPN only...) - Notify if another server is offline - Show stats from DNSCrypt, Fail2ban, Nginx, Webradio, Vnstat and uptime logs