Skip to content

Instantly share code, notes, and snippets.

@holly
holly / pgpool_recovery_1st_stage.sh
Created October 13, 2013 04:40
pgpool online recovery scripts
#!/bin/bash
set -e
SSH=/usr/bin/ssh
PSQL=/usr/bin/psql
PGBASEBACKUP=/usr/bin/pg_basebackup
REPLICATION_USER=replication
if [ -z "$MASTER_HOST" ]; then
@holly
holly / pgpool_follow_master.sh
Created October 14, 2013 15:25
follow_master_command = '/path/to/pgpool_follow_master.sh %d %h %H %r %R'
#!/bin/bash
set -e
SSH=/usr/bin/ssh
PGCTL=/usr/bin/pg_ctl
PCP_ATTACH_NODE=/usr/sbin/pcp_attach_node
DEVNULL=/dev/null
if [ -z "$PCP_HOST" ]; then
/*
This widget shows Recent Posts on your Tumblr blog.
Its dependency is jQuery.
Usage:
1) Add html:
<div id="recent-posts"></div>
2) Add code into the <head>:
#!/bin/sh
if [ -z "$HOSTNAME" ]; then
echo 'input $HOSTNAME'
read HOSTNAME
fi
if [ -z "$ROOT_PASSWORD" ]; then
echo 'input $ROOT_PASSWORD'
read ROOT_PASSWORD
@holly
holly / redis-sentinel-failover.sh
Created November 30, 2014 14:15
redis-sentinel client-reconfig-script
#!/bin/sh
# The following arguments are passed to the script:
#
# <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>
MASTER_IP=$6
VIP=172.17.0.101
NETMASK=16
IF=eth0
MY_IP=$(ip addr show dev $IF | grep "global $IF" | head -1 | sed -e "s/^.*inet \(.*\)\/$NETMASK .*$/\1/")
@holly
holly / getswap.sh
Last active April 8, 2023 14:22 — forked from koemu/getswap.sh
#!/bin/bash
# Get current swap usage for all running processes
# Erik Ljungstrom 27/05/2011
# Updated: 2013-11-13 Yuichiro Saito
SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ; do
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm --no-headers`
for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'`
@holly
holly / Check server
Last active August 29, 2015 14:16 — forked from Oneiroi/Check server
openssl s_client -cipher EXPORT -connect domain.com:443 < /dev/null 2>/dev/null | grep SSL-Session | wc -l
@holly
holly / make-cert.pl
Created April 19, 2015 03:36
Used to generate PEM encoded files from Mozilla certdata.txt
#!/usr/bin/env perl
# Used to generate PEM encoded files from Mozilla certdata.txt.
# Run as ./make-cert.pl > certificate.crt
#
# Parts of this script courtesy of RedHat (mkcabundle.pl)
#
# This script modified for use with single file data (tempfile.cer) extracted
# from certdata.txt, taken from the latest version in the Mozilla NSS source.
# mozilla/security/nss/lib/ckfw/builtins/certdata.txt
@holly
holly / check_drbd.sh
Created June 28, 2015 13:27
keepalived+drbd sample
#!/bin/bash
EXIT_CODE=0
STATUS_FILE=/tmp/drbd.status
STATUS=$(sed -e 's/.* state:\(.*\)$/\1/' $STATUS_FILE)
if [ "${STATUS}" != "MASTER" ]; then
echo "current status is ${STATUS}. skip"
exit
@holly
holly / virus-alert.sh
Last active June 15, 2018 08:45
clamav-milter VirusAction script
#!/usr/bin/env bash
# setting clamav-milter config file
# VirusAction /path/to/virus-alert.sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
SERVER=$HOSTNAME
VIRUS_ADMIN=${VIRUS_ADMIN:=virus-admin@$HOSTNAME}
VIRUS_ALERT=${VIRUS_ALERT:=postmaster@$HOSTNAME}
SUBJECT="[virus-alert] $SERVER: an infected e-mail has been detected."