sandip's blog

Enabling quotas for users

Check to make sure the quota package is installed, else run:

# yum install quota


Edit "/etc/fstab" and add "usrquota,grpquota" to the / partition:

LABEL=/    /    ext3    defaults,usrquota,grpquota    1 1


Then run:

# mount -o remount /
# quotacheck -avugm
# quotaon -avugm


To check quotas for all users:
# repquota -a


To edit quota for a particular user:
# edquota -u <user>


Alternately use setquota:
# setquota <softlimit> <hardlimit> 0 0 <user>

Creating LVM partitions.

After creating a new partition (/dev/hda5) with fdisk run the below commands:

# partprobe
# pvcreate /dev/hda5
# vgcreate vg0 /dev/hda5
# lvcreate -L 1G -n lv0 vg0
# mke2fs -j /dev/vg0/lv0

Extending LVM

Extend partition by 1Gb.

# lvresize -L +1G /dev/vg00/lvol0
# e2fsck -f /dev/vg00/lvol0
# resize2fs -pf /dev/vg00/lvol0


Notes:

  • resize2fs has replaced ext2online in FC6.
  • need to unmount volume prior to doing resize2fs.

Restoring corrupt rpm database

If you have a corrupt rpm database, simply delete the db files and rebuild it again.

# rm -rf /var/lib/rpm/*db.*
# rpm --rebuilddb

New Hosting Server Checklist

Below are some basic guidelines on setting up new hosting servers. This is only a point of reference to begin with and you should know what you are doing, else it is highly advisable to get an expert to work on setting up and securing the server:

Synopsis:

  • Scan server with tools such as netstat, nmap, nessus etc...
  • Disable services not required.
  • Remove packages not required.
  • Update all other packages.
  • Secure Incoming and Outgoing ports.
  • Move SSH to a different port and disable direct root login.
  • Enable Antidos and BruteForce Detection.
  • Scan for rootkits and setup daily reporting.
  • Secure tmp and tmpfs.
  • Secure binaries, paths and profiles.
  • Secure Apache and PHP, and cofigure to expose minimum info about the applications used.
  • Secure Ftp via TLS/SSL connection.
  • ...

Host Networking on VirtualBox

This is how I got host networking for VirtualBox and have it setup to use bridging on FedoraCore 6 host. This allows for two way traffic between the host and the guest. You will need bridge-utils and uml-utilities.

The first step is to configure the host with a bridge and a tap device. With this only the bridge will get an IP address and not the ethX nor the tapX device.

I am using dhcp to assign the IP addresses so the basic commands on the host are as below and can be put in the rc.local file for it to come up on boot:

# VirtualBox Bridging

# load the tun module
modprobe tun

# Create a tap device with permission for the user running vbox
tunctl -t tap0 -u {user}
chmod 666 /dev/net/tun

# Bring up ethX and tapX in promiscuous mode
ifconfig eth0 0.0.0.0 promisc
ifconfig tap0 0.0.0.0 promisc

# Create a new bridge and add the interfaces to the bridge.
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 tap0

# Give the bridge a dhcp address.
dhclient br0

You should now be able to use host networking in VirtualBox, just change "attached to" to "host interface" and add the interface name of "tap0" in your networking settings for the guest.

Notes:

If you're using a firewall on your host, make sure to turn it off when testing network setup.
I have had success with using APF as firewall which seems compatible with bridging.

References:

  1. VirtualBox
  2. Bridge
  3. uml-utilities
  4. 2.6.6 UML setup

Preparing and presenting video for the web...

Recently, I've had to convert a 15 minute infomercial for BetterDaysMinistries.org, a non-profit organization. I was provided with a dvd, that cycled the infomercial twice during playback. Besides, the phone number and address shown on the original infomercial was old and that information needed to be updated. Below are highlights of the whole conversion process.

Migrating sites between DirectAdmin servers

These are some basic notes for reference just in case I need to do the migration thing again!!!

