Skip to content

Instantly share code, notes, and snippets.

View vikramkhatri's full-sized avatar

Vikram Khatri vikramkhatri

View GitHub Profile
@vikramkhatri
vikramkhatri / disk-usage.sh
Last active May 22, 2020 17:04
Monitor disk space usage and send mail
#!/bin/sh
set +x
SUBJECT="Disk Usage Report on $(date)"
MESSAGE="/tmp/disk-usage.out"
TO="user1@example.com,user2@example.com"
threshold=95
> $MESSAGE
for server in $(cat /root/bin/servers.txt)
@vikramkhatri
vikramkhatri / keybase.md
Created September 3, 2019 12:29
keybase proof

Keybase proof

I hereby claim:

  • I am zinox on github.
  • I am zinox (https://keybase.io/zinox) on keybase.
  • I have a public key ASA4WcnvDA6CdMu2LxquSlmmUpG4DaYsm5RAH8vUVlUdggo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am zinox on github.
  • I am zinox (https://keybase.io/zinox) on keybase.
  • I have a public key ASAY7jui7tM3WH_ne6WjjFmIN4NfTFjCZSKiM9nlBrWxtgo

To claim this, I am signing this object:

@vikramkhatri
vikramkhatri / ask.sh
Created July 10, 2019 09:55
Bash General-Purpose Yes/No Prompt Function ("ask")
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
ask() {
# https://gist.github.com/davejamesmiller/1965569
local prompt default reply
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
@vikramkhatri
vikramkhatri / self-extracting_script.sh
Created August 26, 2018 23:13 — forked from gregjhogan/self-extracting_script.sh
self-extracting shell script
# create files in an otherwise empty directory
mkdir files
cd files
touch setup.sh # entry point after extraction
touch file.txt # supporting data used by setup.sh
# create archive
tar -pczf ../archive.tar.gz *
cd ..
#!/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
@vikramkhatri
vikramkhatri / autossh&.sh
Created July 8, 2018 12:02 — forked from nachivpn/autossh&.sh
Running an expect script in the background
#!/usr/bin/expect -f
set host "host"
set password "password"
spawn ssh $host
expect {
"(yes/no)?" {
send -- "yes\r"