Thursday, August 20, 2009

Reiserfs setup on centos + squid cache partition

#! /bin/bash
# squid cache folder assumed mounted with some other FS .
echo " "
if [ -d "/usr/local/squid" ] ;then

rpm -Uvh /root/reiserfs-utils-3.6.19-2.4.1.i386.rpm
rpm -Uvh /root/
locca=`df -lh |grep -r 'cache' |cut -d " " -f 1`
if [ "$locca" == "" ] ;then
echo "cache Partition not mounted"
umount $locca
mkreiserfs -q $locca
echo "ReiserFS partion done"
mv /usr/local/squid/var/cache /usr/local/squid/var/cache.bak
mkdir -p /usr/local/squid/var/cache

mount -t reiserfs $locca /usr/local/squid/var/cache
echo "Mounted successfully"
mv /usr/local/squid/var/cache.bak/* /usr/local/squid/var/cache/
chown -R squid:squid /usr/local/squid/var/cache
chmod -R 0750 /usr/local/squid/var/cache
echo "cache setup done"
grep -Ev 'cache' /etc/fstab >/etc/newfstab
mv /etc/fstab /etc/fstab.bakup && cp /etc/fstab.bakup /etc/fstab.bakup.original
echo " $locca /usr/local/squid/var/cache reiserfs notail,noatime 1 2" >>/etc/newfstab
mv /etc/newfstab /etc/fstab
echo "fstab updated with new mount info "
echo "Exiting squid not found "

echo "Cool you must reboot the system to take effect "

No comments: