Skip to content

Instantly share code, notes, and snippets.

@daveadams
daveadams / convert-longs-to-lobs.sql
Created January 2, 2014 13:57
Sakai's auto DDL code creates deprecated data types (LONG and LONG RAW) in Oracle databases. While Sakai continues to work, the use of these deprecated data types can cause problems for other tools that work with the database, including Oracle's own maintenance tools. Conversion of these data types to CLOB and BLOB is recommended. This script wi…
-- convert-longs-to-lobs.sql
-- Scan for and convert LONG and LONG RAW fields in a Sakai database
-- See https://jira.sakaiproject.org/browse/SAK-7977
--
-- Created 2013-03-29 daveadams@gmail.com
--
-- USAGE:
-- To scan for LONG and LONG RAW fields, but make no changes:
-- $ sqlplus -S dbuser/dbpass@dbsid @convert-longs-to-lobs.sql
--
@daveadams
daveadams / disk-report.rb
Created January 30, 2014 11:40
Sakai site disk usage report using sakai-info gem
#!/usr/bin/env ruby
#
# disk-report.rb
# Reports disk usage broken down by category for all sites in a Sakai instance.
#
# Written by David Adams (daveadams@gmail.com)
#
# This software is licensed to the Public Domain; No Rights Reserved
#
@daveadams
daveadams / binary-resource-report.rb
Last active August 29, 2015 13:55
Sakai disk usage reports by binary properties
#!/usr/bin/env ruby
#
# binary-resource-report.rb
# Reports disk usage broken down by properties in the binary_entity field.
#
# WARNING: takes a long time to run
# (~5 hours for 10,000,000 records)
#
# Written by David Adams (daveadams@gmail.com)
#
@daveadams
daveadams / install-ansible.sh
Created February 10, 2014 14:13
Install ansible within pyenv
#!/bin/bash -e
which pyenv &>/dev/null \
|| { echo "ERROR: pyenv not found" >&2; exit 1; }
grep -qFx 2.7.6 <(pyenv versions --bare) \
|| { echo "ERROR: python 2.7.6 not installed; run 'pyenv install 2.7.6'" >&2; exit 1; }
export PYENV_VERSION=2.7.6
@daveadams
daveadams / acl-vault-tests.sh
Created December 19, 2015 13:30
ACL policy and tests for Hashicorp Vault
#!/bin/bash
echo -n "Starting vault... "
vault server -dev &> vault-server.log &
vault_pid=$!
echo OK
shutdown() { trap "" EXIT; echo -n 'Shutting down... '; kill -9 $vault_pid; echo OK; exit $1; }
trap "shutdown 0" EXIT
trap "echo; echo 'Got interrupt signal!'; shutdown 255" INT
@daveadams
daveadams / 01-vault-restore-poc.txt
Last active July 15, 2019 17:11
POC Vault Restore
To restore a filesystem-backed Vault instance:
1. Shut down running Vault process (pkill vault)
2. Make backup to new location (cp -r /original-storage /new-storage)
3. Write a new config file to point to /new-storage
4. Start new Vault process (vault server -config=new-config-file.hcl)
5. DO NOT run `vault init`
6. ONLY RUN `vault unseal <key1>`, etc...
@daveadams
daveadams / consul.conf
Created June 1, 2016 17:51
Consul upstart config
description "Consul Agent"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on stopping network-services
respawn
console none
setuid consul
@daveadams
daveadams / consul.defaults
Created June 1, 2016 17:54
Consul defaults
# consul defaults
CONSUL_CONF_DIR=/etc/consul.d
node_name=`curl -s 169.254.169.254/latest/meta-data/instance-id`
first_mac=`curl -s 169.254.169.254/latest/meta-data/network/interfaces/macs/ |head -n 1`
vpc_id=`curl -s 169.254.169.254/latest/meta-data/network/interfaces/macs/${first_mac}vpc-id`
case "$vpc_id" in
vpc-00000000)

Keybase proof

I hereby claim:

  • I am daveadams on github.
  • I am daveadams (https://keybase.io/daveadams) on keybase.
  • I have a public key whose fingerprint is 137C C203 79F2 E5F8 280F 3194 D93A 7D85 B902 603D

To claim this, I am signing this object:

#!/bin/bash
#
# vault-ec2-auth.sh
# Authenticates an EC2 instance to Hashicorp Vault
#
# configuration stored in environment variables in /etc/vault/client.conf
# expected configuration (defaults are selected below if none is specified):
# VAULT_ADDR = url of vault server
# VAULT_ROLE = role name to authenticate as