Monday, April 12, 2010

CentOS Kernel Compiling Problem

Been a long while since I've done this shite ;)

Error:
make[2]: *** [scripts/kconfig/lxdialog/checklist.o] Error 1


Solution:

1)yum install ncurses-devel

Monday, April 5, 2010

PostgreSQL Reminders

Creating A User,Database and Assigning him Rights.

1)adduser test
2)su - postgres
3)psql template1
4)CREATE USER test WITH PASSWORD 'test';
5)create database testdb;
6)GRANT ALL PRIVILEGES ON DATABASE testdb to test;
7)\q
8)exit
9)su - test
$ psql testdb

Changing a password for a user

1)ALTER ROLE test WITH PASSWORD 'testing123';

Getting a list of databases

1)\l

Backing up Databases.

- Backup a certain database

pg_dump testdb > test.sql

- Backup All Databases
pg_dumpall > sql_all.sql

Restore a Database from a backup

1)drop database test
2)create database test
3)psql test < test.sql

Show tables in a database

1)\d table_name

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

Followers