Skip to content

Instantly share code, notes, and snippets.

View mtongnz's full-sized avatar

Matt mtongnz

  • Auckland, New Zealand
View GitHub Profile
#!/bin/sh
PORT_DHCP="67"
PORT_DNS="53"
SHINOBI_IP="192.168.9.10"
STATE_NEW="-m state --state NEW"
REJECT="REJECT --reject-with icmp-host-prohibited"
REJECT_TCP="REJECT --reject-with tcp-reset"
# limit guests to essential router services (icmp echo/reply, dhcp, dns)
@mtongnz
mtongnz / UnraidVMpowerSwitch
Created November 19, 2020 10:10
Hi-jack an unraid server power button to start and stop a VM
################################################################
# edit file: /boot/config/acpi_handler.sh
# change "power)" line to point at vmStartStop script location (shown at top of web UI when editing User Script)
################################################################
#!/bin/sh
# Default acpi script that takes an entry for all actions
IFS=${IFS}/
set $@
@mtongnz
mtongnz / unraidPHPargs
Created January 9, 2024 23:18
This is a script to extract and split the args in PHP using the User Scripts plugin. It allows for args that have spaces and are enclosed in double quotes.
#!/usr/bin/php
<?php
#description=PHP - Get split args out
#argumentDescription=This is the description of the argument(s)
#argumentDefault="a b c" 1 2 3 "de" 4 5
# Split out args
$args = preg_split('/(".*?")/', $argv[1],-1,PREG_SPLIT_DELIM_CAPTURE);
for ($key=0; $key<count($args); $key++) {
@mtongnz
mtongnz / unraidBASHargs
Created January 9, 2024 23:19
This is a script to extract and split the args in Bash using the User Scripts plugin. It allows for args that have spaces and are enclosed in double quotes.
#!/bin/bash
#description=Suck args into array
#argumentDescription=This is the description of the argument(s)
#argumentDefault="ab c dne" 1 2 "de" 3
splitArgs () {
# Default delimiter is *
if [ -z ${2+x} ]; then d=*; else d=$2; fi
@mtongnz
mtongnz / dockerComposeFunctions
Created March 8, 2024 03:46
Unraid user script to run docker compose manager commands
#!/usr/bin/php
<?php
#description=Docker Compose functions
#argumentDescription=arg1: action (up, down, stop, update, down_up) arg2+: compose project names
#argumentDefault=down_up dns tunnels websites multimedia downloads websites automation essentials
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
@mtongnz
mtongnz / unraidArrTester
Last active April 20, 2024 05:52
This is a User Script for unRaid to interface with various *arr APIs. It will test (and thus re-activate) indexers and download clients in Prowlarr, Sonarr, and Radarr.
#!/usr/bin/php
<?php
#description=ARR Tester
// -- CONFIG -- //
// API Key mode:
// Determines if the API key is sent as part of the URL or in the request header
// either HEADER or URL