Skip to content

Commit 8ce5a5a

Browse files
committed
Import my main scripts archive
1 parent 057faa9 commit 8ce5a5a

File tree

313 files changed

+10033
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

313 files changed

+10033
-24
lines changed

.gitignore

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Compiled source #
2+
###################
3+
*.com
4+
*.class
5+
*.dll
6+
*.exe
7+
*.o
8+
*.so
9+
10+
# Packages #
11+
############
12+
# it's better to unpack these files and commit the raw source
13+
# git has its own built in compression methods
14+
*.7z
15+
*.dmg
16+
*.gz
17+
*.iso
18+
*.jar
19+
*.rar
20+
*.tar
21+
*.zip
22+
23+
# Logs and databases #
24+
######################
25+
*.log
26+
*.sql
27+
*.sqlite
28+
29+
# OS generated files #
30+
######################
31+
.DS_Store
32+
.DS_Store?
33+
._*
34+
.Spotlight-V100
35+
.Trashes
36+
ehthumbs.db
37+
Thumbs.db
38+
39+
# OpenOffice lock files
40+
*.~lock*
41+
42+
# editor backup files
43+
*~
44+

Cisco/cisco-enable-syslog.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
configure terminal
2+
service timestamps log datetime
3+
logging host 10.0.6.33
4+
logging trap 5
5+
exit
6+
exit

Cisco/cisco-enablescp.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
configure terminal
2+
ip scp server enable
3+
exit
4+
exit

Cisco/cisco-sshkey.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
configure terminal
2+
no ip ssh pubkey-chain user tfletcher
3+
ip ssh pubkey-chain
4+
user tfletcher
5+
key-string
6+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/cHkrUc/BUWvWnhxDVlHyS9Qb1ioB3bFgF8mJsJkB5loIUB2xRu7HcHqDYH+H
7+
Lx4yIhTtQJeC3ArwiIH+hy9WXzWoJtGS4uoIYxNCEHAvq0WJZy+p9FqQzmLOQDEIg319JjITu4ypzDhKnmzAeXed54rV1dn9+z5q
8+
EwW2SAEp6P3qxSpvCIr0DHokAqFvGsjVGwULQUS63ajpEqaKhz/HXQzBGefz8VMHm5H1YACfzXaIw4At1Bs6fkTkULyUNuoHxuFV
9+
y+ltw9NJ8G2J/Lp3Hyhhw82au2QJc4heWcsqYD4iqQsdf2cZqgM8rJTYRcZ1Lb8fHsfQTjhpFku18dJ9 cardno:000603020768
10+
exit
11+
exit
12+
exit

Cisco/ios-backup.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
switches="missionas02.adm missionas06.adm missionas07.adm hadfieldas01.adm"
3+
coreswitches="missioncs01.adm missioncs02.adm"
4+
aps="missionap1.adm missionap2.adm"
5+
routers="missioncr01.adm custvpn1.wems.co.uk custvpn2.wems.co.uk"
6+
gpgbackupdir=$HOME/WEMS/Cisco/ios-backup
7+
gitbackupdir=$HOME/WEMS/infrastructure-configs/Cisco
8+
date=$(date +%s)
9+
gpgkey=E22C70C4
10+
username=tfletcher
11+
12+
echo -n "Cisco password: "
13+
stty -echo ; read SSHPASS ; stty echo
14+
export SSHPASS
15+
16+
for device in $coreswitches $switches $aps $routers ; do
17+
# Copy startup and running config to git repo
18+
mkdir -p $gitbackupdir/$device
19+
sshpass -e scp $username@$device:running-config $gitbackupdir/$device/running-config
20+
sshpass -e scp $username@$device:startup-config $gitbackupdir/$device/startup-config
21+
# Encrypt copy of config to Dropbox
22+
mkdir -p $gpgbackupdir/$device
23+
gpg -e -r $gpgkey --output $gpgbackupdir/$device/running-config-$date.gpg $gitbackupdir/$device/running-config
24+
gpg -e -r $gpgkey --output $gpgbackupdir/$device/startup-config-$date.gpg $gitbackupdir/$device/startup-config
25+
done
26+
27+
cd $gitbackupdir
28+
git add .
29+
git commit -m "Config backup from $(date)"
30+
git push

