Friday, May 25, 2012

DAViCal Installation on Ubuntu Server (12.04 LTS)


Step1:
Installed Ubuntu Server and update it to latest
added to source list
vim /etc/apt/sources.list
deb http://debian.mcmillan.net.nz/debian lenny awm
then added the key
apt-key advanced --keyserver pgp.net.nz --recv-keys F6E0FA5CF0307507BB23A512EAFCFEBF8FEB8EBF
apt-get install update
apt-get install apache2
apt-get install davical

Configuring Database (Postgresql)

now added the Postgresql sersver to connect the machines
vim /etc/postgresql/9.1/main/pg_hba.conf

Connecting to the Database
Before your database has been created, you should edit your pg_hba.conf file (in /etc/postgresql/8.x/main/pg_hba.conf on Debian or derivatives) in order to grant access to the database for the 'davical_dba' user that will be created to 'own' the database and tables, and also for the 'davical_app' user which will be created for the web application fo connect as.

In a simple installation, where you do not have untrusted users on your database server, and your database is on the same computer as the web server, the following lines (at the very top of the pg_hba.conf file) should be enough:

local   davical    davical_app   trust
local   davical    davical_dba   trust
This means that anyone on the local computer (including the web application) will have rights to connect to the DAViCal database as the 'davical_app' or 'davical_dba' user. It will not allow remote access, or access as any user other than 'davical_app' or 'davical_dba'.

If you want to connect to the database over TCP/IP from your webserver on '192.168.59.231' (e.g. rather than unix sockets which will only work for access from the local machine), the lines in the pg_hba.conf file should look something like:

host davical davical_app 192.168.59.231/32 trust
host davical davical_dba 192.168.59.231/32 trust

Creating and Building the Database
To create the database itself, run the script:

This script expects to be running as a user who has rights to create a new database, so you may need to do this as the "postgres" user, for example:

su postgres -c /usr/share/davical/dba/create-database.sh

#####
su postgres -c /usr/share/davical/dba/create-database.sh
could not change directory to "/root"
could not change directory to "/root"
could not change directory to "/root"
could not change directory to "/root"
could not change directory to "/root"
could not change directory to "/root"
could not change directory to "/root"

could not change directory to "/root"

Supported locales updated.
Updated view: dav_principal.sql applied.
CalDAV functions updated.
RRULE functions updated.
Database permissions updated.
could not change directory to "/root"
could not change directory to "/root"
NOTE
====
*  The password for the 'admin' user has been set to 'ioMLrYKQ'
#########


Now configuring Apache:

cd /etc/apache2/sites-available/
make copy of default website
cp default mydavicalsite

vim mydavicalsite
<VirtualHost 192.168.1.195:80 >
  DocumentRoot /usr/share/davical/htdocs
  DirectoryIndex index.php index.html
  ServerName madrid.hcitec.com
  Alias /images/ /usr/share/davical/htdocs/images/
  <Directory /usr/share/davical/htdocs/>
      AllowOverride None
      Order allow,deny
      Allow from all
  </Directory>
  AcceptPathInfo On
  php_value include_path /usr/share/awl/inc
  php_value magic_quotes_gpc 0
  php_value register_globals 0
  php_value error_reporting "E_ALL & ~E_NOTICE"
  php_value default_charset "utf-8"
</VirtualHost>

sudo ln -s /etc/apache2/sites-available/mydavicalsite /etc/apache2/sites-enabled/mydavicalsite

/etc/init.d/apache2 restart

Recived error while restarting apache2
Invalid command 'php_value'
Then I did
sudo apt-get install libapache2-mod-php5

service apache2 restart
Now it give information about the product installation

DAViCal Configuration
The DAViCal configuration generally resides in /etc/davical/config.php and is a regular PHP file which sets (or overrides) some specific variables. if not then create this file and paste the below in the file

<?php
//  $c->domain_name  = 'davical.example.com';
//  $c->sysabbr     = 'davical';
//  $c->system_name = 'DAViCal CalDAV Server';

  $c->admin_email  = 'admin@example.com';
  $c->pg_connect[] = 'dbname=davical user=davical_app';
OR
<?php
  $c->admin_email = 'vaseemk@hcitec.com';
  $c->system_name = "DAViCal CalDAV Server";
  $c->enable_row_linking = true;
  $c->default_locale = 'en_US.UTF-8';

  $c->pg_connect[] = 'dbname=davical port=5432 user=davical_app';

Now you can get DAViCal running on your server
http://yourserver/
and log in

  Resources:
  http://www.davical.org/installation.php
  http://wiki.davical.org/w/Debian
  http://ubuntuguide.org/wiki/DAViCal_tips

Wednesday, May 9, 2012

Linux Directory Structure (File System Structure) Explained with Examples


Have you wondered why certain programs are located under /bin, or /sbin, or /usr/bin, or /usr/sbin?
For example, less command is located under /usr/bin directory. Why not /bin, or /sbin, or /usr/sbin? What is the different between all these directories?
In this article, let us review the Linux filesystem structures and understand the meaning of individual high-level directories.

1. / – Root

  • Every single file and directory starts from the root directory.
  • Only root user has write privilege under this directory.
  • Please note that /root is root user’s home directory, which is not same as /.

2. /bin – User Binaries

  • Contains binary executables.
  • Common linux commands you need to use in single-user modes are located under this directory.
  • Commands used by all the users of the system are located here.
  • For example: ps, ls, ping, grep, cp.

3. /sbin – System Binaries

  • Just like /bin, /sbin also contains binary executables.
  • But, the linux commands located under this directory are used typically by system aministrator, for system maintenance purpose.
  • For example: iptables, reboot, fdisk, ifconfig, swapon

