Skip to content

Instantly share code, notes, and snippets.

View philwinder's full-sized avatar

Phil Winder philwinder

View GitHub Profile
@philwinder
philwinder / htpasswd.py
Created April 28, 2015 12:19
A clone of the popular htpasswd generator.
#!/usr/bin/python
"""Replacement for htpasswd"""
# Original author: Eli Carter
# Cloned from http://trac.edgewall.org/
import os
import sys
import random
from optparse import OptionParser
@philwinder
philwinder / nginx_groups_auth.conf
Last active December 20, 2018 01:31
IVZ: A nginx configuration file to allow groups of users to access different parts of an elasticsearch instance.
events {
worker_connections 1024;
}
http {
upstream elasticsearch {
server 127.0.0.1:9200;
}
upstream kibana {
@philwinder
philwinder / updateGroups.rb
Created April 28, 2015 12:46
Reads a user:password file named htpasswd and updates all passwords in every *.auth file.
#!/usr/bin/env ruby
# Use htpasswd.py to add users to htpasswd file:
# touch ./htpasswd
# ./htpasswd.py -b ./htpasswd admin password
# ./htpasswd.py -b ./htpasswd alice password
# Add usernames to group files
# touch ./admins.auth
# touch ./users.auth
# echo "admin:..." >> admins.auth
@philwinder
philwinder / elasticsearch
Created April 29, 2015 09:30
A simple elasticsearch init.d script that works with the tar'ed version of elasticsearch on SuSe Enterprise 11 SP3. Move the extracted elasticsearch directory to /usr/share/elasticsearch. Copy this into /etc/init.d. Run with service elasticsearch start. Install service with chkconfig --add elasticsearch
#!/bin/sh
### BEGIN INIT INFO
# Provides: elasticsearch
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
@philwinder
philwinder / Vagrantfile
Last active August 29, 2015 14:20
IVZ. Bootstrap shell script to install software and Vagrantfile. If you also want to install kibana, download the bootstrap_kibana.sh too!
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "idar/sles11sp3"
# config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
@philwinder
philwinder / testWebserverAccess.sh
Last active August 29, 2015 14:20
A set of unit tests to test the vagrant build against the requirements. Uses curl with user/passwords to access the ES database.
#!/bin/bash
assertOK() {
response=$(curl -o /dev/null --silent --write-out '%{http_code}\n' -$1 $2 --data "$3")
if [[ $response == "200" ]] || [[ $response == "201" ]];
then echo "[OK-ACCEPTED] $1 $2 $3";
else
echo "TEST FAILED, should be ok: $1 $2 $3"
echo "Reason: "
echo $(curl --silent -$1 $2 --data "$3")
@philwinder
philwinder / Vagrantfile
Last active August 29, 2015 14:21 — forked from amadeoas/Vagrantfile
Drone installation vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@philwinder
philwinder / InstallDroneOnAWS
Last active May 23, 2018 11:01
Script to install Drone on an Amazon EC2 instance
#!/bin/bash
# First create a new EC2 ubuntu instance on the free tier.
# Ensure that port 22 (SSH) and 80 (HTTP) are open to the public.
# SSH into machine. Run these commands.
echo “Verify that docker is installed, if not install ”
command -v docker >/dev/null 2>&1 || { echo >&2 "docker isn’t installed. Installing"; wget -qO- https://get.docker.com/ | sh; }
wget downloads.drone.io/master/drone.deb
@philwinder
philwinder / authorize.lua
Last active February 3, 2022 07:36
IVZ: Nginx config for using Lua as the authentication module. You must install nginx with lua support. See "openresty" for linux distros or the vagrant bootstrap shell script.
--[[
Provides custom authorization for nginx.
See the `nginx_authorize_by_lua.conf` for the Nginx config. This lua file is referenced in the config
See testWebserverAccess.sh for unit tests.
To Run nginx (make sure you have the lua, config and htpasswd file):
$ /usr/local/openresty/nginx/sbin/nginx -c /etc/nginx/conf/nginx_authorize_by_lua.conf
Logs are available at: /usr/local/openresty/nginx/logs/lua.log
To write to the log:
@philwinder
philwinder / kibana4
Created May 20, 2015 10:06
Kibana4 init.d script for SLES 11 SP3
#!/bin/sh
### BEGIN INIT INFO
# Provides: kibana4
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO