Tuesday, December 8, 2009

Poll .co.za domains for renewals.

Code is a bit clunky and can be improved upon , but I had to get this up and running after one of our providers forgot again to renew one of our domains.Put in a crontab to query nightly/weekly/monthtly.


#!/bin/bash

#########################################################################
# #
# Variables - Changeable #
# #
# #
#########################################################################


#Max amount of days before warning about lapse
warndays=30

#Domains to Query
domains="domain1.co.za domain2.co.za domain3.co.za"

#Monitor Email
emon="dnsmon@yourcompany.com"


########################################################################
# #
# #
# .CO.ZA Status Messages #
# #
# #
########################################################################
notpaid="NOTPAID"


#########################################################################
# #
# Variables - Non Changeable #
# #
# #
#########################################################################


#Variables
#Gets Todays Date
today=`date -d today +%s`


#########################################################################
# #
# #
# Run through the available domains and check if they're OK #
# #
# #
#########################################################################
clear


for d1 in $domains
do
echo "Now Processing $d1"
echo "Adding a pause on here so not to let .co.za think I am a robot"
let R=$RANDOM%60+180;echo $R
echo "Sleeping for $R"
sleep $R
whois $d1 > /tmp/$d1

#First check if account is not in arrears !
domainstatus=`egrep -i "\|" /tmp/"$d1" | tail -n 1 | cut -f 5 -d "|"| sed 's/[ \s]*//g'`


#Let's check if this domain has any unpaid fees
if [ "$domainstatus" = "$notpaid" ]
then
echo -e "\E[47;35m Domain $d1 has outstanding payments \033[0m"
echo -e `egrep -i "\|" /tmp/"$d1" | tail -n 1`
cat /tmp/"$d1" | mail "$emon" -s "Domain Outstanding Payments $d1"
echo
continue
fi

#Look at whether the PAID DATE field has a date in there
result=`egrep -i "\|" /tmp/$d1 | tail -n 1 | cut -f 5 -d "|"| sed 's/[ \s]*//g' | egrep '[0-9][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]'`
retval=$?

if [ "$retval" -lt 1 ]
then

#If domain seems to be paid let's continue and figure out when it will expire next year
regrenew=`egrep -i "\|" /tmp/"$d1" | tail -n 1 | cut -f 1 -d "|"| sed 's/[ \s]*//g'`
incyear=`echo $regrenew | cut -f 1 -d "-"`
incyear=`expr "$incyear" + 1`
suffixm=`echo $regrenew | cut -f 2 -d "-"`
suffixd=`echo $regrenew | cut -f 3 -d "-"`
regrenew="$incyear"-"$suffixm"-"$suffixd"
echo -e "New Domain date is \033[4m$regrenew \033[0m"

#Ok , now lets figure out how many days until we have until we have to re-register
registered=`date -d $regrenew +%s`
remaining=`expr "$registered" - "$today"`
remaining=`expr "$remaining" / 86400`
echo -e "\033[1mThere are $remaining days remaining before renewal \033[0m"
status=`egrep -i "\|" /tmp/"$d1" | tail -n 1`
echo $status


#Check if we have hit the warndays trigger
if [ $remaining -le $warndays ]
then
echo -e "Domain $d1 will expire in $remaining days ! ! ! \nPlease attend to this"| mail "$emon" -s "Domain Expiry $d1"

fi

fi

if [ "$retval" -gt 0 ]
then
echo -e "\E[47;35mThere is something wrong with your domain please inspect the following for any errors \033[0m"
echo -e `egrep -i "\|" /tmp/"$d1" | tail -n 1`
cat /tmp/"$d1" | mail "$emon" -s "Serious Domain Problem $d1"
fi


echo
echo
done

Tuesday, November 24, 2009

PHP Fatal error: Call to undefined function mb_detect_encoding() in /var/www/html/voiceone/admin/lib/gettext/i18n.php on line 85

Make sure php-mbstring is installed.

1)yum install php-mbstring
2)service httpd restart

Running System Calls from Asterisk

Example


exten => 5000,1,system(echo "${DATETIME} - ${CALLERID} - ${CHANNEL}" >> /var/log/asterisk/calls)

You can call asterisk through the command line to parse a command via

Example

asterisk -r -x "console dial 5000@context"

Saturday, November 21, 2009

Installing Asterisk on CentOS5

Either via Yum or Source

YUM
1)Create these files in /etc/repos.d

asterisk.repo

[asterisk-tested]
name=CentOS-$releasever - Asterisk - Tested
baseurl=http://packages.asterisk.org/centos/$releasever/tested/$basearch/
enabled=0
gpgcheck=0
#gpgkey=http://packages.asterisk.org/RPM-GPG-KEY-Digium

[asterisk-current]
name=CentOS-$releasever - Asterisk - Current
baseurl=http://packages.asterisk.org/centos/$releasever/current/$basearch/
enabled=1
gpgcheck=0
#gpgkey=http://packages.asterisk.org/RPM-GPG-KEY-Digium

Create digium.repo

[digium-tested]
name=CentOS-$releasever - Digium - Tested
baseurl=http://packages.digium.com/centos/$releasever/tested/$basearch/
enabled=0
gpgcheck=0
#gpgkey=http://packages.digium.com/RPM-GPG-KEY-Digium

[digium-current]
name=CentOS-$releasever - Digium - Current
baseurl=http://packages.digium.com/centos/$releasever/current/$basearch/
enabled=1
gpgcheck=0
#gpgkey=http://packages.digium.com/RPM-GPG-KEY-Digium



2)yum -y install asterisk16 asterisk16-configs asterisk16-voicemail dahdi-linux dahdi-tools libpri iksemel.i386 iksemel-devel.i386

OR


Source


path_root="/usr/src/asterisk"
filez=`ls -1 $path_root/*tar.gz`

mkdir /usr/src/asterisk
`cd $path_root`

wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.4.27.tar.gz
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/releases/dahdi-linux-complete-2.2.0.2+2.2.0.tar.gz
wget http://downloads.asterisk.org/pub/telephony/libpri/releases/libpri-1.4.10.2.tar.gz

for tarballs in $filez
do
clear
echo "Now Extracting ---- $tarballs"
sleep 1
#`tar -zxvf $tarballs -C $path_root`
tar -zxvf $tarballs -C $path_root
echo "Done"
sleep 1
done


#Now start compiling and installing packages

#Let's start off with DAHDI

cd dahdi-linux-complete*
echo "Now installing DAHDI HardWare Interface Drivers"
make && make install & make config && sleep 1
echo "DONE"
cd ..


#Let's install LibPRI
cd libpri*
echo "Now installing LibPRI"
make && make install
echo "DONE"
cd ..


#Install GTALK Modules
yum install iksemel.i386 iksemel-devel.i386

#Let's install Asterisk
cd asterisk-1.*
echo "Now installing Asterisk"
./configure && make && make menuselect && make install && make samples && make config && sleep 1
echo "DONE"
cd ..

Wednesday, November 4, 2009

Aide Notes

1)Creating the Database

aide -c /etc/aide.conf --init

2)Checking the Database against the current FS

aide -c /etc/aide.conf --check

3)Updating the Database after changes

aide -c /etc/aide.conf --update

Sunday, October 11, 2009

PureFTP w/ MySQL

1)yum install mysql mysql-server httpd php php-mysql php-mbstring pure-ftpd

chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

chkconfig --levels 235 httpd on
/etc/init.d/httpd start

2)mysqladmin -u root password *pwd*
mysqladmin -h server1.localhost.localdomain -u root password *pwd*

If you have CentOS 5 --> http://centos.karan.org/el4/misc/testing/i386/RPMS

3) groupadd -g 2001 ftpgroup
useradd -u 2001 -s /bin/false -d /bin/null -c "pureftpd user" -g ftpgroup ftpuser

mysql -u root -p

CREATE DATABASE pureftpd;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost' IDENTIFIED BY 'ftpdpass';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost.localdomain' IDENTIFIED BY 'ftpdpass';
FLUSH PRIVILEGES;
USE pureftpd;
CREATE TABLE ftpd (
User varchar(16) NOT NULL default '',
status enum('0','1') NOT NULL default '0',
Password varchar(64) NOT NULL default '',
Uid varchar(11) NOT NULL default '-1',
Gid varchar(11) NOT NULL default '-1',
Dir varchar(128) NOT NULL default '',
ULBandwidth smallint(5) NOT NULL default '0',
DLBandwidth smallint(5) NOT NULL default '0',
comment tinytext NOT NULL,
ipaccess varchar(15) NOT NULL default '*',
QuotaSize smallint(5) NOT NULL default '0',
QuotaFiles int(11) NOT NULL default 0,
PRIMARY KEY (User),
UNIQUE KEY User (User)
) TYPE=MyISAM;quit;

