Sometimes it is necessary to check whether server you want to run some big bash script is connected to Internet. Usually it makes sense while running scripts periodically using cron. Below is the tiny bash script for this purpose:
#!/bin/bash
WGET="/usr/bin/wget"
$WGET -q --tries=10 --timeout=5 http://www.google.com -O /tmp/index.google &> /dev/null
if [ ! -s /tmp/index.google ];then
echo "no"
else
echo "yes"
fi
As you see it tries to download google’s index page, if it’s not empty script returns “yes”, if there is not Internet connection available script will return “no”. If it is impossible to fetch the page in more than 5 seconds script will return “no” as well.
Windows and linux information and one stop centre for myself. Having difficulties to remember all things at once. This blog will remain be my references on the internet. Other people can take benefit from it. Thank you for visiting
Monday, May 11, 2009
Limit bandwidth with squid
acl magicwords url_regex -i .rpm .exe .iso .avi .mp3 .tar.gz .tar
delay_pools 1
delay_class 1 2
delay_parameters 1 5000/15000 5000/15000
delay_access allow magicwords
this will limit the bandwidth to 5 Kbps when the download reach 15 Kbps or more
thanks for squid cache guy
delay_pools 1
delay_class 1 2
delay_parameters 1 5000/15000 5000/15000
delay_access allow magicwords
this will limit the bandwidth to 5 Kbps when the download reach 15 Kbps or more
thanks for squid cache guy
Who's behind linux?
| What/who you imagine when you hear the names "Ubuntu", "Debian", "Slackware", etc? Is this tux, penguin, disribution logo? Have you ever wondered who is behind certain Linux distribution? From Ian's blog: Debian was one of the first Linux distributions and arguably the first open source project that explicity set out to be developed in a decentralized fashion by a group of volunteers. Today, over 1,000 volunteers are involved in Debian's development, and there are millions of Debian users worldwide. I can pay, however, because ten years ago when I was still studying at the University of Cape Town in South Africa… Linux allowed me to compete with the best companies in the world, without any obstacles between me and success. That made me a billionaire; so I could fly into space and do many other wonderful things. It was clear for me that Linux had the potential to be an excellent alternative to Windows, or maybe even a full replacement, and at the time I thought that it would be good to provide a Linux distribution that would be as easy to use as Windows. Linux is my big fun project right now - gets pretty crazy sometimes trying to keep up with all of the development going on; for instance, last week the new C libraries, GCC, and kernel were all released within a couple days of each other. Luckily, I like keeping my machine current. Judging from the mail I get when things fall a bit behind, so does everyone else. Daniel in 2007: The logic is as follows: it is impossible to write a kernel module without it being a derivative work of the kernel, which is GPL, so in turn the module itself must be distributed under the terms of the GPL and thus cannot be binary-only/proprietary in nature.To be continued… |
Sunday, May 10, 2009
Saturday, May 9, 2009
Squid from malaysia network only
| Hmm.. sorry to say.. i have ran an open proxy for a years to create a caches between my server and my school's LAN because of leak network bandwidth supplied by GITN. Someone at JPN's forum laughing at me for doing this but it's just fine maybe they have no clue about it. The Websense Enterprise used by GiTN guys for cache and filters the usage does make a sense. As far as i know they are running up to upgrade their network. For me the squid cache does improve web browsing but i cannot compare how effectively using the squid or websense because i never try it ( i'm not using windows as a server )..rather use then nothing.. i did it as a parent peer for my lab ( Luckily i have my own server ). From now i have decided to close my open proxy for malaysian use only.. here what i did Get the network list from http://www.ipdeny.com/ipblocks/data/countries/my.zone edit /etc/squid/squid.conf and add : ---------------- START ------------------------- acl my1 src 58.26.0.0/16 58.27.0.0/17 58.71.128.0/17 58.139.0.0/16 acl my2 src 60.48.0.0/14 60.52.0.0/15 60.54.0.0/16 acl my3 src 61.4.96.0/20 61.4.112.0/20 61.6.0.0/17 61.6.128.0/18 61.11.208.0/20 acl my4 src 110.4.40.0/21 110.74.128.0/18 110.159.0.0/16 acl my5 src 112.137.160.0/20 acl my6 src 113.21.128.0/19 113.23.128.0/17 113.210.0.0/15 113.212.108.0/22 acl my7 src 114.133.0.0/16 acl my8 src 115.132.0.0/14 115.146.96.0/20 115.164.0.0/16 acl my9 src 116.0.96.0/19 116.197.0.0/17 116.206.0.0/16 acl my10 src 118.100.0.0/15 118.107.192.0/18 acl my11 src 119.40.112.0/20 119.110.0.0/18 119.110.96.0/20 119.110.128.0/17 119.161.96.0/21 acl my12 src 120.50.48.0/20 120.138.80.0/20 120.139.0.0/16 120.140.0.0/15 acl my13 src 121.120.0.0/15 121.122.0.0/15 acl my14 src 122.0.16.0/20 122.255.96.0/19 acl my15 src 123.136.96.0/19 acl my16 src 124.13.0.0/16 124.82.0.0/16 124.158.224.0/19 124.195.128.0/20 124.197.224.0/19 124.217.224.0/19 acl my17 src 144.199.0.0/16 acl my18 src 161.139.0.0/16 161.142.0.0/16 acl my19 src 170.38.0.0/16 acl my20 src 192.228.128.0/24 192.228.129.0/24 192.228.130.0/24 192.228.131.0/24 192.228.132.0/22 192.228.136.0/22 acl my21 src 192.228.140.0/24 192.228.141.0/24 192.228.142.0/24 192.228.143.0/24 192.228.144.0/24 192.228.145.0/24 acl my22 src 192.228.146.0/24 192.228.147.0/24 192.228.148.0/24 192.228.149.0/24 192.228.150.0/24 192.228.151.0/24 acl my23 src 192.228.152.0/24 192.228.153.0/24 192.228.154.0/24 192.228.155.0/24 192.228.156.0/24 192.228.157.0/24 acl my24 src 192.228.158.0/24 192.228.159.0/24 192.228.160.0/24 192.228.161.0/24 192.228.162.0/24 192.228.163.0/24 acl my25 src 192.228.164.0/24 192.228.165.0/24 192.228.166.0/24 192.228.167.0/24 192.228.168.0/24 192.228.169.0/24 acl my26 src 192.228.170.0/23 192.228.172.0/23 192.228.174.0/24 192.228.175.0/24 192.228.176.0/24 192.228.177.0/24 acl my27 src 192.228.178.0/24 192.228.179.0/24 192.228.180.0/22 192.228.184.0/22 192.228.188.0/22 192.228.192.0/24 acl my28 src 192.228.193.0/24 192.228.194.0/24 192.228.195.0/24 192.228.196.0/24 192.228.197.0/24 192.228.198.0/24 acl my29 src 192.228.199.0/24 192.228.200.0/22 192.228.204.0/23 192.228.206.0/24 192.228.207.0/24 192.228.208.0/23 acl my30 src 192.228.210.0/24 192.228.211.0/24 192.228.212.0/24 192.228.213.0/24 192.228.214.0/24 192.228.215.0/24 acl my31 src 192.228.216.0/23 192.228.218.0/24 192.228.219.0/24 192.228.220.0/24 192.228.221.0/24 192.228.222.0/24 acl my32 src 192.228.223.0/24 192.228.224.0/20 192.228.240.0/21 192.228.248.0/24 192.228.249.0/24 192.228.250.0/24 acl my33 src 192.228.251.0/24 192.228.252.0/22 acl my34 src 202.0.94.0/24 202.9.96.0/20 202.21.148.0/24 202.45.132.0/22 202.45.136.0/21 202.46.112.0/20 202.47.160.0/19 acl my35 src 202.56.80.0/20 202.58.80.0/20 202.60.56.0/22 202.71.96.0/20 202.73.8.0/21 202.75.4.0/22 202.75.32.0/20 acl my36 src 202.75.48.0/20 202.75.128.0/19 202.75.160.0/19 202.75.240.0/21 202.76.224.0/20 202.83.120.0/21 202.87.216.0/21 acl my37 src 202.94.160.0/20 202.122.144.0/20 202.129.160.0/20 202.133.96.0/20 202.137.252.0/22 202.144.192.0/20 acl my38 src 202.146.64.0/20 202.146.80.0/20 202.151.192.0/18 202.162.0.0/19 202.165.0.0/19 202.168.64.0/20 202.169.24.0/21 acl my39 src 202.170.48.0/20 202.171.32.0/20 202.171.48.0/20 202.171.192.0/20 202.176.12.0/24 202.176.13.0/24 202.178.0.0/19 acl my40 src 202.178.32.0/19 202.178.64.0/20 202.179.96.0/19 202.184.0.0/15 202.186.0.0/15 202.188.0.0/22 202.188.4.0/22 acl my41 src 202.188.8.0/21 202.188.16.0/20 202.188.32.0/19 202.188.64.0/18 202.188.128.0/18 202.188.192.0/18 202.190.0.0/16 acl my42 src 202.191.0.0/24 202.191.128.0/17 acl my43 src 203.10.16.0/21 203.12.220.0/24 203.62.1.0/24 203.78.192.0/20 203.80.16.0/21 203.82.64.0/19 203.92.128.0/19 acl my44 src 203.99.136.0/22 203.106.0.0/18 203.106.64.0/18 203.106.128.0/20 203.106.144.0/20 203.106.160.0/19 acl my45 src 203.106.192.0/18 203.109.32.0/19 203.112.224.0/19 203.115.192.0/20 203.115.208.0/20 203.115.224.0/19 acl my46 src 203.119.57.0/24 203.121.0.0/19 203.121.32.0/19 203.121.64.0/18 203.142.32.0/19 203.148.88.0/22 203.153.16.0/21 acl my47 src 203.153.80.0/20 203.158.24.0/21 203.161.32.0/19 203.176.144.0/21 203.188.232.0/21 203.189.16.0/21 acl my48 src 203.201.182.0/24 203.201.184.0/22 203.215.60.0/22 203.223.128.0/19 acl my49 src 210.5.40.0/21 210.19.0.0/17 210.19.128.0/17 210.48.144.0/20 210.48.192.0/20 210.48.216.0/21 210.186.0.0/17 acl my50 src 210.186.128.0/17 210.187.0.0/17 210.187.128.0/17 210.195.0.0/16 acl my51 src 211.24.0.0/17 211.24.128.0/17 211.25.0.0/16 acl my52 src 218.100.18.0/24 218.100.22.0/24 218.100.44.0/24 218.100.58.0/24 218.111.0.0/16 218.208.0.0/16 acl my53 src 219.92.0.0/15 219.94.0.0/17 219.95.0.0/16 acl my54 src 221.133.32.0/21 221.133.40.0/21 http_access allow my1 http_access allow my2 http_access allow my3 http_access allow my4 http_access allow my5 http_access allow my6 http_access allow my7 http_access allow my8 http_access allow my9 http_access allow my10 http_access allow my11 http_access allow my12 http_access allow my13 http_access allow my14 http_access allow my15 http_access allow my16 http_access allow my17 http_access allow my18 http_access allow my19 http_access allow my20 http_access allow my21 http_access allow my22 http_access allow my23 http_access allow my24 http_access allow my25 http_access allow my26 http_access allow my27 http_access allow my28 http_access allow my29 http_access allow my30 http_access allow my31 http_access allow my32 http_access allow my33 http_access allow my34 http_access allow my35 http_access allow my36 http_access allow my37 http_access allow my38 http_access allow my39 http_access allow my40 http_access allow my41 http_access allow my42 http_access allow my43 http_access allow my44 http_access allow my45 http_access allow my46 http_access allow my47 http_access allow my48 http_access allow my49 http_access allow my50 http_access allow my51 http_access allow my52 http_access allow my53 http_access allow my54 #deny all lah! http_access deny all --------------------- END -------------- save and exit restart squid FUYOH!!!! lenguh tangan aku taip... |
Automatic Email Notification When Security Upgrades Available
| LOL.. i didn't notice that in debian ( maybe in other also try it ) there is an application which check the available updates and email us a notification called "APTICRON". here's what i did:- aptitude install apticron then.. edit /etc/apticron/apticron.conf change the EMAIL="root" to EMAIL="your@domain.com" you're done! the script in /etc/cron.daily/apticron will do the rest /etc/init.d/cron restart to active |
Restore zimbra backup
#!/bin/bash
domain="@my.domain"
backupdir="/root/backup/users"
if [ $# -ne 2 ]; then
echo "Usage: $0 account [reset, skip]"
exit 1
fi
case "$2" in
reset)
OPTION="reset"
;;
skip)
OPTION="skip"
;;
*)
echo "Usage: $0 account [reset, skip]"
exit 3
esac
echo "Start to restore => `date`"
echo -n "Check account [$1] ==> "
sudo -u zimbra /opt/zimbra/bin/zmprov ga $1$domain > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "NO, [$1] not exist"
exit 2
else
echo "Yes, we have [$1]"
fi
echo -n "Check backup data for [$1] ==> "
if [ ! -e $backupdir/$1.tgz ]; then
echo "No, no backup data for [$1]"
exit 3
else
echo "Yes, backup data for [$1] exists"
fi
echo -n "Start to restore user [$1] ==> "
sudo -u zimbra /opt/zimbra/bin/zmmailbox -z -m $1$domain postRestURL "//?fmt=tgz&resolve=$OPTION" $backupdir/$1.tgz
if [ $? -eq 0 ]; then
echo "OK"
else
echo "Fail"
fi
echo "Restore finish => `date`"
domain="@my.domain"
backupdir="/root/backup/users"
if [ $# -ne 2 ]; then
echo "Usage: $0 account [reset, skip]"
exit 1
fi
case "$2" in
reset)
OPTION="reset"
;;
skip)
OPTION="skip"
;;
*)
echo "Usage: $0 account [reset, skip]"
exit 3
esac
echo "Start to restore => `date`"
echo -n "Check account [$1] ==> "
sudo -u zimbra /opt/zimbra/bin/zmprov ga $1$domain > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "NO, [$1] not exist"
exit 2
else
echo "Yes, we have [$1]"
fi
echo -n "Check backup data for [$1] ==> "
if [ ! -e $backupdir/$1.tgz ]; then
echo "No, no backup data for [$1]"
exit 3
else
echo "Yes, backup data for [$1] exists"
fi
echo -n "Start to restore user [$1] ==> "
sudo -u zimbra /opt/zimbra/bin/zmmailbox -z -m $1$domain postRestURL "//?fmt=tgz&resolve=$OPTION" $backupdir/$1.tgz
if [ $? -eq 0 ]; then
echo "OK"
else
echo "Fail"
fi
echo "Restore finish => `date`"
Zimbra backup all users
#!/bin/bash
domain="@my.domain"
backupdir="/root/backup/users"
echo "Start to backup => `date`"
if [ ! -d $backupdir ]; then
echo "$backupdir not existing, create it now automatically"
mkdir -p $backupdir
fi
index=1
sudo -u zimbra /opt/zimbra/bin/zmprov gaa |
while read line; do
echo -n "[$index]backup user : $line..."
username=`echo $line | cut -d@ -f1`
sudo -u zimbra /opt/zimbra/bin/zmmailbox -z -m $line getRestURL "//?fmt=tgz" > $backupdir/$username.tgz
if [ $? -eq 0 ]; then
echo "OK [`du -h $backupdir/$username.tgz | awk '{print $1}'`]"
else
echo "Fail"
fi
index=`expr $index + 1`
done
echo "Backup finish => `date`"
domain="@my.domain"
backupdir="/root/backup/users"
echo "Start to backup => `date`"
if [ ! -d $backupdir ]; then
echo "$backupdir not existing, create it now automatically"
mkdir -p $backupdir
fi
index=1
sudo -u zimbra /opt/zimbra/bin/zmprov gaa |
while read line; do
echo -n "[$index]backup user : $line..."
username=`echo $line | cut -d@ -f1`
sudo -u zimbra /opt/zimbra/bin/zmmailbox -z -m $line getRestURL "//?fmt=tgz" > $backupdir/$username.tgz
if [ $? -eq 0 ]; then
echo "OK [`du -h $backupdir/$username.tgz | awk '{print $1}'`]"
else
echo "Fail"
fi
index=`expr $index + 1`
done
echo "Backup finish => `date`"
Getting mysql root password for zimbra
I have to....
Must...
Felt guilty...
do this to get zimbra mysql password
/opt/zimbra/bin/zmlocalconfig -s | grep mysql | grep password
then what?
/opt/zimbra/bin/mysql -uroot -p -P 7306
waaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Must...
Felt guilty...
do this to get zimbra mysql password
/opt/zimbra/bin/zmlocalconfig -s | grep mysql | grep password
then what?
/opt/zimbra/bin/mysql -uroot -p -P 7306
waaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Subscribe to:
Comments (Atom)
Simple Python Calculator This script will allows your to calculate the integers given with the chosen operation. You can add, substract, mu...
-
when trying to apt-get update i got this error message :- W: There is no public key available for the following key IDs xxxxxxxxxxxx t...
-
Skrip ini aku guna kat server aku.. backup mysql setiap hari. Hanya perlu ubah pada bahagian setting sahaja. chmod dan set cron untuk daily ...
-
This tutorial will help you get AWStats and Lighttpd working together. AWStats is an excellent log analyzer, and works well with Lighttpd. T...