Steps taken on the old server

  1. Created a new reseller account.

  2. Created sites in the new reseller account as domain.com2 for the domains that needed to be migrated. DA won't let you add the same name twice, which is why I used a different one for the time being. Doing this will setup all the required files/paths needed to use the website.

  3. Copied the files to the new domain.
    # cp -pR /home/olduser/domains/domain.com/* /home/newuser/domains/domain.com2/
    # chown -R newuser:newuser /home/newuser/domains/domain.com2
  4. Did a search for the old file path and updated it to the new file path.
    # for x in `find /home/newuser/domains/*/public_html -type f -print0 | xargs --null grep -l /home/olduser`; do perl -pi.bak -e 's/\/home\/olduser/\/home\/newuser/g' $x ; done
  5. Swapped around the the email folders.
    # cd /etc/virtual
    # mv domain.com domain.com.tmp
    # mv domain.com2 domain.com
    # mv domain.com.tmp domain.com2
  6. Copied over the imap files. Any data in /home/olduser/imap needed to be copied over. There will also be permission issues as well, but can be fixed afterwards with the set_permissions.sh script.

  7. Changed user for the imap files.
    # find /home/newuser/imap -user olduser | xargs chown newuser:newuser
  8. Renamed the existing domains with a suffix of ".old".

  9. Renamed the new domains to domain.com from domain.com2.

  10. Logged in as reseller and created a backup.

  11. Created a script and dumped out single databases.
    #!/bin/bash
    # dbExport.sh

    OLD_DB=(
    db1
    db2
    db3
    ...
    )

    for ((i=0; i<${#OLD_DB[@]}; i++))
    do
      mysqldump --opt -u root --password={psswd} ${OLD_DB[$i]} > ./db/${OLD_DB[$i]}.db
    done
  12. Did a search and created a list of folders with 777 permission set.
    # find /home/newuser/domains -perm 0777 -type d > 777.txt
  13. Setup dns for each domain with a www1 A record to point to the new server IP. Better solution, would be to edit the local hosts file for testing purpose.

Nepalese NGO Releases Localised Open CD

In its on going efforts to bring the power of FOSS based technologies to the mountainous asian nation of Nepal, the Madan Puraskar Pustakalaya has released a localised version of the Open CD.

The Open CD is a project to create a collection of FOSS applications that run on the Windows platform, from Open Office to Firefox and beyond.

Localized Free and Open Source Software, Nepali Open CD 1.0

Madan Puraskar Pustakalaya (MPP) has released the Nepali OpenCD 1.0 in January 9, 2007. The Nepali OpenCD 1.0 is a compilation of free and open source software localized into Nepali and runnable in the Windows operating system and developed by Madan Puraskar Pustakalaya. After the release of two different versions of NepaLinux, a localized Linux Distribution in Nepali, the development of the Nepali OpenCD 1.0 is yet another attempt of Madan Puraskar Pustakalaya for promoting the usage of localized Free and Open Source Software in the region. With the existing old legacies of the Windows operating system deeply rooted in the masses, the localized OpenCD is believed to be a motivating factor for switching to the Free and Open Source Software. The translation and localization of the software has been supported by the International Development and Research Centre, Canada under the PAN Localization Project.

Contents of the Nepali OpenCD

The localized Nepali OpenCD consists of the following software:
1.OpenOffice.org Suite (Office applications like Writer,Calc,Impress,Base etc.);
2.SeaMonkey Browser and Mail client (Browser and mail client);
3.Gimp (Image Manipulation Software);
4.FileZilla - 3(FTP Client Program for uploading and downloading files);
5.VLC Media Player (Software for playing audio video files);
6.Nepali Unicode Keyboard driver (Input System for Nepali).

Pre-requisites for running the software included in the OpenCD after installation

In order to run the software included in the OpenCD after installation, the Nepali Unicode Keyboard driver, also included in the OpenCD has to be installed first in the computer.

Both the Open CD and its sister project Nepalinux can be found at nepalinux.org

Serving files from a folder outside the web root with mod_rewrite

I was serving static content within a drupal installation, which became a huge nightmare when doing upgrades. So, I decided, I should just create a symbolic link to a folder outside the installation and route the traffic via mod_rewrite rules.

I first created a folder called "/var/www/site_files" and then symlinked to it from "/var/www/html/site_files". This way, I just have to recreate one single symbolic link after doing the upgrades.

With the below rules, I was able to maintain the links to the existing pages.

  ## BEGIN: site_files ##
  # Redirect to the homepage if site_files is being called
  RewriteRule ^site_files/?$ http://%{HTTP_HOST}/ [L,R=301]
  # Apped / at the end of url, if directory is being called without /
  RewriteCond %{REQUEST_URI} !^/?$
  RewriteCond %{DOCUMENT_ROOT}/site_files%{REQUEST_URI} -d
  RewriteRule ^(.+[^/])$ /$1/ [R=301,L]
  # Get directory or file if exists in site_files directory
  RewriteCond %{REQUEST_URI} !^/$
  RewriteCond %{DOCUMENT_ROOT}/site_files%{REQUEST_URI} -d [OR]
  RewriteCond %{DOCUMENT_ROOT}/site_files%{REQUEST_URI} -f
  RewriteRule ^(.*)$ site_files/$1 [L]
  ## END: site_files ##

Syndicate content
Comment