Skip to content

Instantly share code, notes, and snippets.

View ambakshi's full-sized avatar

Amit Bakshi ambakshi

View GitHub Profile
@ambakshi
ambakshi / vmrun.sh
Last active February 14, 2018 16:36
vmrun wrapper to run a command over vix and get the stdout/stderr
#!/bin/bash
#
# vmrun.sh
#
# Wrapper around vmrun to make running a shell command
# or script in the path easier. Outputs stdout/stderr
# from the command in the guest and exits with the
# same return code.
#
# Amit Bakshi
# Windows AMIs don't have WinRM enabled by default -- this script will enable WinRM
# AND install the CloudInit.NET service, 7-zip, curl and .NET 4 if its missing.
# Then use the EC2 tools to create a new AMI from the result, and you have a system
# that will execute user-data as a PowerShell script after the instance fires up!
# This has been tested on Windows 2008 R2 Core x64 and Windows 2008 SP2 x86 AMIs provided
# by Amazon
#
# To run the script, open up a PowerShell prompt as admin
# PS> Set-ExecutionPolicy Unrestricted
# PS> icm $executioncontext.InvokeCommand.NewScriptBlock((New-Object Net.WebClient).DownloadString('https://raw.github.com/gist/1672426/Bootstrap-EC2-Windows-CloudInit.ps1'))
@ambakshi
ambakshi / inputrc
Created November 30, 2014 04:42
inputrc
$include /etc/inputrc
set editing-mode vi
set keymap vi-insert
"\C-l": clear-screen
set keymap vi
#set completion-ignore-case on
#set show-all-if-ambiguous on
#set page-completions off
set match-hidden-files off
@ambakshi
ambakshi / gitconfig
Last active January 23, 2023 18:10
my gitconfig
; vim:set filetype=dosini:
[alias]
fap = fetch --all --prune
sb = status -sb
st = status -s
co = checkout
br = branch
bv = branch -avv
rv = remote -v
@ambakshi
ambakshi / base.df
Last active August 29, 2015 14:10
Base Dockerfile that shows how to get around pam w.r.t sudo
FROM centos:centos6
MAINTAINER Amit Bakshi <ambakshi@gmail.com>
RUN yum update -y && \
yum groupinstall -y 'Development tools' && \
yum install -y tar gzip cronolog rsyslog ruby ruby-devel rubygems vim-enhanced \
epel-release sudo hg bash-completion bzr rpmdevtools rpm-build rpm-libs \
openssh openssh-server openssh-clients screen mysql-server mysql httpd php
RUN gem install --no-rdoc --no-ri fpm
RUN rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-13.ius.centos6.noarch.rpm
@ambakshi
ambakshi / ec2-failed-instance-email.sh
Created November 2, 2014 19:55
Send an email when an instance dies during cloud-init.
#!/bin/bash
exec > >(tee /var/log/user-data.log|logger -it user-data -s 2>/dev/console) 2>&1
eval `ec2-tags -s -i`
/usr/sbin/sendmail -oi -t -f $EMAIL <<EOM
From: $EMAIL
To: $EMAIL
Subject: EC2 instance failure
@ambakshi
ambakshi / docker-direct-lvm.sh
Last active January 14, 2021 13:15
docker-direct-lvm
#!/bin/bash
set -e
## striping seems to break docker
#STRIPE="-i2 -I64"
#DEVS="/dev/xvdf /dev/xvdg"
DEVS="$1"
if [ -z "$DEVS" ]; then
echo >&2 "Specify which block devices to use"
exit 1
@ambakshi
ambakshi / go-install.sh
Last active August 29, 2015 14:08
Install the latest version of golang and some useful tools from source into ~/opt/go1.x
#!/bin/bash
#
# 1. Downloads, builds and install Golang from source.
# into $HOME/opt/goXXX where GOROOT is $HOME/opt/go
# symlink to the current version.
# 2. Install some standard go tools and helpers
# 3. Update $GOPATH built packages with new version of compiler
#
set -e
@ambakshi
ambakshi / route53-asg-rrdns.sh
Last active July 25, 2021 05:39
Add all instances in an autoscaling group to an equivalently named dns entry.
#!/bin/bash
#
# Get all IPs from an autoscale group and update set the local ip as
# equal weight A entries (round robin dns). Takes autoscale group as
# parameter.
#
# Amit Bakshi
# 10/21/2014
#
@ambakshi
ambakshi / docker-latest.sh
Last active August 29, 2015 14:07
Get the latest docker
#!/bin/bash
#
#
# Download the latest docker release and
# make sure /etc/sysconfig/docker is set
# to use it.
#
set -e