Skip to content

Instantly share code, notes, and snippets.

@traderose
traderose / gist:cad30bbc94ca5103b490d9b8c1b54c65
Created May 21, 2021 18:58 — forked from ibnux/gist:59dd7d64bd9cb7e1e670b6ddd70ad991
Mikrotik Script for DHCP Lease to Queue simple
:local queueName "Client-$leaseActMAC";
:local ipAdd "$leaseActIP/32";
:if ([:len [/queue simple find name=$queueName]] = 0) do={
:log info "No Queue";
/queue simple add name=$queueName target=($ipAdd) limit-at=10M/4M max-limit=10M/4M comment=[/ip dhcp-server lease get [find where active-mac-address=$leaseActMAC && active-address=$leaseActIP] host-name];
} else={
:log info "exists";
:local ada [/queue simple get [find name=$queueName] target];
@traderose
traderose / rotate_old_radacct_detail_files_mtime_based.sh
Created May 21, 2021 00:54 — forked from ptomulik/rotate_old_radacct_detail_files_mtime_based.sh
Rotation script for freeradius accounting detail files. Shall be run as a cron script.
#! /bin/sh
########################################################################################
# Compresses old radacct detail files and removes very old compressed radacct files.
########################################################################################
# Author: P. Tomulik
########################################################################################
# Path to the programs used (for environments without $PATH set)
FIND=/usr/bin/find
@traderose
traderose / README.md
Created January 1, 2021 16:15 — forked from alixaxel/README.md
Generating IPv6 PTR records from a Bind9 zonefile using Bash

Generating IPv6 PTR records from a Bind9 Zonefile using Bash.

The following script takes a Bind9 zonefile, gets all AAAA records from it and generated PTR records based on them.

What you need to do:

  1. Edit the Zone header in the script.
  2. Run the script with ./generate_v6_ptr.sh /path/to/zonefile.zone

This will output the zones on STDOUT. If you want to save this to a zonefile, you can use this example:

@traderose
traderose / backupToFTP.sh
Created September 22, 2019 07:07 — forked from jameshartig/backupToFTP.sh
Backup and tar directory to a remote FTP server via bash
#!/bin/bash
# this also assumes you created "backups" on the remote host
DATETIME=`date +%Y%m%d%H%M`
BACKUP_FILENAME=$DATETIME.tar.gz
LOG=/tmp/backup/upload-$DATETIME.log
tar pzcPf /tmp/backup/$BACKUP_FILENAME /opt
# include FTP variables from home directory
@traderose
traderose / city_code_helper.php
Created April 18, 2019 15:05 — forked from ckimrie/city_code_helper.php
3 letter IATA City code to City name converter
<?php
/**
* 3-letter IATA City Code to CityName conversion
*
* Usage:
*
* $city_name = City::code("LON");
* // "London"
*