Skip to content

Instantly share code, notes, and snippets.

@nohtyp
nohtyp / add-filesize.sh
Created November 27, 2013 00:06
This one-liner will total up the size of your file data
find . -name "*.txt" -ls | awk '{total += $7} END {print total}'
@nohtyp
nohtyp / seditknowhost.sh
Created November 27, 2013 00:10
sed one-liner to remove ssh-key output from known_hosts example: if offending ssh-key is on line 15 in known_hosts then the script would be ran as: sed -if '15d' /home/<user>/.ssh/known_hosts. This script can be used for many other issues.
sed -if '<number>d' file
@nohtyp
nohtyp / gitprettyoutput.sh
Last active December 29, 2015 18:29
git shortcut to get data of repo without looking at git web interface
git log --pretty=format:"%h - %an - %ar - %s"
To ignore last modifications and restart over from your repository:
git stash save --keep-index; git pull; git stash drop
@nohtyp
nohtyp / vagrant-build.sh
Last active December 31, 2015 01:59
This command line builds a vagrant server and concurrently provisions the system.
#!/bin/bash
#Used examples in the following link:
#http://coldattic.info/shvedsky/pro/blogs/a-foo-walks-into-a-bar/posts/7
#awk $0 is the entire line -> $1 is first argument -> line is making entire line equal first arg.
#will provision machines concurrently in vagrant
NUMPROCS='2'
vagrant up --no-provision;vagrant status |grep 'virtualbox' |awk '$0=$1'| xargs --max-procs=$NUMPROCS -I HOST vagrant provision HOST
@nohtyp
nohtyp / Vagrantfile
Last active January 11, 2016 02:53
My vagrant file...better example of how easy it is to add new servers
domain = 'familyguy.com'
VAGRANTFILE_API_VERSION = "2"
VAGRANT_BOX_URL = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box"
VAGRANT_TMP_NAME = "centos-min"
VBGUI = false
nodes = [
{ :hostname => 'peter', :ip => '192.168.2.10', :box => 'centos-min' },
{ :hostname => 'lois', :ip => '192.168.2.11', :box => 'centos-min' },
@nohtyp
nohtyp / useraudit.sh
Created December 18, 2013 14:33
user audit script
#!/bin/bash
#Create user list
cat /etc/passwd | awk -F : '{print $1}' > list
#Parse list and create organized list
USER=`cat list| while read line; do echo -n $line ;printf " "; done`
PWNEVER="PWNEVER.log"
@nohtyp
nohtyp / passwdchange.sh
Last active December 31, 2015 18:49
This script will change the password on the local server and send an email if it failed or completed the job.
#!/bin/bash
MYHOST=`hostname -s`
MYPW='!QAZXSw2@'
MYUSER='root'
NEWPASS="$MYHOST$MYPW"
MYEMAIL='<email list>'
echo -e "$NEWPASS\n$NEWPASS" | (passwd --stdin $MYUSER)
@nohtyp
nohtyp / environment.rb
Created December 23, 2013 16:40
puppet fact to determine dns sub-domain to use for dns resolution.
#Environment.rb
##Determines dns from hostname
Facter.add("mydns") do
setcode do
Senv = Facter.value('hostname').scan(/(^\D+\d)/)
if Senv.any?
Senv.to_s + ".promnetwork.com"
else
"no environment"
@nohtyp
nohtyp / oracle-pre-req.spec
Last active January 4, 2016 16:59
oracle-pre-req
Name: oracle-11g-pre-reqs
Version: 1
Release: 1%{?dist}
Summary: This package is the pre-reqs for an Oracle install
Group: Miscellaneous
License: PIN
URL: http://www.promnetwork.com/syseng
Source0: oracle-11g-pre-reqs.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
#!/usr/bin/env ruby
#!/opt/puppet/bin/ruby
require 'trollop'
require 'rbvmomi'
require 'rbvmomi/trollop'
################
# Parse Args #