Skip to content

Instantly share code, notes, and snippets.

@pad92
pad92 / mysql-import.sh
Last active December 5, 2023 12:46
MySQL Import (MultiThread)
#!/bin/sh
# Run it into backup directory.
# export file format : base-table....sql.gz
for FILE in $(ls -1 *.sql.gz) ; do
DATABASE=$(echo $FILE | cut -d\- -f1)
TABLE=$(echo $FILE | cut -d\- -f2 | cut -d\. -f1)
PS=$(mysql -e 'show processlist\G' | grep ^Command | wc -l)
while [ $PS -gt 100 ]; do
@pad92
pad92 / discover.sh
Created June 26, 2012 10:34
discover
#!/bin/bash
# You should be strict ! ( -e )
# Or want some debug ? ( -x )
set -e
# NOTES
# | mail -s "AWH host check for $HOSTNAME @ $(date +%Y.%m.%d-%H:%M)" [email protected]
###
@pad92
pad92 / check_ns_from_name-conf-local.sh
Created July 24, 2012 12:59
DIG NS from /etc/bind/named.conf.local
#!/usr/bin/env sh
for zone in $(cat /etc/bind/named.conf.local | grep -v ^/ | grep -v ^$| cut -d\" -f2 | sort |uniq ); do
echo "* dig NS $zone"
dig NS +short $zone
done
@pad92
pad92 / mount_qcow2.sh
Created July 25, 2012 10:08
Mount .qcow2 img file
#!/usr/bin/env sh
#charger le module
modprobe nbd max_part=63
# connecter le systeme a l'image (nbd0 a nbd15 dispo )
qemu-nbd -c /dev/nbd0 image.qcow2
# monter la partition
mount /dev/nbd0p1 /mnt/image
@pad92
pad92 / apache_gen_vhosts.sh
Created July 26, 2012 13:16
Create vhost conf from list
#!/usr/bin/env sh
PATH="/etc/apache2/sites-available"
if [ "$#" -gt "0" ]; then
for VHOST in $@; do
if [ -f "$PATH/$VHOST" ]; then
/bin/rm "$PATH/$VHOST";
fi
/bin/cp "$PATH/default" "$PATH/$VHOST"
@pad92
pad92 / apache_expand_vhost.sh
Created July 26, 2012 14:44
Expand apache Vhost
#!/usr/bin/env sh
if [ ! -f "$1" ]; then
echo "Usage $0 : filename to paste"
exit 1
fi
COUNTER=0
while read LINE
#!/usr/bin/env sh
FTP_HOST='ftpback-rbx4-105.ovh.net'
ZFS_POOL='zroot'
GPG_USERID='0xA8331351'
for DIR in $(df -t zfs | awk '/\// {print $6}'); do
DIR_NAME=$(echo $DIR | sed 's#^/$#slash#' | sed 's#/##'| sed 's#/#_#g')
zfs set snapdir=visible $ZFS_POOL$DIR
if [ -d "$DIR/.zfs/snapshot/daily.0" ]; then
@pad92
pad92 / .conkyrc
Created December 2, 2012 00:46
My Conky
background yes
update_interval 1
cpu_avg_samples 2
net_avg_samples 2
temperature_unit celsius
double_buffer yes
no_buffers yes
text_buffer_size 2048
Package: libapache2-mod-php5 libapache2-mod-php5filter
Pin: version 5.2*
Pin-Priority: 1001
Package: php5-suhosin
Pin: version 0.9.2*
Pin-Priority: 1001
Package: php5 php5-cgi php5-cli php5-common php5-curl php5-dbg php5-dev php5-enchant php5-gd php5-gmp php5-ming php5-xcache
Pin: version 5.2*
#!/usr/bin/env sh
# === CONFIG ===
MYCNF='/etc/mysql/debian.cnf'
BIN_DEPS='bzip2 mysql'
# === CHECKS ===
for BIN in $BIN_DEPS; do
which $BIN 1>/dev/null 2>&1