4)vi /etc/pure-ftpd/pure-ftpd.conf



ChrootEveryone yes
MySQLConfigFile /etc/pure-ftpd/pureftpd-mysql.conf
CreateHomeDir yes
5)vi /etc/pure-ftpd/pureftpd-mysql.conf

MYSQLSocket /var/lib/mysql/mysql.sock
#MYSQLServer localhost
#MYSQLPort 3306
MYSQLUser pureftpd
MYSQLPassword ftpdpass
MYSQLDatabase pureftpd
#MYSQLCrypt md5, cleartext, crypt() or password() - md5 is VERY RECOMMENDABLE uppon cleartext
MYSQLCrypt md5
MYSQLGetPW SELECT Password FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetUID SELECT Uid FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetGID SELECT Gid FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetDir SELECT Dir FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetQTASZ SELECT QuotaSize FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetQTAFS SELECT QuotaFiles FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")

6)mysql -u root -p
USE pureftpd;
INSERT INTO `ftpd` (`User`, `status`, `Password`, `Uid`, `Gid`, `Dir`,
`ULBandwidth`, `DLBandwidth`, `comment`, `ipaccess`, `QuotaSize`,
`QuotaFiles`) VALUES ('exampleuser', '1', MD5('secret'), '2001',
'2001', '/home/www.example.com', '100', '100', '', '*', '50', '0');


7)chkconfig --levels 235 pure-ftpd on
/etc/init.d/pure-ftpd start

Saturday, October 3, 2009

Vi Tips #2

Word Boundaries

:%s/\/testing123/g

BackReferences

Use \(\) to make backreferences

%s/\(specification\)/new \1/g

Thursday, October 1, 2009

Auto Yum Script to install all Deps for OCS Inventory Server and Agent

yum -y install perl-XML-Simple perl-DBI perl-DBD-MySQL perl-Apache-DBI perl-Net-IP perl-SOAP-Lite
yum -y install perl-XML-SAX
yum -y install perl-XML-SAX-Base
yum -y install perl-libwww-perl-5.805-1.1.1
yum -y install perl-Compress-Zlib
yum -y install perl-IO-Compress
yum -y install perl-Compress-Zlib
yum -y install perl-Net-CIDR
yum -y install perl-Test-Mock-LWP
yum -y install perl-Test-Mock-LWP
yum -y install perl-Daemon-Generic
yum -y install perl-Unix-PID.noarch
yum -y install perl-Proc-PID-File.noarch
yum -y install perl-Net-IPv4Addr.noarch
yum -y install perl-Net-Interface.i386
yum -y install perl-Net-IP-CMatch.i386
yum -y install perl-Net-IPv4Addr.noarch
yum -y install perl-Net-IPv6Addr.noarch
perl -MXML::SAX -e "XML::SAX->add_parser(q(XML::SAX::PurePerl))->save_parsers()"

/Zlib.pm conflicts between attempted installs of perl-IO-Compress- and perl-Compress-Zlib

Tested On - CentOS 5.1

Had this error come up when trying to install perl-IO-Compress

Resolved it by

1)yum update perl
2)yum -y install perl-Compress-Zlib
3)yum -y install perl-IO-Compress
4)yum -y install perl-Compress-Zlib

Wednesday, September 30, 2009

Could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.8/XML/SAX

I've setup a wonderful computer inventory management system called OCSReports . I initially had some errors when the agents tried to send reports to the server getting 5.0.0. responses from the server but that was solved by installing the perl-XML-SAX package through yum.

It solved the problem for me , but I kept getting this annoying error in the error logs in apache afterwards

"could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.8/XML/SAX"

I managed to fix it luckily by doing some googling and performing the following action

perl -MXML::SAX -e "XML::SAX->add_parser(q(XML::SAX::PurePerl))->save_parsers()"

Saturday, September 26, 2009

Squid error w/VideoCache

On a testbed server we got the following error

The Redirector helpers are crashing to rapidly, need help !

Solution

/usr/sbin/update-vc

This updates your system in accordance with the /etc/videocache.conf file.

Thursday, September 17, 2009

Sending SMS's from the linux console

We have a server running Call Monitoring and System/Link Monitoring , and we use SMS's to notify us when either a link/server goes down or when a call is logged.We use a package called SMS Server Tools 3 to send sms's to us.


Configuration is very easy , provided you have a kernel that can detect the 3G Modem you are attaching to the system.

