Skip to content

Instantly share code, notes, and snippets.

@danisla
danisla / startup.sh
Created May 4, 2015 01:50
Startup script for running daemon java process in docker and tail log file
#!/usr/bin/env bash
# Script to run a process that runs in the background,
# then tail the log file in the forground.
# Useful for running apps in Docker container like subsonic, spark or apache.
# Author: [email protected]
function cleanup {
kill `pidof tail` 2>/dev/null
kill `pidof java` 2>/dev/null

Keybase proof

I hereby claim:

  • I am danisla on github.
  • I am disla (https://keybase.io/disla) on keybase.
  • I have a public key ASBcCSEnN7aTEyZrErozduW2IP6qe4wNPuG-H2o88PuTTwo

To claim this, I am signing this object:

@danisla
danisla / aws.mk
Last active October 25, 2016 22:24
Makefile for AWS Networking
SHELL := /bin/bash
VPC_CIDR ?= 10.240.0.0/16
SUBNET_CIDR ?= 10.240.0.0/24
aws-vars:
ifndef AWS_DEFAULT_REGION
$(error AWS_DEFAULT_REGION is not set)
else ifndef AWS_ACCESS_KEY_ID
$(error AWS_ACCESS_KEY_ID is not set)
@danisla
danisla / spinnaker-local.yml
Last active April 4, 2017 02:22 — forked from viglesiasce/spinnaker-local.yml
Spinnaker local configuration
# This file is intended to override the default configuration in the
# spinnaker.yml file while providing guidance on the mostly likely
# configuration parameters to be changed.
#
# In order for Spinnaker to discover it, it must be copied to a file named
# "spinnaker-local.yml" and placed in the $HOME/.spinnaker directory.
global:
spinnaker:
timezone: 'America/Los_Angeles'
@danisla
danisla / kernel-upgrade.sh
Created July 28, 2017 15:23
Install PREEMPT kernel on GKE container-vm instance
sudo bash
sudo apt-get update && sudo apt-get install -y build-essential libncurses5-dev bc
mkdir kernel && cd kernel
curl -LO http://http.us.debian.org/debian/pool/main/l/linux/linux-source-3.16_3.16.43-2+deb8u2_all.deb
dpkg -i linux-source-3.16_3.16.43-2+deb8u2_all.deb
@danisla
danisla / nf_conntrack_no_hash_resize_preempt-3.16_3.16.43-2.patch
Created July 30, 2017 20:34
Kernel patch to disable nf_conntrack hash resize
--- a/net/netfilter/nf_conntrack_core.c 2017-04-04 21:21:58.000000000 +0000
+++ b/net/netfilter/nf_conntrack_core.c 2017-07-30 18:23:52.951182000 +0000
@@ -1611,6 +1611,12 @@
struct nf_conntrack_tuple_hash *h;
struct nf_conn *ct;
+#ifdef CONFIG_PREEMPT
+ /* Setting hashsize with PREEMPT kernel is not supported. */
+ printk("WARN: nf_conntrack_set_hashsize: not supported with PREEMPT kernel, skipping resize request to: %s", val);
+ return 0;
@danisla
danisla / docker-terraform.bash
Last active November 9, 2017 08:42
Terraform with Docker for Linux, OSX and Google Cloud Shell
function terraform()
{
if [[ -e ${HOME}/.config/gcloud/credentials.json ]]; then
GOOGLE_CREDENTIALS="$(cat ${HOME}/.config/gcloud/credentials.json | tr '\n' ' ')";
fi;
GOOGLE_PROJECT=${DEVSHELL_PROJECT_ID:-$(gcloud config get-value project 2>/dev/null)};
VERSION=latest
docker run -u "${UID}:${UID}" -it --rm -v ${HOME}:${HOME} --env-file <(env|awk '/^.+=/'|grep -v TMPDIR) -e GOOGLE_CREDENTIALS="${GOOGLE_CREDENTIALS}" -e GOOGLE_PROJECT="${GOOGLE_PROJECT}" -w $PWD hashicorp/terraform:${VERSION} $@
}
@danisla
danisla / .kubefunc.bash
Created October 18, 2017 21:54
Kubernetes Bash Helper Functions
function kube-pod() {
kubectl get pods --selector=run=$1 --output=jsonpath={.items..metadata.name}
}
function helm-install-rbac() {
kubectl create serviceaccount tiller --namespace kube-system
kubectl create clusterrolebinding tiller-cluster-rule \
--clusterrole=cluster-admin \
--serviceaccount=kube-system:tiller
helm init --service-account=tiller
@danisla
danisla / terraform-install.sh
Last active July 15, 2024 13:36
Terraform latest version install script
#!/bin/bash
function terraform-install() {
[[ -f ${HOME}/bin/terraform ]] && echo "`${HOME}/bin/terraform version` already installed at ${HOME}/bin/terraform" && return 0
LATEST_URL=$(curl -sL https://releases.hashicorp.com/terraform/index.json | jq -r '.versions[].builds[].url' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | egrep -v 'rc|beta' | egrep 'linux.*amd64' |tail -1)
curl ${LATEST_URL} > /tmp/terraform.zip
mkdir -p ${HOME}/bin
(cd ${HOME}/bin && unzip /tmp/terraform.zip)
if [[ -z $(grep 'export PATH=${HOME}/bin:${PATH}' ~/.bashrc) ]]; then
echo 'export PATH=${HOME}/bin:${PATH}' >> ~/.bashrc
@danisla
danisla / packer-install.sh
Created August 2, 2018 05:51
Packer Install Script
#!/usr/bin/env bash
function packer-install() {
OS=$(uname -s)
[[ -f ${HOME}/bin/packer ]] && echo "`${HOME}/bin/packer version` already installed at ${HOME}/bin/packer" && return 0
LATEST_URL=$(curl -sL https://releases.hashicorp.com/packer/index.json | jq -r '.versions[].builds[].url' | sort -n | egrep -v 'rc|beta' | egrep "${OS,,}.*amd64" |tail -1)
curl ${LATEST_URL} > /tmp/packer.zip
mkdir -p ${HOME}/bin
(cd ${HOME}/bin && unzip /tmp/packer.zip)
if [[ -z $(grep 'export PATH=${HOME}/bin:${PATH}' ~/.bashrc 2>/dev/null) ]]; then