Skip to content

Instantly share code, notes, and snippets.

for manifest in $(find manifests/ -type f -iname '*.pp'); do
sed -i 's/[ \t]*$//' $manifest #strip whitespace
vim -c 'normal gg=G' -c 'wq' $manifest #indent all lines properly (converting tabs to spaces, etc)
puppet-lint --no-80chars-check --no-documentation-check --fix $manifest #fix puppet style issues
done
@nbeernink
nbeernink / notify to slack.json
Last active October 5, 2016 11:04
[cerb] relay notifications through slack with time and activity conditions
{
"behavior":{
"title":"Notifications to slack",
"is_disabled":false,
"is_private":false,
"event":{
"key":"event.notification.received.worker",
"label":"New notification for me"
},
"nodes":[
@nbeernink
nbeernink / gauge-ticket-resolution-past-week.json
Created October 5, 2016 11:03
[cerb] gauge ticket resolutiontime the past week
{
"widget":{
"label":"Average resolution time past week",
"extension_id":"core.workspace.widget.gauge",
"cache_ttl":900,
"params":{
"threshold_labels":[
"Within 4 hours",
"within 8 hours",
"More than 24 hours",
@nbeernink
nbeernink / keyscan
Created March 1, 2017 10:23
Make connecting to huge lists of new hosts easier with this simple ssh hostkey importer (using ssh-keyscan)
#!/bin/bash
hostlist=$1
outputfile=$2
if [ -z "${2}" ];then
outputfile=~/.ssh/known_hosts
fi
time while read -r host; do
ip=$(dig +short "$host" 2> /dev/null)
#remove the key from the file
ssh-keygen -R "$host" -f "$outputfile" >/dev/null 2>&1;
@nbeernink
nbeernink / fix-plesk-ownership.sh
Last active March 1, 2017 15:03
tries to fix most of plesk users vhost ownership & permissions
#!/bin/bash
#Getting list of users and their home directories from psacln group
awk -F ":" '{print $1, $4, $6}' /etc/passwd | grep "$(getent group psacln|cut -d: -f3)" | awk -F " " '{print $1, $3}' > /root/users_list.txt
time while read -r i
do
user=$(echo $i | awk '{print $1}')
path=$(echo $i | awk '{print $2}')
echo Fixing ownership and permissions for $user
@nbeernink
nbeernink / wp-htpasswd.sh
Last active March 21, 2017 13:23
password protect wp-login to thwart bruteforce attacks
#!/bin/bash
test -e /tmp/found-wp-instances || find /home/ -type f -name "wp-login.php" > /tmp/found-wp-instances
time while read -r wp; do
#Set variables
user=$(echo "$wp"|cut -d/ -f3)
domain=$(echo "$wp"|cut -d/ -f5)
wp_htaccess=${wp//wp-login.php/.htaccess}
wp_htpasswd=${wp//wp-login.php/.htpasswd}

Keybase proof

I hereby claim:

  • I am nbeernink on github.
  • I am nbeernink (https://keybase.io/nbeernink) on keybase.
  • I have a public key whose fingerprint is FCDB 3FE6 555F FDB6 3CF8 B221 457E 8D28 82E3 F3DC

To claim this, I am signing this object:

@nbeernink
nbeernink / batch-imapsync.py
Last active April 3, 2018 12:10
batch migrate mail data via imapsync read from a csv file
#!/usr/bin/env python3
import argparse
import csv
import os
import subprocess
parser = argparse.ArgumentParser(description='Batch migrate e-mail with imapsync reading from a CSV-file')
parser.add_argument('csvfile',help='The CSV file to parse. The file should have a header like this: host1,user1,password1,host2,user2,password2')
parser.add_argument('--dry',action='store_true',help="Use imapsync's dry mode: don't sync, show what would happen")
args = parser.parse_args()
#!/bin/env python
import subprocess
import json
php_handler_data=json.loads(subprocess.check_output(['plesk','bin','php_handler','--list','-json','true']))
for handler in php_handler_data:
if handler['status'] == 'enabled' and 'x-httpd-lsphp' not in handler['id']:
print handler['id']
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR"|| (echo "Cannot change working directory to $DIR" && exit 1)
if [ "$(readlink "$DIR"/.git/hooks/pre-commit)" = "../../pre-commit.sh" ]; then
echo "Hook already installed!";
else
ln -vs ../../pre-commit.sh .git/hooks/pre-commit && echo "Installed git-hook succesfully!"
fi