Skip to content

Instantly share code, notes, and snippets.

@stuudmuffin
stuudmuffin / aws_key_cycle.sh
Last active September 13, 2023 20:21
If you work in multiple AWS environments, and you want to be sure your keys are rotated every now and then, here is a script that will cycle through your configured accounts, remove extra un-used keys, generate new keys, configure your ~/.aws/credentials with the new keys, and delete the old keys from that particular AWS account.
#!/bin/bash
# Script to rotate your aws keys, and update them in ~/.aws/credentials
# Requirements: awscli, jq
# Will attempt all profiles by default
# You can specify a profile with the -p flag.
# Profiles and their access key/secret can be commented out with # and the script will skip them
AWS_PROFILES=()
@stuudmuffin
stuudmuffin / mc_dynmap_nginx_proxy.conf
Last active March 14, 2018 23:41
Minecraft dynmap nginx proxy error pages. We port our dynmap plugin through a proxy so we can secure it with https, and enable it as a folder extension instead of a random port or a root folder.
# /etc/nginx/sites-enabled/ssl.conf or default.conf. Change and add your configuration accordingly
#
# With this nginx configuration, we can default to showing an error page if the proxy fails. Our setup is
# a little unique, in that our domain name (mc.ourdomain.com) forwards anything 404 related to a our main
# site for server information (www.ourdomain.com/servers/minecraft) the only reason to use the mc subdoamin
# is to join the server, and view the map (mc.ourdomain.com/map). This config might be simplified if we
# were redirecting all other traffic (ie, the location = for specific image files may not be needed)
#
server {
@stuudmuffin
stuudmuffin / mikrotik_firewall_accesslist.php
Last active September 6, 2023 14:36
PHP api applicator to simply add ip's to an ip firewall access-list. Now with javascript countdown timer!
<?php
/*
When you add an ssh key to a mikrotik user, ssh still gives a password prompt.
A valid key will make password login fail on ssh, but hackers don't know that.
They'll keep trying to pry in, forever fruitless. This is really just annoying
on the logs. So I created a firewall rule to drop traffic on port 22 unless the
source ip exists inside of a defined "ssh_whitelist". To add myself to this list,
I have a webserver on the network I can get to through https login, and simply
add my IP with this script. I have custom formatting on my own page, of course.
I've left formatting to the minimum here. You have the power to make it as pretty
@stuudmuffin
stuudmuffin / minecraft_dynmap_db_size.sh
Last active January 23, 2018 17:04
Script to easily show how much storage your minecraft dynamp is using
#!/bin/bash
host="127.0.0.1"
db="dynmap"
user="db_user_name"
pass="db_user_pass"
## an alternative to putting the password into the script ( "less secure" ) is to read the user input into the variable ( "more secure" ).
#echo "Enter password for $user: "
#read -s pass
#database sizes
@stuudmuffin
stuudmuffin / minecraft_spigot_compiler.sh
Created January 20, 2018 21:58
Simple pull of fresh BuildTools followed by building the new server jar
#!/bin/bash
# you'll want to run this script in a folder by itself. The folder will be populared with all the stuff required to build the jar
# REQUIREMENTS
# curl
# java
version=$1;
curl "https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar" -o BuildTools.jar
@stuudmuffin
stuudmuffin / minecraft_plugin_versions.sh
Last active February 13, 2018 17:22
json output of plugin names and extensions
#!/bin/bash
# I used this to easily export the json to a file for more processing
## bash minecraft_plugin_versions.sh > /var/www/html/info/version.json
## chown www-data:www-data /var/www/html/info/version.json
# this would save the file to my webserver directory, and ensure it had the right permissions to be processed by the server
# I then had a php script that would compare the list in a crude way against the developer sites for my plugins, and display them in a nice format
# that script I likely will not post as it's super dirty... Maybe if I find a better method of doing it.
# REQUIREMENTS
# zip
@stuudmuffin
stuudmuffin / mount_exfat.sh
Last active February 28, 2024 01:26
simple exfat mounting script with some error checking
#!/bin/bash
# I had this on an ubuntu box which had a USB hard drive for some basic server backups.
# this could be easily modified for other mounting types.
# REQUIREMENTS:
# install exfat compatability
# find the uuid of your drive (I used "ls -l /dev/disk/by-uuid" then "smartctl -i /dev/PATH_HERE" to determine which drive I was wanting
uuid="5566-77FF"; # the uuid can sometimes be longer.
mnt_path="/mount/exfat"; # mnt_path can be just about any empty folder you'd like. And it must be empty to work.
@stuudmuffin
stuudmuffin / curl_progress.php
Last active May 11, 2024 20:21 — forked from bdunogier/curl_progress.php
PHP/cURL download progress monitoring
<?php
//If output buffer flushing does not work, web-search for reasons your php/webserver setup may need to be adjusted
header('X-Accel-Buffering: no');
if (ob_get_level() == 0) ob_start();
//create javascript progress bar
echo "<html>
<head>
<script type='text/javascript'>
function updateProgress(perc) {