Skip to content

Instantly share code, notes, and snippets.

View ChatchaiJ's full-sized avatar

Chatchai Jantaraprim ChatchaiJ

View GitHub Profile
@ChatchaiJ
ChatchaiJ / ftp-debian-mirror-state
Created December 8, 2015 07:39
Get debian mirror status for CoE ftp from DMC -- debian mirror check!
#!/usr/bin/perl -w-
# --------------------------------------------------------------------- #
# ftp-debian-mirror-state Get debian mirror status for CoE ftp #
# from DMC -- debian mirror check! #
# #
# version 0.2 - cj (2007-08-14) fixed up version. #
# version 0.3 - cj (2010-01-25) change site name from #
# ftp.coe.psu.ac.th to ftp.th.debian.org. #
# version 0.4 - cj (2010-01-29) no proxy needed. Transparent proxy is #
@ChatchaiJ
ChatchaiJ / mirrorstate
Created December 8, 2015 07:36
Check debian mirror state, keep in log file, and also sending mail to admins.
#!/bin/sh
# --------------------------------------------------------------------- #
# mirrorstate - Check debian mirror state, keep in log file, and also #
# sending mail to admins. #
# #
# version 0.1 - cj (2010-05-14) also monitor other up/down stream #
# push mirror. #
# version 0.1a - cj (2011-05-30) add ftp.jp.debian.org to the list. #
# version 0.1b - cj (2013-03-23) add ftp.kr.debian.org to the list. #
@ChatchaiJ
ChatchaiJ / dmtc.sh
Created December 8, 2015 07:27
Debian Mirror Trace Check
#!/bin/bash
# --------------------------------------------------------------------- #
# dmtc - Debian Mirror Trace Check #
# Check projects/trace directory in debian's mirror to #
# see which mirror has more up-to-date data. #
# #
# version 0.1 - cj (2013-05-17) init. #
# version 0.2 - cj (2013-05-17) some bug fixed. #
# version 0.2a - cj (2013-05-18) archive in progress detection added. #
@ChatchaiJ
ChatchaiJ / dmesg-datestamp.sh
Created December 8, 2015 07:26
Show dmesg in time/date stamp like in system log.
#!/bin/sh
# --------------------------------------------------------------------- #
# dmesg-datestamp - Show dmesg in time/date stamp like in system #
# log. Since my brain can't interpret uptime #
# that well. #
# #
# version 0.1 - cj (2013-03-25) init. #
# --------------------------------------------------------------------- #
@ChatchaiJ
ChatchaiJ / debmirror-checkspeed.sh
Created December 8, 2015 07:23
Check Debian Mirror Speed
#!/bin/bash
SITES="
ftp.th.debian.org
ftp.kr.debian.org
ftp.jp.debian.org
ftp.tw.debian.org
ftp.nz.debian.org
ftp.debianclub.org
mirror1.ku.ac.th
@ChatchaiJ
ChatchaiJ / buildvdimage.sh
Created December 8, 2015 07:20
Build raw disk image for VirtualBox and install debian system on it
#!/bin/bash
# --------------------------------------------------------------------- #
# buildvdimage - Build raw disk image for VirtualBox and install #
# debian system on it. So we can start using the new #
# virtual machine immediately without to install and #
# configure that system manually. #
# #
# Part of this script was modified from #
# http://blog.quinthar.com/2008/07/ #
@ChatchaiJ
ChatchaiJ / psuautosigned.sh
Created December 8, 2015 07:10
Signed-in with PSU Login to access internet
#!/bin/sh
# --------------------------------------------------------------------- #
# psuautosigned Signed-in with PSU Login to access internet. #
# #
# version 0.1 - cj (2010-06-11) modified from engautosign-3 #
# version 0.1a - cj (2010-06-14) read login/password from user #
# if any of them doesn't provide from $CONF #
# version 0.1b - cj (2010-06-15) uses of function bug fixed. #
# thanks to aj. Panyarak for this. #
@ChatchaiJ
ChatchaiJ / install-changetrack
Created December 8, 2015 07:00
Install changetrack on debian/ubuntu host
#!/bin/bash
# --------------------------------------------------------------------- #
# install-changetrack - Install changetrack on debian/ubuntu host. #
# #
# version 0.1 - cj (2010-08-24) init. #
# --------------------------------------------------------------------- #
ADMIN="sysadmin@localhost"
CONF="/etc/changetrack.conf"
@ChatchaiJ
ChatchaiJ / drop-unuse-mysql-database.sh
Created December 8, 2015 06:58
Drop unused students' database
#!/bin/bash
MYSQLDIR="/var/lib/mysql"
cd $MYSQLDIR
LIST=$( find . -maxdepth 1 -type d -mtime +365 -print |\
sed -e 's/^\.\///' |\
grep ^s4 )
for d in $LIST; do
echo "drop database $d;"
@ChatchaiJ
ChatchaiJ / ban-ip-ssh-attack
Created December 8, 2015 06:55
Using iptable to filter ip that try to guess root's and other account's password
#!/usr/bin/perl -w-
# --------------------------------------------------------------------- #
# ban-ip-ssh-attack - using iptable to filter ip that try to #
# guess root's and other account's password. #
# #
# version 0.1 - cj (2005-05-05) initial version. #
# version 0.2 - cj (2005-05-09) working version. #
# version 0.3 - cj (2005-05-31) takasila version. #
# --------------------------------------------------------------------- #