Skip to content

Instantly share code, notes, and snippets.

View JonTheNiceGuy's full-sized avatar

Jon "The Nice Guy" Spriggs JonTheNiceGuy

View GitHub Profile
@JonTheNiceGuy
JonTheNiceGuy / AAA_Vagrant + Windows + Chocolatey Provisioning.md
Last active March 11, 2016 13:27
There are lots of instructions about setting up an auto-provisioning Linux host in Vagrant, but not a lot about doing the same for Windows. This should help!

Copy all of these into a single directory, make sure you've got a recent version of Vagrant and Virtualbox installed, then just... vagrant up

Vagrant will start a "simple" Windows 2012r2 box, created (presumably) by the fine folks at OpenTable and then it runs the provisioning sequence:

  • This will first run the ChocoBootstrap.cmd file to load Chocolatey onto the box (via InstallChocolatey.ps1)
  • It then uses chocolatey to install BoxStarter using the InstallBoxStarter.bat script
  • Lastly, it copies the BoxStarterOperations.txt file to %temp% and then executes it via RunBoxstarter.bat

This was all made a lot easier due to these blog posts

@JonTheNiceGuy
JonTheNiceGuy / line.sh
Created March 19, 2016 12:56
Get the latest Vagrant on x86/x64 Debian based systems
#! /bin/bash
if [ `uname -p` == 'x86_64' ]
then
wget `curl -s https://www.vagrantup.com/downloads.html | sed 's/\s/\n/g' | grep x86_64.deb | cut -c 7- | cut --delimiter=\" -f 1` -O /tmp/vagrant.deb; dpkg -i /tmp/vagrant.deb; rm /tmp/vagrant.deb
else
wget `curl -s https://www.vagrantup.com/downloads.html | sed 's/\s/\n/g' | grep i686.deb | cut -c 7- | cut --delimiter=\" -f 1` -O /tmp/vagrant.deb; dpkg -i /tmp/vagrant.deb; rm /tmp/vagrant.deb
fi
@JonTheNiceGuy
JonTheNiceGuy / AAA GPG Encrypt a file to a large number of recipients README.md
Created April 6, 2016 13:36
This batch file is used to encrypt a file with GPG against a large number of recipient email addresses

Using this script

Place this batch file and the text file into the same directory, edit the batch file to specify the key server and the text file to specify the names to encrypt.

If you hit an issue where an individual has multiple keys against their name, the script may well complain and ditch responses. In this case, uncomment the line in the batch file which says: REM %COMMAND% --recv-keys <KEY ID>

So it should say instead: %COMMAND% --recv-keys DECAFBAD

@JonTheNiceGuy
JonTheNiceGuy / group_vars~all
Created January 26, 2017 16:41
How to define multiple NICs on a host in Ansible with K5. Note this is redacted from my own code, so yours may need some tweaking and changes!
---
compute_images:
REDACTED:
name: "REDACTED"
compute_types:
REDACTED:
name: "REDACTED"
az:
@JonTheNiceGuy
JonTheNiceGuy / User commands.yml
Created May 16, 2017 08:09
Some common "create user" commands for Ansible
- name: Create Users on W2012 Server
raw: if (dsquery user -samid "{{item.key}}") {"Not Required"} else { New-ADUser -SamAccountName "{{item.key}}" -UserPrincipalName "{{item.key}}@{{windows_domain}}" -Name "{{item.value.name}}" -DisplayName "{{item.value.name}}" -GivenName "{{item.value.name.split(" ")[1]}}" -Surname "{{item.value.name.split(" ")[-1]}}" -ChangePasswordAtLogon $true -Enabled $true -AccountPassword (ConvertTo-SecureString "{{default_password}}" -AsPlainText -Force) }
- name: Create Users on W2008 Server with Domain Admin
raw: if (dsquery user -samid "{{item.key}}") {"Not Required"} else {dsadd user "CN={{item.key}},CN=Users,{{search_base}}" -samid "{{item.key}}" -upn "{{item.key}}@{{windows_domain}}" -display "{{item.value.name|default("Undefined")}} {{item.value.role|default("")}}" -fn "{{item.value.name.split(" ")[1]|default("Undefined")}}" -ln "{{item.value.name.split(" ")[-1]|default("Undefined")}}" -mustchpwd yes -pwd "{{default_password}}" -memberof "CN=Domain Admins,CN=Users,{{s
@JonTheNiceGuy
JonTheNiceGuy / AAA_runas-README.md
Last active December 5, 2017 23:13
Run GUI commands as other users, without having to SSH to that user account.

runas for Unix-like Systems

Download these two files, and place them in /usr/local/bin. Chmod them to 755, and chown them to root:root.

Then, perform the following command:

runas -u someuser command

or

@JonTheNiceGuy
JonTheNiceGuy / gmm.sh
Created December 5, 2017 23:20
Start a Google MusicManager session in another account
#!/bin/bash
while ! ping -c 1 8.8.8.8 2>/dev/null >/dev/null ; do
echo Waiting for network...
done
ssh -X bloggsf@localhost -i ~/.ssh/gmm.id_rsa /opt/google/musicmanager/google-musicmanager
@JonTheNiceGuy
JonTheNiceGuy / AAA_iBeacon_README.md
Last active January 8, 2018 20:57
Use your Debian System as an iBeacon for Home Automation

Use your Debian System as an iBeacon for Home Automation

Introduction

I have been playing with using the https://Home-Assistant.io system at home to play with Home Automation.

One thing I've found is that the Raspberry Pi is perfect for quite a few of the monitoring things that I wanted it to do (see also https://github.com/JonTheNiceGuy/home-assistant-configs for more details of what I'm doing there!).

I'm using the http://OwnTracks.org application to talk to an MQTT server, but I could also do with it knowing where I am in the house, so I looked around for some details on iBeacons.

iBeacon is an Apple standard, but it's very easy to configure on Linux systems. I took some pointers from this article and wrote up this script. When I later went to deploy this on another system, I also needed a pointer from [this PDF](https://cdn-learn.adafruit.com/downloads/pdf/pibeacon-ib

@JonTheNiceGuy
JonTheNiceGuy / AA_K5_Simple_Scripts.md
Last active June 26, 2018 08:56
The following scripts are tools I use on a regular basis to run simple activities on the K5 platform.

The following scripts are tools I use on a regular basis to run simple activities on the K5 platform. They can fairly easily be modified to work with OpenStack (and, probably in many cases, will work without modifications).

These are all written by me in my spare time, and are released under the WTFPL.

@JonTheNiceGuy
JonTheNiceGuy / AAA_Redirector_README.md
Created July 27, 2018 08:24
This script is a simple script to redirect you from your site to other locations. It's a very basic short-link generator.

Redirector

This script is a simple script to redirect you from your site to other locations. It's a very basic short-link generator.