Vi Tips

ctrl-a --> Will increment a number under your cursor
ctrl-x --> Will decrement a number under your cursor
1,$ /^#/d --> Delete any lines starting with hash
%s/poop/crap/ --> Search and replace entire file
%s/poop/crap/g --> Search and replace greedily
%s/poop/crap/gc --> Search and replace greedily with confirmation
%s/poop/crap/gi --> Search and replace greedily with case insensitivity

*When opening multiple files use :n and :rew

Wednesday, September 2, 2009

SNMPD not giving enough info on public queries

Tested On
CentOS 4.4

When you get the following message when doing a simple snmpwalk -v 1 -c public 192.168.X.X

SNMPv2-MIB::sysDescr.0 = STRING: Linux squidbox 2.6.29.3 #2 SMP Sat May 16 15:03:06 SAST 2009 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (679) 0:00:06.79
SNMPv2-MIB::sysContact.0 = STRING: Root (configure /etc/snmp/snmp.local.conf)
SNMPv2-MIB::sysName.0 = STRING: squidbox
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (1) 0:00:00.01
SNMPv2-MIB::sysORID.1 = OID: IF-MIB::ifMIB
SNMPv2-MIB::sysORID.2 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.3 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.4 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.5 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.6 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.7 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.8 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.9 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB module to describe generic objects for network interface sub-layers
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.3 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.6 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORDescr.7 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.8 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.9 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (1) 0:00:00.01
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (1) 0:00:00.01
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (1) 0:00:00.01
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (1) 0:00:00.01
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (1) 0:00:00.01
SNMPv2-MIB::sysORUpTime.9 = Timeticks: (1) 0:00:00.01
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (569973) 1:34:59.73
End of MIB

1)Try this ; The default restrictions might be a bit too restrictive


In /etc/snmp/snmpd.conf change

view systemview included .1.3.6.1.2.1.1
to
view systemview included .1.3.6.1.2.1

Sunday, June 21, 2009

Sendmail : Put in a size restriction

Tested On CentOS 5 - Sendmail 8.13.8

1)Edit sendmail.mc

Add the following

define(`confMAX_MESSAGE_SIZE', `5000')


2)m4 sendmail.mc > sendmail.cf


Sunday, June 7, 2009

Creating a Custom Error SQUID

Tested On-CentOS 4.4 w/ Custom SQUID 3.0.STABLE15


1)Add the following entries

deny_info ERR_AUTH_PROXY ntlm_users #ntlm_users is my NTLM Authentication acl , change it to whatever you configured it with.

2)On the filesystem create the following file and add the customized entries

/usr/local/squid/share/errors/templates/ERR_AUTH_PROXY

3)Restart squid , or check with squid -d 1 if the entries are good.

Saturday, May 30, 2009

Weird Samba Error when upgrading SAMBA

So I've been trying to upgrade SAMBA , but I keep getting this error.I've downloaded SAMBA , from samba.org and use the RHEL /packaging/RHEL/makerpms.sh to try and upgrade it , and I would constantly get this error.


Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1


RPM build errors:
File not found: /var/tmp/samba-3.3.4-root/usr/sbin/cifs.upcall
File not found by glob: /var/tmp/samba-3.3.4-root/usr/share/man/man8/cifs.upcall.8.*
makerpms.sh: Done.

The solution was to install the keyutils-devel package

1)yum install keyutils-devel

Tuesday, May 26, 2009

Samba - Act as a domain controller

Tested on Samba - Samba Version 3.0.10-1.4E.9


1)Put in the following changes in Samba

workgroup = MYGROUP # This will be the Domain Name
netbios name = HOSTNAME
server string = Samba Server %v %h
security = user
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
unix password sync = yes

passwd program = /usr/bin/passwd %u
passwd chat = *New*password* %n\n *Please*retype*new*password* %n\n *password*successfully*updated*


local master = yes

os level = 64

domain master = yes

preferred master = yes

domain logons = yes

logon drive = P:

logon script = netlogon.bat

#=== shares ===
[homes]
comment = Home Directories
browseable = no
writable = yes
valid users = %S
create mode = 0664
directory mode = 0775

[netlogon]
comment = Network Logon Service
path = /home/samba/netlogon
writable = no
share modes = no

[Profiles]
path = /home/samba/profiles
browseable = no


2)Adding the appropriate directories

groupadd -g 300 admins
groupadd -g 301 machines

groupadd -g 302 users

