Skip to content

Instantly share code, notes, and snippets.

View jim80net's full-sized avatar

Jim Park jim80net

  • Scribd
  • San Francisco, CA
  • 20:53 (UTC -07:00)
  • X @jim80net
View GitHub Profile
@jim80net
jim80net / install.sh
Created September 3, 2012 21:07
Install jenkins server on SmartOS
#!/bin/pseudo-bash
# Read through this and modify to taste.
# Tested on:
# dataset_uuid: c36a3d28-80c2-11e1-9ec6-df5bd8b43f76
# sdc:sdc:smartosplus:3.2.0
mkdir /data
useradd -d /data dev
groupadd dev
cd /data
@jim80net
jim80net / rotisascreen.sh
Created December 5, 2012 22:54
Use wmctrl to rotate through workspaces
#!/bin/bash
# rotisascreen.sh
# - Rotate screens on occassion
screenCount=$(wmctrl -d | tail -n 1 | awk '{print $1}')
while true
do
count=1
while [[ $count -le $screenCount ]]
do
@jim80net
jim80net / gist:5440037
Created April 23, 2013 01:08
Install git on cpanel server.
sudo su -
cd /usr/local/src
wget http://git-core.googlecode.com/files/git-1.7.6.4.tar.gz
tar zxvf git-1.7.6.4.tar.gz
cd git-1*
make clean && make distclean
make configure
./configure --prefix=/usr
make
make install
@jim80net
jim80net / vmigrate.sh
Last active November 20, 2023 14:19
Use this script to migrate a SmartOS guest to a target. ./vmigrate.sh UUID TARGETIP - or - ./vmigrate.sh UUID TARGETIP migration-snapshotdate # specify the initial snapshot timestamp to increment the snapshot on the target
#!/bin/bash
# Use this to send and receive files
# Dependencies:
# SSH-Keys setup for root users. I recommend using agent forwarding for this.
# mbuffer installed in /opt/local/bin/mbuffer. Adjust to reality.
#
# This script presumes:
# zsnapper is installed. Comment out the two lines where it is referenced if you don't use it
DATE=$(date +%Y%m%d%H%M)
@jim80net
jim80net / puppet_gem_installer.sh
Created September 23, 2013 03:14
Install puppet via gem on smartos
#!/bin/bash
# For installation of puppet by gem for smartos
#
VERSION=3.3.0
PREFIX=/opt
mkdir -p /var/lib
cd ${PREFIX}
sudo gem install --no-ri --no-rdoc puppet
@jim80net
jim80net / gist:8870533
Last active August 29, 2015 13:56
Class arbitrary instance attributes
def method_missing(sym, *args)
name = sym.to_s
if name[-1,1] == '='
instance_variable_set( "@#{name[0, name.size - 1]}", *args)
else
instance_variable_get("@#{name}")
end
end
@jim80net
jim80net / dnscheck.rb
Created February 18, 2014 16:39
Compare DNS output with a list of expected values
#!/usr/bin/env ruby
require 'awesome_print'
require 'pry'
require 'ostruct'
require 'resolv'
begin #top
puts "Reading worklist"
@jim80net
jim80net / gist:9253601
Created February 27, 2014 16:31
BINDIR for bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
from: http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
@jim80net
jim80net / checksum.sh
Created February 27, 2014 16:38
BASH checksum
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CHECKSUM=`cat $DIR/.syncme.sh.md5sum | awk '{print $1}'`
MYCHECKSUM=`md5sum $DIR/syncme.sh | awk '{print $1}'`
if [[ "$CHECKSUM" != "$MYCHECKSUM" ]]
then
echo "This script was modified."
exit 2
else
@jim80net
jim80net / becareful.sh
Created March 11, 2014 06:00
dirty way to truncate deleted file handles
lsof | grep -i deleted | grep REG | grep -v txt | ruby -r 'pp' -e 'STDIN.each do |v| a = v.split(/ +/); puts `:> /proc/#{a[1]}/fd/#{a[3].chop}`; end'