Skip to content

Instantly share code, notes, and snippets.

View oSquat's full-sized avatar

Vic Simeone oSquat

  • Philadelphia, PA, USA
View GitHub Profile
@oSquat
oSquat / cleanup.sh
Created March 27, 2024 21:59
Bash script to keep the <n> newest files and delete the rest from a given directory. This has come in handy in odd systems without any inbuilt means of maintaining on-system backups.
#!/bin/bash
#
# Keep the <n> newest files, deleting the rest.
#
BACKUP_FILES_DIRECTORY="/srv/backup/wherever"
BACKUPS_TO_KEEP=2
# Delete all but the last N backups
COUNT=0
@oSquat
oSquat / randofile.sh
Created March 27, 2024 21:46
Bash script to return a random file from a given directory
#!/bin/bash
#
# Return a random file from a directory.
#
# Usage:
# randofile.sh /path/to/files/
path=$1
file_count=$(ls $path | wc -l)
rand=$((1 + $RANDOM % $file_count))
@oSquat
oSquat / 0_minecraft_server.md
Last active October 31, 2022 11:45
How to run a Minecraft server on Linux using tmux

Minecraft Server Recipe

Some rough notes on running a headless Minecraft server on Debian using tmux. This was written largely as a place to point those considering Flask Craft for info on the basic setup required/

Minecraft

Download the Minecraft server and get it setup where it suits you. For this gist we'll use /srv/minecraft. I'm writing this weeks after I did this myself, so I'm foggy on the details + other articles will offer greater detail if you need more info on how the actual server runs. I create a user (mc) and chown the whole directory for that unprivileged user to run the server.

# useradd mc
# chown -R mc:mc /srv/minecraft