Skip to content

Instantly share code, notes, and snippets.

View jagland's full-sized avatar

Jon Agland jagland

  • Wales
View GitHub Profile
@jagland
jagland / dob-check.pl
Created November 15, 2014 09:24
FreeRADIUS Date of Birth Check
#!/usr/bin/perl
##################################################################
# Copyright (C) 2012 - Jon Agland #
# #
# This program is free software; you can redistribute it and/or #
# modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation; either version 2 #
# of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful,#
@jagland
jagland / vm-backup.sh
Last active August 29, 2015 14:09
VMWare VCB Backup Script
#!/bin/bash
PATH=$PATH:/usr/sbin
VCBSNAP="/usr/sbin/vcbSnapAll"
USERNAME=""
PASSWORD=""
HOST="vcenter"
DEST="/vmfs/volumes/nnnnnnnn-nnnnnnnn"
$VCBSNAP -h $HOST -u $USERNAME -p $PASSWORD -a powerstate:on -r $DEST -M 1
cp /usr/scripts/backup-vm.log $DEST
@jagland
jagland / vm-snapshot-cleanup.sh
Created November 15, 2014 09:38
VMWare VCB Backup Snapshot Remover
#!/bin/bash
# This a dirty script to remove any VCB Backup snapshosts - see my vm-backup.sh in gist
PATH=$PATH:/usr/sbin
VCBVMNAME="/usr/sbin/vcbVmName"
VCBSNAP="/usr/sbin/vcbSnapshot"
VMLIST=$(/usr/sbin/vcbVmName -h vcenter -u username -p password -s powerstate:on | grep moref | awk -F\: '{ print $2 }'
for i in $VMLIST;
do
SNAPNAME=$(/usr/sbin/vcbSnapshot -h vcenter -u username -p password -f moref:$i "_VCB-BACKUP_" | grep "SsId:" | awk -F: '{ print $2 }')
@jagland
jagland / pfsense-backup.sh
Created November 15, 2014 09:40
pfSense Config Backup
#!/bin/bash
# You need a user called backup on the pfsense box and
# the SSH key of the user running this script shared.
HOSTS=''
for HOST in $HOSTS
do
scp -B -q backup@$HOST:/conf/config.xml ~/pfsense/$HOST-config.xml
done
@jagland
jagland / pfsense-mirror.sh
Created November 15, 2014 09:51
pfSense Mirror
#!/bin/bash
# Use this to create a local pfSense mirror as the updates
# can sometimes be a bit slow in the UK, useful if you have multiple boxes.
# you can specify multiple URLs, in this case grabbing x86 and amd64
TMPFILE=`mktemp`
updateurl='http://updates.pfsense.org'
urls='_updaters _updaters/amd64'
dest='/var/www/localhost/htdocs/pfsense'
for j in $urls;
@jagland
jagland / timeware-swipe.sh
Created November 15, 2014 10:06
Timeware Swipe
#!/bin/bash
# Handy script for submitting swipes to the timeware system.
# Once wrapped it with Zenity so that I could be prompted to swipe on login to my PC
# If you were deceitful you could use cron - Don't hold me responsible if you get sacked!
TMPFILE=`mktemp`
curl -b $TMPFILE -c $TMPFILE --data "txtUserName=username&txtPassword=password&cmdLogIn=Log%20In" -i http://timeware/log_in.html
curl -b $TMPFILE -c $TMPFILE --data "cmdSubmit=Submit%20Booking" -i http://timeware/attendance_booking.html
rm $TMPFILE
@jagland
jagland / vmtools
Created November 15, 2014 10:16
VMware Tools - Gentoo Init Script
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# This a wrapper for the vmware-tools init script, as it doesn't seem to work well under Gentoo.
extra_started_commands="reload"
depend() {
need logger
}
@jagland
jagland / generate-aliases
Last active September 9, 2016 10:08
Generate Aliases file based on multiple sources
#!/bin/bash
##################################################################
# Copyright (C) 2013 - Jon Agland #
# #
# This program is free software; you can redistribute it and/or #
# modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation; either version 2 #
# of the License, or (at your option) any later version. #
# #
@jagland
jagland / generate-address-list
Created November 15, 2014 10:34
Generate Address List from Aliases
#!/bin/bash
# Generate Address List from Aliases and drop an e-mail with an txt attachment
# Useful for importing to other mail systems that require a list of valid addresses
# for a particular domain.
if [ "$1" == "" ]
then
echo "Give me your email address..."
else
TMPFILE=`mktemp`
@jagland
jagland / tcpdump-reader
Created November 19, 2014 22:08
tcpdump-reader
#!/bin/bash
FILES=`ls -1 /var/lib/tcpdump`
for j in $FILES
do
tcpdump -q -r "/var/lib/tcpdump/"$j "$@"
done