Cisco/ios-copy-sshkey.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
switches="missionas02.adm missionas03.adm missionas06.adm missionas07.adm missionas08.adm missionas09.adm missionas10.adm missioncs01.adm missioncs02.adm missioncs01.adm missioncs02.adm"
3+
aps="missionap1.adm missionap2.adm"
4+
routers="missioncr01.adm vpn2.wems.co.uk"
5+
backupdir=ios-backup
6+
7+
echo -n "Cisco password: "
8+
stty -echo ; read SSHPASS ; stty echo
9+
export SSHPASS
10+
11+
for device in $switches $aps $routers ; do
12+
mkdir -p $backupdir/$device
13+
cat cisco-enablescp.txt | sshpass -e ssh -o PubKeyAuthentication=no -T $device
14+
done

Cisco/ios-enable-scp.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
switches="missionas02.adm missionas03.adm missionas06.adm missionas07.adm missionas08.adm missionas09.adm missionas10.adm missioncs01.adm missioncs02.adm missioncs01.adm missioncs02.adm"
3+
aps="missionap1.adm missionap2.adm"
4+
routers="missioncr01.adm vpn2.wems.co.uk"
5+
6+
echo -n "Cisco password: "
7+
stty -echo ; read SSHPASS ; stty echo
8+
export SSHPASS
9+
10+
for device in $switches $aps $routers ; do
11+
mkdir -p $backupdir/$device
12+
cat cisco-enablescp.txt | sshpass -e ssh -o PubKeyAuthentication=no -T $device
13+
done

Cisco/ios-enable-syslog.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
switches="missionas02.adm missionas03.adm missionas06.adm missionas07.adm missionas08.adm missionas09.adm missionas10.adm missioncs01.adm missioncs02.adm missioncs01.adm missioncs02.adm"
3+
aps="missionap1.adm missionap2.adm"
4+
routers="missioncr01.adm vpn2.wems.co.uk"
5+
6+
echo -n "Cisco password: "
7+
stty -echo ; read SSHPASS ; stty echo
8+
export SSHPASS
9+
10+
for device in $switches $aps $routers ; do
11+
cat cisco-enable-syslog.txt | sshpass -e ssh -o PubKeyAuthentication=no -T $device
12+
done

Cisco/vpn-check.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
router=vpn2.wems.co.uk
3+
user=tfletcher
4+
key=
5+
vrfs=$(ssh -tt tfletcher@vpn2.wems.co.uk show vrf 2>/dev/null | grep 100:| awk '{print $1}')
6+
for vrf in $vrfs ; do
7+
count=$(ssh -tt $user@$router "show crypto session ivrf $vrf brief" 2>&1 | grep -c 'UA' )
8+
echo $vrf has $count sessions active
9+
done

Cisco/vpn-count.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
router=vpn2.wems.co.uk
3+
user=tfletcher
4+
key=
5+
crit=$3
6+
warning=$2
7+
count=$(ssh -tt $user@$router "show crypto session ivrf $1-vrf" 2>&1 | grep 'SAs:' | grep -cv 'SAs: 0' )
8+
if [ $crit -ge $count ] ; then
9+
echo Critial failure only $count SAs present
10+
exit 1
11+
elif [ $warning -ge $count ] ; then
12+
echo Warning only $count SAs present
13+
exit 1
14+
else
15+
echo $count SAs present
16+
exit 0
17+
fi

Cisco/vpn2-debug.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#1/bin/sh
2+
target=vpn2.wems.co.uk
3+
debug="ipsec isakmp engine"
4+
case $1 in
5+
on|enable)
6+
for item in $debug ; do
7+
echo debug crypto $item | ssh $target -tt
8+
done
9+
;;
10+
off|disable)
11+
for item in $debug ; do
12+
echo no debug crypto $item | ssh $target -tt
13+
done
14+
;;
15+
status)
16+
ssh $target show debug
17+
echo
18+
;;
19+
*)
20+
echo "$0 enable|disable|status"
21+
;;
22+
esac

