Script to generate interface configs on Linux

Wednesday, September 16th, 2009

Generate ifcfg-eth1 307-366 configs.

touch ifcfg-eth1:{307..366}
for f in ifcfg-eth1:{307..366}; do cat origfile > “$f”; done
for f in eth1:{307..366}; do echo “DEVICE=$f” >> “ifcfg-$f”; done
for f in {307..366}; do echo “IPADDR=aaa.bbb.ccc.$((f-239))” >> “ifcfg-eth1:$f”; done

origfile contains:

GATEWAY=eee.fff.ggg.hhh
TYPE=Ethernet
BOOTPROTO=none
NETMASK=255.255.255.192

Installing perl audio converter

Wednesday, August 5th, 2009

Download the latest version of pacpl from:

Download PACPL from http://pacpl.sourceforge.net/

install cpan, either with yum,apt..

Install these cpan modules:

cpan install Ogg::Vorbis::Header
cpan install Inline::MakeMaker
cpan install MP3::Tag
cpan install Audio::FLAC::Header
cpan install MP4::Info
cpan install Audio::WMA
cpan install Audio::Musepack
cpan install CDDB_get

Untar the pacpl source and move the binary into /usr/bin and the share/pacpl files into /usr/share/pacpl, also the config file (pacpl.conf) should be in /etc/pacpl/

To convert from .caf to mp3 use:

pacpl –to mp3 file.caf

cpio and rpm2cpio howto

Thursday, June 18th, 2009

To extract a cpio file:

cpio -iv < cpio_file

To list the contents of a cpio file:

cpio -itv < cpio_file

To create a cpio file with all files in the current directory:

ls | cpio -o > cpio_file

To extract all files from an RPM:

rpm2cpio RPM_file | cpio -idv

To extract individual file(s) from an RPM:

rpm2cpio RPM_file | cpio -id individual_file(s)

e.g. Extracting libcrypto.so.0.9.7a and libssl.so.0.9.7a from openssl-0.9.7a-2.i386.rpm:

rpm2cpio openssl-0.9.7a-2.i386.rpm | cpio -it egrep “libcrypto.so.0.9.7a|libssl.so.0.9.7a”

-rwxr-xr-x 1 root root 992092 Feb 27 12:10 ./lib/libcrypto.so.0.9.7a
-rwxr-xr-x 1 root root 216004 Feb 27 12:10 ./lib/libssl.so.0.9.7a

rpm2cpio openssl-0.9.7a-2.i386.rpm | cpio -idv ./lib/libssl.so.0.9.7a ./lib/libcrypto.so.0.9.7a

This will extract the two files from the RPM into a ./lib subdirectory.

Multiple gcc versions

Thursday, June 18th, 2009

Lets say you have this package from FC11:

[root@localhost ~]# rpm -q gcc
gcc-4.4.0-4.i586

But you have an source code that needs gcc-4.3 to compile or something lower.

So download lets say this: gcc-4.3.2-7.i386.rpm then:

mkdir newgcc && cd newgcc
download http://pathtogcc/gcc-4.3.2-7.i386.rpm
rpm2cpio gcc-4.3.2-7.i386.rpm | cpio -idv

Now you should have in newgcc/usr/bin/gcc.

Or download the gcc package you need from ftp://ftp.gnu.org and compile it with –prefix=$HOME/newgcc

Download RPMs with yum

Thursday, June 18th, 2009

Under Fedora and Centos:

[root@infra ~]# yum install yum-downloadonly

Be sure /etc/yum.conf contains : plugins=1

[root@infra ~]# yum reinstall gcc –downloadonly –downloaddir=/root
Loaded plugins: downloadonly
Setting up Reinstall Process
Resolving Dependencies
–> Running transaction check
—> Package gcc.i386 0:4.1.2-33 set to be updated
—> Package gcc.i386 0:4.1.2-33 set to be erased
–> Finished Dependency Resolution

Dependencies Resolved

Installing:
gcc i386 4.1.2-33 fedora 5.2 M
Removing:
gcc i386 4.1.2-33 installed 9.6 M

Transaction Summary

Install 1 Package(s)
Update 0 Package(s)
Remove 1 Package(s)

Total download size: 5.2 M
Is this ok [y/N]: y
Downloading Packages:
gcc-4.1.2-33.i386.rpm | 5.2 MB 00:00

exiting because –downloadonly specified

Now /root should contain : gcc-4.1.2-33.i386.rpm

Bandwidth Monitoring with Webmin

Wednesday, June 17th, 2009

I have Fedora 8 on this server..to install webmin:

yum -y install perl-Net-SSLeay
rpm -ihv http://superb-west.dl.sourceforge.net/sourceforge/webadmin/webmin-1.480-1.noarch.rpm

Then login to the Webmin interface: https://site.com:10000/ and enable Networking -> Bandwidth Monitoring.
It uses iptables and reads counters for IN/OUT. A good practice would be to change the port. This should work on Centos 5.2 / Centos 5.3 too. Also keep in mind that default installations of Fedora or Centos might require to open port 10000. On this Fedora 8 I had to :

iptables -I RH-Firewall-1-INPUT -p tcp -m state –state NEW -m tcp –dport 10000 -j ACCEPT
service iptables save

How to upgrade MySQL 5.0 to MySQL 5.1 cPanel

Sunday, June 14th, 2009

How to upgrade MySQL 5.0 to MySQL 5.1 in a cPanel server

Login as root and edit /var/cpanel/cpanel.config.

Replace :

mysql-server=5.0 with
mysql-server=5.1

Finally run: /scripts/mysqlup