Skip to content

Instantly share code, notes, and snippets.

@limed
limed / pre-commit.sh
Created May 10, 2012 16:41
Git client pre-commit hook for verifying puppet errors
#!/bin/sh
syntax_errors=0
error_msg=$(mktemp /tmp/error_msg.XXXXXX)
if git rev-parse --quiet --verify HEAD > /dev/null
then
against=HEAD
else
# Initial commit: diff against an empty tree object
@limed
limed / remove.pp
Created June 14, 2012 22:42
Removes yum packages
# Remove a yum package via exec, this is done this way because
# package { 'foo': ensure => purged; } keeps getting called on every
# puppet run. We can't use ensure => absent because of an issue with
# circular dependencies
define yum::remove(
$package = $name,
$ensure = 'absent') {
if ($ensure in ['absent', 'purged']) {
@limed
limed / base_init.pp
Last active October 9, 2015 06:38
Base module that is OS agnostic
class base {
case $::operatingsystem {
'ubuntu', 'debian': {
include base::debian
}
'fedora', 'centos', 'redhat': {
include base::el
}
@limed
limed / el.pp
Last active October 9, 2015 06:38
Puppet base module for enteprise linux
class base::el {
# This is the enteprise linux class, we will split it off more
# for centos or redhat
if $::osfamily != redhat {
fail("${::operatingsystem} not supported")
}
class { 'yum':
extrarepo => ['epel', 'puppetlabs'],
@limed
limed / vimrc
Last active October 12, 2015 15:27
vimrc
"-------------------------------------------------
" vimrc file for ed lim
" @author - Ed Lim
"-------------------------------------------------
"------------ editor behaviour block ------------------
set shiftwidth=4 " Use 4 spaces when text is indented
set softtabstop=4
set tabstop=4 " sets how many spaces a tab is
set smarttab
@limed
limed / .bash_gpg
Last active December 12, 2015 05:09
Init's gpg agent if the daemon isn't running and exports the environment variables
envfile="${HOME}/.gnupg/gpg-agent.env"
if test -f "$envfile" && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null; then
eval "$(cat "$envfile")"
else
eval "$(gpg-agent --daemon --log-file=~/.gnupg/gpg.log --write-env-file "$envfile")"
fi
export GPG_AGENT_INFO # the env file does not contain the export statement
@limed
limed / megacounter3000
Last active December 23, 2015 02:39
This basically iterates through all the mailbox folders and counts the number of mail a particular mailbox has
#!/bin/bash
for i in `zmprov -l gas | grep 'mbox'`; do
for j in $( zmprov -l gaa -s ${i} | egrep -v "^(spam|ham)" ); do
total=0
echo -n "Total emails for $j = "
for k in $( zmmailbox -z -m "$j" gaf | awk '{print $4}' | egrep -o "[0-9]+" ); do
total=$(( total + k ))
done
echo $total
@limed
limed / quotachecker4000
Last active December 23, 2015 09:49
Checks if user is over quota and gives a report
#!/bin/bash
IAM=`id -un`
if [ "$IAM" != "zimbra" ]; then
echo "You must run this script as the 'zimbra' user. Please 'su - zimbra' first."
exit 1
fi
# Run command zmprov gc Phoenix zimbraMailQuota | grep zimbraMailQuota | awk '{print $2}'
@limed
limed / 5yearcounter
Created September 19, 2013 21:28
Counts mail that is > 5 years
#!/bin/bash
# Counts for mail > 5 years
IAM=`id -un`
if [ "$IAM" != "zimbra" ]; then
echo "You must run this script as the 'zimbra' user. Please 'su - zimbra' first."
exit 1
fi
for mboxgroup in `/opt/zimbra/bin/mysql --batch --skip-column-names -e "show databases like 'mboxgroup%'"`; do
/opt/zimbra/bin/mysql --batch --skip-column-names -e "select count(*) from mail_item where date < unix_timestamp(now() - interval 5 year)" $mboxgroup;
[[email protected] puppetdb]# grep "Retrying after attempt" puppetdb.log | tail
2013-11-26 09:19:06,070 ERROR [command-proc-46] [puppetdb.command] [3e3036f7-5054-4e55-a2a2-b81ac6e8a328] [replace catalog] Retrying after attempt 4, due to: org.postgresql.util.PSQLException: This connection has been closed.
2013-11-26 09:19:43,077 ERROR [command-proc-46] [puppetdb.command] [3e3036f7-5054-4e55-a2a2-b81ac6e8a328] [replace catalog] Retrying after attempt 5, due to: org.postgresql.util.PSQLException: This connection has been closed.
2013-11-26 09:34:49,008 ERROR [command-proc-46] [puppetdb.command] [6940ac76-6803-4ca4-b693-94118f23aa8d] [replace facts] Retrying after attempt 4, due to: org.postgresql.util.PSQLException: This connection has been closed.
2013-11-26 09:34:50,111 ERROR [command-proc-46] [puppetdb.command] [1c3436ce-0933-413e-9965-f44ecd31fb89] [replace catalog] Retrying after attempt 4, due to: org.postgresql.util.PSQLException: This connection has been closed.
2013-11-26 09:35:09,004 ERR