Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
if [[ "$#" < "2" || "$#" > "3" ]]; then
cat <<END
Glusterfs GFID resolver -- turns a GFID into a real file path
Usage: $0 <brick-path> <gfid> [-q]
<brick-path> : the path to your glusterfs brick (required)
@pulecp
pulecp / check_repos_agaist_permissions.sh
Last active October 4, 2016 15:01
[Gitolite] Find missing permissions and missing repositories
#!/bin/bash
RED='\033[0;31m'
BLUE='\033[1;34m'
NC='\033[0m' # No Color
tmp_dir_repos=/tmp/srv_git_repositories
tmp_perm_repos=/tmp/gitolite_conf_repositories
perm_file=/srv/git/.gitolite/conf/gitolite.conf
@pulecp
pulecp / ip_address_duplication_check.sh
Last active September 1, 2016 11:04
Nagios check for IP address duplications
#!/bin/bash
# This file is managed by puppet
# ignore localhost, and addresses with subnet /32 (because of Hetzner failover IP)
ips=$(ip addr show | grep "inet\b" | awk '{print $2}' | grep -E -v '127\.0\.0\.1|\/32' | cut -d/ -f1)
interfaces=$(ip link show | grep 'state UP' | cut -d ':' -f2 | tr -d ' ' | grep -v '\-drac')
duplications=''
arping_output=''
@pulecp
pulecp / purge_elasticsearch.sh
Last active June 29, 2016 08:38
Script to remove documents from elasticsearch by query or whole index
#!/bin/bash
# elasticsearch cleanup script
ES_BASEDIR='/var/lib/elasticsearch/'
ES_HTTP='http://localhost:9200'
RETENTION_PERIOD='365'
QUERY=''
REMOVE=false
TEMP_FILE=/tmp/_usr_local_sbin_purge_elasticsearch.sh_$$
@pulecp
pulecp / package-drupal-coder
Created June 16, 2016 08:41
The script to create rpm package from Drupal coder
#!/bin/bash
rm -f *.rpm
rm -rf coder
git clone https://git.drupal.org/project/coder.git
cd coder
PACKAGE_VERSION='2.0'
PACKAGE_RELEASE='2'
@pulecp
pulecp / list_of_upstream_nameservers.rb
Last active May 26, 2016 10:14
Get list of namservers per domain
#
# src: https://gist.github.com/pulecp/678057b9b059ff34dee0f130680a7d79
#
# gem install whois
require 'whois'
# # randomly sort the domains recursively
recursive_sort = ""
# random_boolean = [true, false].sample
# random_boolean ? recursive_sort = "" : recursive_sort = "-r"
@pulecp
pulecp / rm-corrupt.sh
Last active March 31, 2016 09:49 — forked from codepunkt/rm-corrupt.sh
find/delete corrupt whisper-files
#!/bin/bash
options=('find' 'delete')
PS3='state your wish: '
echo -e "\nfind/delete corrupt whisper-files"
[ -x /bin/whisper-info ] || { echo '/bin/whisper-info does not exists or it is not executable'; exit 1; }
select opt in "${options[@]}"; do
case $REPLY in
#!/bin/bash
# src: https://gist.github.com/untergeek/8029608
curl -XDELETE http://localhost:9200/_template/logstash?pretty=true
echo
echo "Deleted current logstash template..."
echo "Creating new logstash template..."
define downtime {
host_name zimbra8.example.com
service_description Bacula job: zimbra8.example.com
author kayn
comment Schedule downtime for services with workhours notifications
downtime_period monday 00:00-09:00,18:00-24:00
downtime_period tuesday 00:00-09:00,18:00-24:00
downtime_period wednesday 00:00-09:00,18:00-24:00
downtime_period thursday 00:00-09:00,18:00-24:00
downtime_period friday 00:00-09:00,18:00-24:00
NR_OF_IPADDRESS=`/sbin/ip a | grep 'inet ' | grep -v '127\.0\.0\.1' | wc -l`
[ "$NR_OF_IPADDRESS" -lt 1 ] && /sbin/service network restart