Debian/cleanup-template.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -e
3+
histfiles="*.swp .bash_history .lesshst -.viminfo"
4+
5+
# Check we are running on a VMware box
6+
if [ ! vmware-checkvm ] ; then
7+
echo Are you sure this is an VMware system?
8+
exit 1
9+
elif [ $UID != 0 ] ; then
10+
echo Please run the script as root
11+
exit 1
12+
fi
13+
14+
# Fully upgrade the system, then clean out cached packges
15+
apt-get update
16+
apt-get -y dist-upgrade
17+
apt-get -y autoremove
18+
find /var/cache/apt -type f -print0 | xargs -0 --no-run-if-empty rm -v
19+
20+
# Delete history files from /root and /home
21+
for file in $histfiles ; do
22+
find /root /home -name "$file" -print0 | xargs -0 --no-run-if-empty rm -v
23+
done
24+
25+
# Stop rsyslog and delete all log files
26+
systemctl stop rsyslog.socket
27+
systemctl stop rsyslog
28+
find /var/log -type f -print0 | xargs -0 --no-run-if-empty rm -v

Debian/jessie-chroot.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
mirror=http://ftp.uk.debian.org/debian
3+
targetdir=/working/jessie-chroot
4+
distro=jessie
5+
6+
rm -rf $targetdir
7+
mkdir $targetdir
8+
9+
debootstrap --arch=armhf --foreign --variant=minbase --include=wget $distro $targetdir $mirror
10+

Debian/jigdo-update-testing.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# Script to update an existing iso to the latest version via Jigdo
3+
url=http://ftp.heanet.ie/mirrors/ftp.debian.org/debian-cd-weekly/amd64/jigdo-dvd
4+
basename=debian-testing-amd64-DVD-1
5+
target=/working/Debian
6+
7+
for file in iso template jigdo ; do
8+
mv ${target}/${basename}.${file} ${target}/${basename}.${file}.old
9+
done
10+
11+
for file in template jigdo ; do
12+
wget ${url}/${basename}.${file} -O ${target}/${basename}.${file}
13+
done
14+
15+
sudo mkdir -p /run/jigdo/${basename}
16+
sudo mount -o loop ${target}/${basename}.iso.old /run/jigdo/${basename}
17+
18+
cd ${target}
19+
jigdo-lite --scan /run/jigdo/${basename} ${basename}.jigdo
20+
sudo umount /run/jigdo/${basename}
21+
sudo rmdir -p /run/jigdo/${basename}

FIO/fio-config/fio_config-12-randrw-threads.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[global]
2-
ioengine=libaio
2+
ioengine=posixaio
33
group_reporting=1
44
iodepth=32 # How many IOs to keep in flight for each file
55
blockalign=4k

FIO/ioping

41.8 KB
Binary file not shown.

GRML/build-iso.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
keyboard=uk
3+
isosource=../grml64-full_testing_latest.iso
4+
isoout=../grml64-full_testing_latest_sshkeys.iso
5+
bootid=$(7z x -so $isosource conf/bootid.txt 2>/dev/null)
6+
sudo grml2iso -b "config ssh noswraid nodmraid nolvm read-only noeject noprompt noswap nofstab keyboard=$keyboard bootid=$bootid" -c overlay/ -o $isoout $isosource

GRML/disk-check.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
badblocks -s -w -v -b 4096 /dev/sd$1

GRML/disk-perf.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
smartctl -l scterc,70,70 /dev/sd$1
4+
hdparm -W 1 /dev/sd$1
5+
echo 1024 > /sys/block/sd$1/queue/nr_requests
6+
echo noop > /sys/block/sd$1/queue/scheduler
7+

GRML/grml-postboot.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
#export http_proxy=http://proxy:8080/
3+
apt-get update
4+
apt-get install sysstat

KVM/10gb-migrate.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
apollo=10.0.7.133
3+
cyclopes=10.0.7.135
4+
titan=10.0.7.137
5+
6+
case $1 in
7+
evacuate)
8+
echo "Full host evacuation requested, moving all VMs"
9+
vms="$(virsh list | grep running | awk '{print $2}')"
10+
;;
11+
*)
12+
vms="$1"
13+
;;
14+
esac
15+
16+
target=$(eval "echo \$${2}")
17+
18+
for vm in $vms ; do
19+
echo -n "Migration of $vm started to $target: "
20+
virsh migrate --live $vm qemu+ssh://$target/system tcp://$target/
21+
done