mkdir -m 0775 -p /home/samba/netlogon
chown root.admins /home/samba/netlogon
mkdir /home/samba/profiles

3)Add machine + User accounts

Change the default shell in /etc/default/useradd and change the SHELL=/sbin/nologin

useradd -g machines -d /dev/null computer$

passwd -l computer$

smbpasswd -a -m computer

useradd -g users -d /home/samba/profiles/userx userx

passwd userx

smbpasswd -a userx


Add a Samba account for root , used to join the network

smbpasswd -a root


4)Run testparm -v , and if OK restart

SQUID - Traffic Management via Delay Pools

Tested ON - Centos 4 SQUID 3

1)Build SQUID with delay pool options

./configure --enable-delay-pools

2)Configure squid with the following options

delay_pools 1
delay_class 1 2
delay_access 1 allow localnet
delay_parameters 1 64000/64000 32000/32000 16000/16000

3)Restart and test squid

Saturday, May 16, 2009

SQUID - Allowing internet traffic to go through a different gateway

Tested - CentOS 5- Custom iptables 1.4.1

1)iptables -t mangle -I OUTPUT -m owner --uid-owner squid -j MARK --set-mark 0x1

2)iptables-save > /etc/sysconfig/iptables

3)edit /etc/iproute2/rt_tables and add a line:
101 squid

4)/etc/sysconfig/network-scripts/rule-eth0:
fwmark 0x1 table 101 pref 1000

/etc/sysconfig/network-scripts/route-eth0:
default via 10.0.0.2 dev eth0 table 101

*You can do this manually:
/sbin/ip rule add fwmark 0x1 table 101 pref 101
/sbin/ip route add default via 10.0.0.2 dev eth0 table 101



5)Restart network service

service network restart

6)Check that the ip rules

ip route list table 101
ip rule show

SQUID - Allow Access via Mac Access

Tested On CentOS 4 w/ custom compiled squid SQUID 3.0

1)Configure squid with the following options

/configure --enable-arp-acl

2)make
3)make install
4)If you have a init.d script configure it for bootup , copy and configure it otherwise do some /etc/rc.local magic
5)Edit /usr/local/squid/etc/squid.conf

acl ACLARP arp "/usr/local/squid/etc/mac.conf"

*Put this before your localnets config

http_access deny !ACLARP


6)Edit the
/usr/local/squid/etc/mac.conf file

11:12:13:14:15:16

7)Stop and restart squid

service squid restart
service squid start
or whatever other method


8)Test

Sunday, May 10, 2009

BASH Shorten Scripts

I tend to write a lot of scripts , that have IF or CASE clauses depending on the return code that the command returns.

An easier way to shorten some of these clauses are with the trap command.Here are some that you can use


[root@media ~]# trap -l

1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE
9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2
13) SIGPIPE 14) SIGALRM 15) SIGTERM 17) SIGCHLD
18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN
22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO
30) SIGPWR 31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1
36) SIGRTMIN+2 37) SIGRTMIN+3 38) SIGRTMIN+4 39) SIGRTMIN+5
40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8 43) SIGRTMIN+9
44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13
52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9
56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6 59) SIGRTMAX-5
60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2 63) SIGRTMAX-1
64) SIGRTMAX


A short example

trap "rm -f -R /tmp/myfiles" EXIT

Which will delete a directory and its contents if an EXIT condition is met.

Sunday, May 3, 2009

Creating a Ethernet/Wireless Bridge

We have a proxy server connected to both the wireless and wired segments that share the same network segment.This makes it possible for it to serve both wireless and wired clients.

1)Install bridge-utils -> yum install bridge-utils
2)Create the following files

/etc/sysconfig/network-scripts/ifcfg-br0

DEVICE=br0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.100.90
NETMASK=255.255.255.0
GATEWAY=192.168.100.254
ONBOOT=yes
TYPE=Bridge


/etc/sysconfig/network-scripts/ifcfg-ath0

DEVICE=ath0
ONBOOT=yes
BOOTPROTO=static
BRIDGE=br0


/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
ONBOOT=yes
TYPE=Ethernet
BRIDGE=br0


3)Restart network service -> service network restart
4)Test that its working -> brctl show

Saturday, May 2, 2009

SQUID - Save money and bandwidth caching streaming video sites with VideoCache

Tested ON - CentOS 5 - Squid 2.6

One problem we face is , people browsing the internet during lunchtime and using a lot of bandwidth in the process of doing so.

