Skip to content

Instantly share code, notes, and snippets.

View ambakshi's full-sized avatar

Amit Bakshi ambakshi

View GitHub Profile
@ambakshi
ambakshi / ssh-agent-profile.sh
Last active August 29, 2015 14:06
ssh-agent
#
# After running the above script, paste the following into your ~/.bash_profile or ~/.profile
#
if test -f "$HOME/.ssh/environment.$HOSTNAME"; then
source "$HOME/.ssh/environment.$HOSTNAME"
if ! test -e /proc/$SSH_AGENT_PID; then
rm -f $HOME/.ssh/environment.$HOSTNAME
unset SSH_AUTH_SOCK SSH_AGENT_PID
echo >&2 "Run ~/bin/ssh-agent.sh to set your SSH env"
echo >&2 "then source your profile to set the ssh-agent"
@ambakshi
ambakshi / drop_caches.sh
Last active August 29, 2015 14:06
Drop Linux page cache
#!/bin/bash
/usr/bin/logger -it drop_caches -p cron.info drop caches ${1:-3}
/bin/echo ${1:-3} > /proc/sys/vm/drop_caches
@ambakshi
ambakshi / iam-assume-role.sh
Last active October 25, 2021 15:50
Assume an IAM role. An interesting way of doing IAM roles is to give the instance permissions to assume another role, but no actual permissions by default. I got this idea while setting up security monkey: http://securitymonkey.readthedocs.org/en/latest/quickstart1.html#setup-iam-roles.
#!/bin/bash
#
# Assume the given role, and print out a set of environment variables
# for use with aws cli.
#
# To use:
#
# $ eval $(./iam-assume-role.sh)
#
@ambakshi
ambakshi / puppet-gem-chroot.sh
Created September 15, 2014 10:58
Builds puppet & facter into something akin to a virtualenv /opt/puppet-3.6.2 with wrappers in /opt/puppet/bin/{facter,puppet}
#!/bin/bash
set -ex
V=3.6.2
TMP=/tmp/gems/$LOGNAME/$$
mkdir -p "$TMP/root/opt/puppet-$V"
trap "cd -; mv $TMP/*.rpm . ; rm -rf $TMP" EXIT
cd "$TMP"
@ambakshi
ambakshi / build-tmux.sh
Last active August 29, 2015 14:06
Build tmux1.9a with dependencies statically linked
#!/bin/bash
ITER=5
TMUXV=1.9a
EVENTV=2.0.21
NCURSESV=5.9
set -ex
export TMP=/tmp/tmux
rm -rf $TMP
@ambakshi
ambakshi / bash_aliases
Last active January 24, 2024 18:47
Bootstrap vim and tmux
#!/bin/bash
# shellcheck disable=SC1073,SC1007,SC1072,SC1090,SC1091,SC2015
if [[ $UID -ne 0 ]]; then
if ! type -t __git_ps1 >/dev/null 2>&1 && test -e /usr/share/git-core/contrib/completion/git-prompt.sh; then
. /usr/share/git-core/contrib/completion/git-prompt.sh
fi
if type -t __git_ps1 >/dev/null 2>&1; then
PS1='[\[\033[32m\]\u@\h\[\033[00m\] \[\033[36m\]\W\[\033[31m\]$(__git_ps1)\[\033[00m\]] \$ '
@ambakshi
ambakshi / mesos-docker.sh
Last active August 29, 2015 14:07
mesos-docker.sh
#!/bin/bash
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get install lxc-docker
echo 'docker,mesos' | sudo tee /etc/mesos-slave/containerizers
echo '5mins' | sudo tee /etc/mesos-slave/executor_registration_timeout
sudo service mesos-slave restart
@ambakshi
ambakshi / get-docker.sh
Created October 17, 2014 18:09
get-docker
#!/bin/bash
V="${1:-1.3.0}"
curl -sSL -O https://get.docker.com/builds/Linux/x86_64/docker-${V} && chmod +x docker-${V} && sudo mv docker-${V} /usr/local/bin/docker
@ambakshi
ambakshi / virtualenv-13.1.2.sh
Last active October 20, 2015 05:55
Nice little trick to have a deployable shim to a real python package
#!/bin/bash
#
# The package name and version are parsed from the filename (in this case
# PACKAGE=virtualenv V=1.11.6). The package is downloaded to /var/tmp if it
# isn't already there, and the main script is executed. This is sort of like
# having a lightweight shim to the real remote executable package. Very cool,
# I can't believe I didn't think of this sooner.
#
# This same file will work for (almost) any package.
#
@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