4. /etc – Configuration Files

  • Contains configuration files required by all programs.
  • This also contains startup and shutdown shell scripts used to start/stop individual programs.
  • For example: /etc/resolv.conf, /etc/logrotate.conf

5. /dev – Device Files

  • Contains device files.
  • These include terminal devices, usb, or any device attached to the system.
  • For example: /dev/tty1, /dev/usbmon0

6. /proc – Process Information

  • Contains information about system process.
  • This is a pseudo filesystem contains information about running process. For example: /proc/{pid} directory contains information about the process with that particular pid.
  • This is a virtual filesystem with text information about system resources. For example: /proc/uptime

7. /var – Variable Files

  • var stands for variable files.
  • Content of the files that are expected to grow can be found under this directory.
  • This includes — system log files (/var/log); packages and database files (/var/lib); emails (/var/mail); print queues (/var/spool); lock files (/var/lock); temp files needed across reboots (/var/tmp);

8. /tmp – Temporary Files

  • Directory that contains temporary files created by system and users.
  • Files under this directory are deleted when system is rebooted.

9. /usr – User Programs

  • Contains binaries, libraries, documentation, and source-code for second level programs.
  • /usr/bin contains binary files for user programs. If you can’t find a user binary under /bin, look under /usr/bin. For example: at, awk, cc, less, scp
  • /usr/sbin contains binary files for system administrators. If you can’t find a system binary under /sbin, look under /usr/sbin. For example: atd, cron, sshd, useradd, userdel
  • /usr/lib contains libraries for /usr/bin and /usr/sbin
  • /usr/local contains users programs that you install from source. For example, when you install apache from source, it goes under /usr/local/apache2

10. /home – Home Directories

  • Home directories for all users to store their personal files.
  • For example: /home/john, /home/nikita

11. /boot – Boot Loader Files

  • Contains boot loader related files.
  • Kernel initrd, vmlinux, grub files are located under /boot
  • For example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic

12. /lib – System Libraries

  • Contains library files that supports the binaries located under /bin and /sbin
  • Library filenames are either ld* or lib*.so.*
  • For example: ld-2.11.1.so, libncurses.so.5.7

13. /opt – Optional add-on Applications

  • opt stands for optional.
  • Contains add-on applications from individual vendors.
  • add-on applications should be installed under either /opt/ or /opt/ sub-directory.

14. /mnt – Mount Directory

  • Temporary mount directory where sysadmins can mount filesystems.

15. /media – Removable Media Devices

  • Temporary mount directory for removable devices.
  • For examples, /media/cdrom for CD-ROM; /media/floppy for floppy drives; /media/cdrecorder for CD writer

16. /srv – Service Data

  • srv stands for service.
  • Contains server specific services related data.
  • For example, /srv/cvs contains CVS related data.

Awesome Cron Job Examples


Awesome Cron Job Examples:


Linux Crontab Format

MIN HOUR DOM MON DOW CMD
Table: Crontab Fields and Allowed Ranges (Linux Crontab Syntax)
FieldDescriptionAllowed Value
MINMinute field0 to 59
HOURHour field0 to 23
DOMDay of Month1-31
MONMonth field1-12
DOWDay Of Week0-6
CMDCommandAny command to be executed.

1. Scheduling a Job For a Specific Time Every Day

The basic usage of cron is to execute a job in a specific time as shown below. This will execute the Full backup shell script (full-backup) on 10th June 08:30 AM.

Please note that the time field uses 24 hours format. So, for 8 AM use 8, and for 8 PM use 20.
30 08 10 06 * /home/ramesh/full-backup
  • 30 – 30th Minute
  • 08 – 08 AM
  • 10 – 10th Day
  • 06 – 6th Month (June)
  • * – Every day of the week

2. Schedule a Job For More Than One Instance (e.g. Twice a Day)

The following script take a incremental backup twice a day every day.

This example executes the specified incremental backup shell script (incremental-backup) at 11:00 and 16:00 on every day. The comma separated value in a field specifies that the command needs to be executed in all the mentioned time.
00 11,16 * * * /home/ramesh/bin/incremental-backup
  • 00 – 0th Minute (Top of the hour)
  • 11,16 – 11 AM and 4 PM
  • * – Every day
  • * – Every month
  • * – Every day of the week

3. Schedule a Job for Specific Range of Time (e.g. Only on Weekdays)

If you wanted a job to be scheduled for every hour with in a specific range of time then use the following.

Cron Job everyday during working hours

This example checks the status of the database everyday (including weekends) during the working hours 9 a.m – 6 p.m
00 09-18 * * * /home/ramesh/bin/check-db-status
  • 00 – 0th Minute (Top of the hour)
  • 09-18 – 9 am, 10 am,11 am, 12 am, 1 pm, 2 pm, 3 pm, 4 pm, 5 pm, 6 pm
  • * – Every day
  • * – Every month
  • * – Every day of the week

Cron Job every weekday during working hours

This example checks the status of the database every weekday (i.e excluding Sat and Sun) during the working hours 9 a.m – 6 p.m.
00 09-18 * * 1-5 /home/ramesh/bin/check-db-status
  • 00 – 0th Minute (Top of the hour)
  • 09-18 – 9 am, 10 am,11 am, 12 am, 1 pm, 2 pm, 3 pm, 4 pm, 5 pm, 6 pm
  • * – Every day
  • * – Every month
  • 1-5 -Mon, Tue, Wed, Thu and Fri (Every Weekday)