What we've noticed is that they go to youtube/break.com and watch a video . If they enjoy the video , the forward the url to the coworkers and the problem gets a lot worse because these videos are never cached on the squid system.

We've been using VideoCache(http://cachevideos.com/) with a lot of success recently.Configration and installation is a breeze

1)yum install python-iniparse
2) wget http://cachevideos.com/sites/default/files/pub/videocache/videocache-1.9.0.noarch.rpm (This will change as new releases come out so get the latest version if possible)
3)rpm -i videocache-1.9.0.noarch.rpm
4)Added the following directives to my squid.conf file

# --BEGIN-- videocache config for squid
url_rewrite_program /usr/bin/python /usr/share/videocache/videocache.py
url_rewrite_children 7
acl videocache_allow_url url_regex -i \.youtube\.com\/get_video\?
acl videocache_allow_url url_regex -i \.googlevideo\.com\/videoplayback \.googlevideo\.com\/videoplay \.googlevideo\.com\/get_video\?
acl videocache_allow_url url_regex -i \.google\.com\/videoplayback \.google\.com\/videoplay \.google\.com\/get_video\?
acl videocache_allow_url url_regex -i \.google\.[a-z][a-z]\/videoplayback \.google\.[a-z][a-z]\/videoplay \.google\.[a-z][a-z]\/get_video\?
acl videocache_allow_url url_regex -i (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/videoplayback\?
acl videocache_allow_url url_regex -i (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/videoplay\?
acl videocache_allow_url url_regex -i (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/get_video\?
acl videocache_allow_url url_regex -i proxy[a-z0-9\-][a-z0-9][a-z0-9][a-z0-9]?\.dailymotion\.com\/
acl videocache_allow_url url_regex -i vid\.akm\.dailymotion\.com\/
acl videocache_allow_url url_regex -i [a-z0-9][0-9a-z][0-9a-z]?[0-9a-z]?[0-9a-z]?\.xtube\.com\/(.*)flv
acl videocache_allow_url url_regex -i bitcast\.vimeo\.com\/vimeo\/videos\/
acl videocache_allow_url url_regex -i va\.wrzuta\.pl\/wa[0-9][0-9][0-9][0-9]?
acl videocache_allow_url url_regex -i \.files\.youporn\.com\/(.*)\/flv\/
acl videocache_allow_url url_regex -i \.msn\.com\.edgesuite\.net\/(.*)\.flv
acl videocache_allow_url url_regex -i media[a-z0-9]?[a-z0-9]?[a-z0-9]?\.tube8\.com\/ mobile[a-z0-9]?[a-z0-9]?[a-z0-9]?\.tube8\.com\/
acl videocache_allow_url url_regex -i \.mais\.uol\.com\.br\/(.*)\.flv
acl videocache_allow_url url_regex -i \.video[a-z0-9]?[a-z0-9]?\.blip\.tv\/(.*)\.(flv|avi|mov|mp3|m4v|mp4|wmv|rm|ram)
acl videocache_allow_url url_regex -i video\.break\.com\/(.*)\.(flv|mp4)
acl videocache_allow_dom dstdomain .mccont.com dl.redtube.com .cdn.dailymotion.com
acl videocache_deny_url url_regex -i http:\/\/[a-z][a-z]\.youtube\.com http:\/\/www\.youtube\.com
url_rewrite_access deny videocache_deny_url
url_rewrite_access allow videocache_allow_url
url_rewrite_access allow videocache_allow_dom
redirector_bypass on
# --END-- videocache config for squid

5)Changed the following parameters in the /etc/videocache.conf

cache_host = 192.168.1.254
proxy = http://192.168.1.254:3128/
base_dir = /var/spool/videocache/:4000

6)Restart SQUID -> service squid restart

7)Look if it is working -> tail -f /var/log/videocache/videocache.log

Squid Tips

TESTED ON:Centos 5 - SQUID 2.6

Here are some very basic squid tips

1)Improve the Maximum Cache Size (By default the cache is rather small.Improve this to match the specifications of your hardware/partitions

cache_dir ufs /var/squid/cache 20000 16 256

2)Improve the Maximum Object File Size (The standard is 4M . My coworkers regularly access large photos online bigger than this size)

maximum_object_size 12288 KB

3)Maximize RAM Cached Files

cache_mem 64 MB

First Post

Hi this is CentOS Files.In here , this is my personal howto on certain CentOS server functions.

Followers