KVM/clone-xp.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
nfsbaseimage='/carbon/diskimages/Virtual Machines/Microsoft/WindowsXP-SP3-base.qcow2'
3+
baseimage='WindowsXP-SP3-base.qcow2'
4+
target=WindowsXP-SP3.img
5+
dir=/var/lib/libvirt/images
6+
7+
sudo rm -i $dir/$target
8+
sudo qemu-img create -f qcow2 -b "$dir/$baseimage" "$dir/$target"
9+

KVM/kvm-U3.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
# from printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))
3+
diskid=usb-_Patriot_Memory_070726A3A57F4937
4+
macaddress=DE:AD:BE:EF:87:6A
5+
arch=x86_64
6+
disk=/dev/disk/by-id/${diskid}-0:0
7+
8+
sudo umount /dev/disk/by-id/${diskid}*
9+
sync
10+
11+
sudo qemu-system-$arch \
12+
-m 1024 \
13+
-name U3 \
14+
-net nic,model=virtio,macaddr=$macaddress \
15+
-net tap,ifname=tap0,script=no,downscript=no \
16+
-drive file=$disk,if=virtio \
17+
-usb -usbdevice tablet \
18+
-localtime \
19+
-vga std $*
20+

KVM/kvm-bridge

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
# script to manage tap interface allocation
3+
# for linux kernels >= 2.6.18
4+
5+
# modified by bodhi.zazen from :
6+
# http://calamari.reverse-dns.net:980/cgi-bin/moin.cgi/FrequentlyAskedQuestions#head-2511814cb92c14dbe1480089c04f83c281117a86
7+
# http://ubuntuforums.org/showthread.php?t=528046
8+
# http://www.howtoforge.com/using-kvm-on-ubuntu-gutsy-gibbon
9+
10+
# set up a tap interface for qemu
11+
# USERID - uid qemu is being run under.
12+
USERID=`whoami`
13+
14+
# generate a random mac address for the qemu nic
15+
# shell script borrowed from user pheldens @ qemu forum
16+
17+
ranmac=$(echo -n DE:AD:BE:EF ; for i in `seq 1 2` ; \
18+
do echo -n `echo ":$RANDOM$RANDOM" | cut -n -c -3` ;done)
19+
20+
# specify which NIC to use - see qemu.org for others
21+
# model=r8169
22+
# Set model based on this how-to
23+
# http://www.howtoforge.com/using-kvm-on-ubuntu-gutsy-gibbon
24+
25+
model=rtl8139
26+
iface=`sudo tunctl -b -u $USERID`
27+
28+
# start kvm with our parameters
29+
# echo "Bringing up interface $iface with mac address $ranmac"
30+
# nohup added to allow kvm to run independent of the terminal
31+
nohup kvm -net nic,vlan=0,macaddr=$ranmac -net tap,vlan=0,ifname=$iface $@
32+
33+
# kvm has stopped - no longer using tap interface
34+
sudo tunctl -d $iface &> /dev/null

KVM/kvm-eSATA.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
# from printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))
3+
# diskid=usb-SanDisk_U3_Cruzer_Micro_08776011C691C3A5
4+
diskid=scsi-SATA_TOSHIBA_MK3252G_X8LBC388T
5+
macaddress=DE:AD:BE:EF:43:8C
6+
arch=x86_64
7+
disk=/dev/disk/by-id/${diskid}
8+
9+
sudo umount /dev/disk/by-id/${diskid}*
10+
sync
11+
12+
sudo qemu-system-$arch \
13+
-m 1024 \
14+
-name USBHDD \
15+
-net nic,model=virtio,macaddr=$macaddress \
16+
-net tap,ifname=tap0,script=no,downscript=no \
17+
-drive file=$disk,if=virtio,boot=on \
18+
-usb -usbdevice tablet \
19+
-localtime \
20+
-vga vmware $*

0 commit comments

Comments
 (0)