วันพฤหัสบดีที่ 16 ธันวาคม พ.ศ. 2553

iphone

http://stackoverflow.com/questions/1058880/can-iphone-send-gps-coordinates-to-a-website-painlessly


up vote

7

down vote

accepted

Please login or register to vote for this post.

(click on this box to dismiss)

Here's a snippet on how to read location from the iPhone. Looks like it requires 3.0:



navigator.geolocation.getCurrentPosition(foundLocation, noLocation);



function foundLocation(position)

{

var lat = position.coords.latitude;

var long = position.coords.longitude;

alert('Found location: ' + lat + ', ' + long);

}

function noLocation()

{

alert('Could not find location');

}

See: http://mapscripting.com/how-to-use-geolocation-in-mobile-safari



By the way, if you want to use web code on the iPhone, there are a couple middle-ground solutions you could try that don't force you to create a native app but allow you to wrap your site in an app and get access to GPS and other native features.



PhoneGap: http://phonegap.com/

Appcelerator: http://www.appcelerator.com/products/titanium-mobile/

link
flag

วันจันทร์ที่ 13 ธันวาคม พ.ศ. 2553

Clone hard disk ubuntu

Clone your Ubuntu installation onto a new hard disk




Wednesday, 07 May 2008 12:54 Linux.com



By Keir Thomas



This article is excerpted from the newly published book Ubuntu Kung Fu and published with the express permission of the publisher, the Pragmatic Programmers, LLC.



Three things must be done. First, you must discover how Ubuntu refers to the hard disks. Second, you must install ddrescue and then use it to clone the disk. Third, once ddrescue has finished, you must use the Gparted utility to expand the disk partition(s) (assuming that the new disk is bigger than the old one, which is almost certainly going to be the reason for upgrading in the first place).



It's not a good idea to clone a hard disk that's in use (any more than it's a good idea to repair a car while it's being driven), so you must use your Ubuntu install CD's live distro mode. To carry out the following instructions, boot from your Ubuntu install CD, and select Try Ubuntu from the boot menu.



Note that all the following stages are carried out using the Ubuntu install CD's live distro mode. At no point in the process do you need to boot into your standard Ubuntu installation, apart from to test the cloned disk at the end.



Preparing to clone



Before starting, it's a good idea to do three things in preparation. First, back up all valuable personal files to CD/DVD-R/RW disc, a USB keystick, or an external hard disk. The instructions that follow involve drastic fundamental disk management and the possibility of data loss.



Second, it's a good idea to check the filesystem of the original hard disk for errors and possibly enact repairs. Ideally, you should check the Windows filesystem for errors too.



Third, remove any USB memory sticks, card readers, or other kinds of attachable storage, such as MP3 players or mobile phones. This will avoid confusion when partitioning.



After all this, open a terminal window, and type the command sudo fdisk -l, which will scan the hard disks and list their partitions. Here are the results from my test system:



Disk /dev/sda: 81.9 GB, 81964302336 bytes

255 heads, 63 sectors/track, 9964 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0x1c381c37

Device Boot Start End Blocks Id System

/dev/sda1 * 1 4742 38090083+ 7 HPFS/NTFS

/dev/sda2 4743 9964 41945715 5 Extended

/dev/sda5 4743 9744 40178533+ 83 Linux

/dev/sda6 9745 9964 1767118+ 82 Linux swap

/Solaris

Disk /dev/sdb: 120.0 GB, 120034123776 bytes

255 heads, 63 sectors/track, 14593 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0xb94838a4

Disk /dev/sdb doesn't contain a valid partition table

Two hard disks are listed in the results: look for the headings Disk /dev/sda and Disk /dev/sdb. Beneath each heading is technical information about the disk, and beneath that the partitions on that disk are listed.



It should be obvious that, on my test computer, /dev/sdb is the new hard disk because it has no partitions (it "doesn't contain a valid partition table"), while /dev/sda has the standard partition layout of an Ubuntu system. Yours will probably be similar, if not identical.



Look for the reference to your new hard disk and make a note of it. In my case, I make a note of /dev/sdb. Then type sudo cfdisk -z /dev/sdb to start the cfdisk partitioning program, which we'll use to write an initial partition table to the disk. If necessary, replace /dev/sdb with the details of the new hard disk you discovered earlier. When cfdisk starts, type W (note that's Shift+w) and then type yes to write a blank partition table. Then press q to quit cfdisk. You can ignore the handful of minor errors that are reported.



Cloning the disk



Now that we have this information, we can install ddrescue and use it to clone the disk. This needs to be installed because it isn't a default system tool. Although the computer is running the Ubuntu install CD live distro mode, it's still possible to install additional software from the online repositories. However, before doing this, it's necessary to enable the Universe software repository (of course, you will need to use NetworkManager to get online too, if you haven't already). Click System -> Administration -> Software Sources, and put a check in the box alongside Community-maintained Open Source software (universe). Then click the Close button, and agree to refresh the list of software when asked.



After this, type sudo apt-get install gddrescue at the prompt to install ddrescue.



Use ddrescue by first specifying the old hard disk, then the new hard disk. Add the -v command option to provide a status report as the command progresses:



$ sudo ddrescue -v /dev/sda /dev/sdb

It's extremely important that you ensure you get the old and new disks in the right order. Otherwise, you might well overwrite the data on your old disk!



Once the cloning has finished -- it will probably take an hour or more, depending on the size of the original hard disk -- you should shut down the computer, remove the old disk (you must disconnect the old disk before you can continue!), and boot from the cloned copy to test things. If you use Windows XP/Vista, it might object to a new hard disk as part of its Windows Genuine Advantage system, and you might have to revalidate online. Of course, Ubuntu will work fine without any such worries.



Assuming everything works correctly, you can move on to the next step: expanding the partitions to take advantage of the larger hard disk.



Expanding the partitions



Before attempting to expand the partitions, it's a good idea to check that your Ubuntu partition's filesystem is sound. To do this, boot into the Ubuntu install CD's live distro mode as before. Open a terminal window and type the command sudo fsck.ext3 -f /dev/sda5 to perform a disk check (assuming that Ubuntu is installed alongside Windows on your hard disk in the standard configuration).



Once this has completed, close the terminal window and click System -> Administration -> Partition Editor. What happens next depends on your requirements. If you just want to expand the Ubuntu partition, follow these steps:



In the Partition list, right-click the linux-swap entry and select Swap off. This will stop Ubuntu's live distro mode from accessing the swap partition so that it can be moved on the hard disk.

Before anything else can happen, you must resize the extended partition that contains Ubuntu. Right-click the extended entry in the list and select Resize/Move. In the dialog box that appears, change the Free Space Following (MiB) box to read 0, then press Tab. This will cause the partition to be expanded to fill the space. Click the Resize/Move button when done. Bear in mind that no changes are carried until you click the Apply button, which you will do after making all the changes to the disk's partitions.

Right-click the linux-swap partition once again, and select Resize/Move. In the dialog box that appears, click and drag the graphical representation of the partition to the end of the free space (in other words, click and drag it to the right of the graphical display). After this, the Free Space Following (MiB) box should read 0. Click Resize/Move.

Back in the main GParted program window, right-click the ext3 entry in the list, and select Resize/Move. Click and drag the rightmost edge of the partition in the graphical representation so that it "grows" to fill the free space. Eventually the Free Space Following (MiB) box will read 0. When this is the case, click the Resize/Move button.

Finally, click the Apply button on the main GParted toolbar. Then click Apply in the dialog box that appears, and sit back and wait while the partitions are moved and resized. If you want to see what's happening, click the small arrow alongside Details in the Applying pending operations dialog box.

When GParted has finished, close the program, then open a terminal window. Enter sudo fsck.ext3 -f /dev/sda5, which will once again check the Ubuntu partition for errors (and, again, these steps assume that Ubuntu is installed alongside Windows on your hard disk in the standard configuration). If there are any errors, you'll be prompted to repair them. Usually you can agree to the repair.

After the filesystem check, you can reboot your computer from the new hard disk. You should find the Ubuntu partition is now larger.



If you want to resize your Windows partition too, these steps are still relevant. However, you will have to move the swap and ext3 partitions, as well as the extended partition containing them, before resizing the NTFS partition.



If you want to dispose of the old hard disk or pass it on to somebody else, be sure to securely wipe it. However, don't do so until you're 100% sure your new cloned copy is working correctly. I usually wait at least a week or two to ensure the copy works fine before doing anything to the old disk.

วันพุธที่ 8 ธันวาคม พ.ศ. 2553

windows command

Hope you find these useful.




Shutdown %windir%\System32\shutdown.exe -s



Reboot %windir%\System32\shutdown.exe -r



Logoff %windir%\System32\shutdown.exe -l



Standby %windir%\System32\rundll32.exe powrprof.dll,SetSuspendState Standby



Hibernate %windir%\System32\rundll32.exe powrprof.dll,SetSuspendState Hibernate

วันเสาร์ที่ 27 พฤศจิกายน พ.ศ. 2553

Moodle online text template

Description « Hide

enable teacher to add a "template text" for students to base their answer upon

when giving them an online assignment.

patch explanation follows in the comments for this tracker issue









Description enable teacher to add a "template text" for students to base their answer upon when giving them an online assignment. patch explanation follows in the comments for this tracker issue Show »





All Comments Change History Version Control Sort Order: Ascending order - Click to sort in descending order



[ Permalink
« Hide ]

Nadav Kavalerchik added a comment - 27/May/09 04:15 AM

add new field to the DB, table assignment called "answertemplate" type=text collation=utf8_unicode_ci

patch the file mod/assignment/type/online/assignment.class.php

line 117:

print_single_button('view.php', array('id'=>$this->cm->id,'edit'=>'1','assignmentid'=>$this->assignment->id),

just after line 252 add:



$mform->addElement('htmleditor', 'answertemplate', get_string('answertemplate', 'assignment'), array('cols'=>60, 'rows'=>30));

$mform->setType('answertemplate', PARAM_RAW); // to be cleaned before display

$mform->setHelpButton('answertemplate', array('reading', 'writing', 'richtext'), false, 'editorhelpbutton');

$mform->addRule('answertemplate', get_string('required'), 'required', null, 'client');

just after line 283 add:



if (! $answertemplate = get_field('assignment','answertemplate' ,'id', $_GET['assignmentid'])) {

//error('assignment ID was incorrect');

}

$mform->setDefault('text', $answertemplate);

add to you local lang assignment.php files the string:

$string['answertemplate'] = 'A template for student\'s answer';

enjoy



[ Show » ]

Nadav Kavalerchik added a comment - 27/May/09 04:15 AM

add new field to the DB, table assignment called "answertemplate" type=text collation=utf8_unicode_ci

patch the file mod/assignment/type/online/assignment.class.php line 117:

print_single_button('view.php', array('id'=>$this->cm->id,'edit'=>'1','assignmentid'=>$this->assignment->id),

just after line 252 add:

$mform->addElement('htmleditor', 'answertemplate', get_string('answertemplate', 'assignment'), array('cols'=>60, 'rows'=>30));

$mform->setType('answertemplate', PARAM_RAW); // to be cleaned before display

$mform->setHelpButton('answertemplate', array('reading', 'writing', 'richtext'), false, 'editorhelpbutton');

$mform->addRule('answertemplate', get_string('required'), 'required', null, 'client');

just after line 283 add:

if (! $answertemplate = get_field('assignment','answertemplate' ,'id', $_GET['assignmentid'])) {

//error('assignment ID was incorrect');

}

$mform->setDefault('text', $answertemplate);

add to you local lang assignment.php files the string:

$string['answertemplate'] = 'A template for student\'s answer';

enjoy

วันพุธที่ 24 พฤศจิกายน พ.ศ. 2553

mount usb on linux

Mounting the External File System (Hard Drive)


To mount your hard drive you need to use the mount command. (To unmount the drive when you are ready to unplug it and take it home, use the umount command.) Here’s an example:



mkdir /mnt/usbdrive

mount /dev/sda1 /mnt/usbdrive



The above command first creates a directory in your /mnt folder, typically the folder will be descriptive of the device, so we use /mnt/usbdrive. This only has to be done once, as you won’t be deleting this folder. This folder will be your mount point for the external hard drive.



The second line mounts the device at the /dev/sda1 location to the /mnt/usbdrive directory.



Now you can reference your hard drive from the command line using the folder /mnt/usbdrive.



Automount In the Terminal

To have your hard drive mount each time your server is restarted, you must edit your /etc/fstab file. Simply add at the bottom of your /etc/fstab file:



/dev/sda1 /mnt/usbdrive ext3 defaults 0 0



The first argument (/dev/sda1) tells the system what device to mount, and the second argument (/mnt/usbdrive) tells the system where to mount it. The third argument is the filesystem type (ext3). The fourth argument (defaults) tells the system what options to apply to the device, so in this case we’ll just use the defaults. The fifth and sixth arguments (both zeros) tell the system if the filesystem should be backed up using the dump utility, and the second zero tells the system whether to process the device when fsck is run. We can leave them both to zero for now.



Now you have a mounted hard drive that you can use for all your company backups, and by reading our previous two articles you can setup a script to automate your backup.

วันอังคารที่ 23 พฤศจิกายน พ.ศ. 2553

moodle online txt

http://tracker.moodle.org/browse/MDL-19299

add new harddisk drive onto ubuntu

http://www.techotopia.com/index.php/Adding_a_New_Disk_Drive_to_an_Ubuntu_Linux_System

Getting Started


This tutorial assumes that the new physical hard drive has been installed on the system and is visible to the operating system. The best way to do this is to enter the system BIOS setup during the boot process and ensure that the BIOS sees the disk drive. Sometimes the BIOS will provide a menu option to scan for new drives. If the BIOS does not see the disk drive double check the connectors and jumper settings (if any) on the drive.



[edit] Finding the New Hard Drive in Ubuntu

Assuming the drive is visible to the BIOS it should automatically be detected by the operating system. Typically, the disk drives in a system are assigned device names beginning hd or sd followed by a letter to indicate the device number. For example, the first device might be /dev/sda, the second /dev/sdb and so on.



The following is output from a system with only one physical disk drive:



ls /dev/sd*

/dev/sda /dev/sda1 /dev/sda2 /dev/sda5

This shows that the disk drive represented by /dev/sda is itself divided into three partitions, represented by /dev/sda1, /dev/sda2 and /dev/sda5.



The following output is from the same system after a second hard disk drive has been installed and detected by the operating system:



ls /dev/sd*

/dev/sda /dev/sda1 /dev/sda2 /dev/sda5 /dev/sdb

As shown above, the new hard drive has been assigned to the device file /dev/sdb. At this point the drive has no partitions shown (because we have yet to create any).



[edit] Creating Linux Partitions

The next step is to create one or more Linux partitions on the new disk drive. This is achieved using the fdisk utility which takes as a command-line argument the device to be partitioned (in this case /dev/sdb):



sudo fdisk /dev/sdb

[sudo] password for johndoe:

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xc2fe324b.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.



Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)



Command (m for help):

In order to view the current partitions on the disk enter the p command:



Command (m for help): p



Disk /dev/sdb: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0xc2fe324b



Device Boot Start End Blocks Id System



As we can see from the above fdisk output, the disk currently has no partitions because it is a previously unused disk. The next step is to create a new partition on the disk, a task which is performed by entering n (for new partition) and p (for primary partition):



Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4):

In this example we only plan to create one partition which will be partition 1. Next we need to specify where the partition will begin and end. Since this is the first partition we need it to start at cylinder 1 and since we want to use the entire disk we specify the last cylinder as the end. Note that if you wish to create multiple partitions you can specify the size of each partition by cylinders, bytes, kilobytes or megabytes.



Partition number (1-4): 1

First cylinder (1-261, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):

Using default value 261

Now that we have specified the partition we need to write it to the disk using the w command:



Command (m for help): w

The partition table has been altered!



Calling ioctl() to re-read partition table.

Syncing disks.

If we now look at the devices again we will see that the new partition is visible as /dev/sdb1:



ls /dev/sd*

/dev/sda /dev/sda1 /dev/sda2 /dev/sda5 /dev/sdb /dev/sdb1

Now that the disk has been successfully partitioned, the next step is to create a file system on our new partition.



[edit] Creating a Filesystem on an Ubuntu Disk Partition

We now have a new disk installed, it is visible to Ubuntu and we have configured a Linux partition on the disk. The next step is to create a Linux file system on the partition so that the operating system can use it to store files and data. The easiest way to create a file system on a partition is to use the mkfs.ext3 utility which takes as arguments the label and the partition device:



sudo mkfs.ext3 -L /photos /dev/sdb1

mke2fs 1.40.2 (12-Jul-2007)

Filesystem label=/photos

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

262144 inodes, 524112 blocks

26205 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=536870912

16 block groups

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912



Writing inode tables: done

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done



This filesystem will be automatically checked every 28 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.



[edit] Mounting a Filesystem

Now that we have created a new file system on the Linux partition of our new disk drive we need to mount it so that it is accessible. In order to do this we need to create a mount point. A mount point is simply a directory into which the file system will be mounted. For the purposes of this example we will create a /photos directory to match our file system label (although it is not necessary that these values match):



sudo mkdir /photos

The file system may then be manually mounted using the mount command:



sudo mount /dev/sdb1 /photos

Running the mount command with no arguments shows us all currently mounted file systems (including our new file system):



mount

/dev/sda1 on / type ext3 (rw,errors=remount-ro)

proc on /proc type proc (rw,noexec,nosuid,nodev)

/sys on /sys type sysfs (rw,noexec,nosuid,nodev)

varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)

varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)

udev on /dev type tmpfs (rw,mode=0755)

devshm on /dev/shm type tmpfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

lrm on /lib/modules/2.6.22-14-generic/volatile type tmpfs (rw)

securityfs on /sys/kernel/security type securityfs (rw)

/dev/sdb1 on /photos type ext3 (rw)

[edit] Configuring Ubuntu to Automatically Mount a Filesystem

In order to set up the system so that the new file system is automatically mounted at boot time, an entry needs to be added to the /etc/fstab file. This may be edited by issuing the following command in a terminal window:



sudo gedit /etc/fstab

The following example shows an /etc/fstab file configured to automount our /photos partition:



# /etc/fstab: static file system information.

#

#

proc /proc proc defaults 0 0

# /dev/sda1

UUID=4a621e4d-8c8b-4b39-8934-98ab8aa52ebc / ext3 defaults,errors=remount-ro 0 1

# /dev/sda5

UUID=9c82bf09-c6f7-4042-8927-34e46518b224 none swap sw 0 0

/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec 0 0

/dev/fd0 /media/floppy0 auto rw,user,noauto,exec 0 0

/dev/sdb1 /photos auto defaults 0 0

Thin disk

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1005418

วันจันทร์ที่ 22 พฤศจิกายน พ.ศ. 2553

NFS

Install NFS Server in Ubuntu




sudo apt-get install nfs-kernel-server nfs-common portmap



When configuring portmap do =not= bind loopback. If you do you can either edit /etc/default/portmap using the following



sudo vi /etc/default/portmap



or use the following command



sudo dpkg-reconfigure portmap



Restart Portmap using the following command



sudo /etc/init.d/portmap restart



NFS Server Configuration



NFS exports from a server are controlled by the file /etc/exports. Each line begins with the absolute path of a directory to be exported, followed by a space-seperated list of allowed clients.



You need to edit the exports file using the following command



sudo vi /etc/exports



Here are some quick examples of what you could add to your /etc/exports



For Full Read Write Permissions allowing any computer from 192.168.1.1 through 192.168.1.255



/files 192.168.1.1/24(rw,no_root_squash,async)



Or for Read Only from a single machine



/files 192.168.1.2 (ro,async)



save this file and exit



A client can be specified either by name or IP address. Wildcards (*) are allowed in names, as are netmasks (e.g. /24) following IP addresses, but should usually be avoided for security reasons.



A client specification may be followed by a set of options, in parenthesis. It is important not to leave any space between the last client specification character and the opening parenthesis, since spaces are intrepreted as client seperators.



Now you need to restart NFS server using the following command



sudo /etc/init.d/nfs-kernel-server restart



If you make changes to /etc/exports on a running NFS server, you can make these changes effective by issuing the command



sudo exportfs -a



Install NFS client support in Ubuntu



sudo apt-get install portmap nfs-common



This will install all the required packages for nfs client



Mounting manually



Example to mount server.mydomain.com:/files to /files. In this example server.mydomain.com is the name of the server containing the nfs share, and files is the name of the share on the nfs server



The mount point /files must first exist on the client machine.



Create files directory using the following command



sudo mkdir files



You need to mount the share using the following command



sudo mount server.mydomain.com:/files /files



Now you may need to restart services using the following command



sudo /etc/init.d/portmap restart



sudo /etc/init.d/nfs-common restart



Mounting at boot using /etc/fstab



If you want to mount using fstab file



sudo vi /etc/fstab



In this example my /etc/fstab was like this



server.mydomain.com:/files /files nfs rsize=8192,wsize=8192,timeo=14,intr



Change “servername.mydomain.com:/files”, and “/files” to match your server name,share name, and the name of the mount point you created.



Firewall Ports for NFS



If you have a firewall you need to make sure ports 32771, 111 and 2049 are open

Testing Your Configuration



Use the following command in terminal to test



mount /files



the mount point /files will be mounted from the server.



Reference



http://czarism.com/easy-peasy-ubuntu-linux-nfs-file-sharing

วันพุธที่ 3 พฤศจิกายน พ.ศ. 2553

access denied

http://isp-control.net/forum/printthread.php?tid=1544
today I finally manage to make things tick. I would like to share my settings here.




dovecot.conf



Code:



base_dir = /var/run/dovecot/

protocols = imap pop3

disable_plaintext_auth = no

listen = *

syslog_facility = mail

log_path = /var/log/dovecot.log

info_log_path = /var/log/dovecot-info.log

auth_debug=yes

auth_debug_passwords=yes

login_greeting = Dovecot ready.

mail_location = maildir:/var/mail/virtual/%d/%n

mail_extra_groups = mail

protocol imap {

}

namespace private {

prefix = INBOX.

inbox = yes

}

protocol pop3 {

pop3_uidl_format = %u-%v

}

protocol lda {

postmaster_address = postmaster@(hidden).com

auth_socket_path = /var/run/dovecot/auth-master

}

auth default {

mechanisms = plain login

passdb sql {

args = /etc/dovecot-sql-domain.conf

}

userdb sql {

args = /etc/dovecot-sql-domain.conf

}

passdb sql {

args = /etc/dovecot-sql-subdomain.conf

}

userdb sql {

args = /etc/dovecot-sql-subdomain.conf

}

socket listen {

client {

path = /var/spool/postfix/private/auth

mode = 0660

user = postfix

group = postfix

}

master {

path = /var/run/dovecot/auth-master

mode = 0660

user = vmail

group = mail

}

}

user = vmail

}

plugin {

}



postconf -n





Code:



alias_database = hash:/etc/aliases

alias_maps = hash:/etc/aliases

append_at_myorigin = yes

append_dot_mydomain = no

biff = no

broken_sasl_auth_clients = yes

command_directory = /usr/sbin

config_directory = /etc/postfix

daemon_directory = /usr/libexec/postfix

debug_peer_level = 2

html_directory = no

inet_interfaces = all

local_destination_recipient_limit = 1

local_recipient_maps = unix:passwd.byname $alias_database

local_transport = local

mail_owner = postfix

mail_spool_directory = /var/mail

mailbox_command = procmail -a "$EXTENSION"

mailbox_size_limit = 0

mailq_path = /usr/bin/mailq.postfix

manpage_directory = /usr/share/man

mydestination = $myhostname, $mydomain

mydomain = (hidden).com

myhostname = localhost.(hidden).com

mynetworks_style = host

myorigin = $mydomain

newaliases_path = /usr/bin/newaliases.postfix

queue_directory = /var/spool/postfix

readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES

sample_directory = /usr/share/doc/postfix-2.3.3/samples

sendmail_path = /usr/sbin/sendmail.postfix

setgid_group = postdrop

smtpd_banner = $myhostname ISPCP 1.0 Priamos Managed ESMTP 1.0.0 RC2 OMEGA

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination

smtpd_sasl_auth_enable = yes

smtpd_sasl_authenticated_header = yes

smtpd_sasl_path = private/auth

smtpd_sasl_security_options = noanonymous

smtpd_sasl_type = dovecot

smtpd_sender_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination

transport_maps = hash:/etc/postfix/ispcp/transport

unknown_local_recipient_reject_code = 550

virtual_alias_maps = hash:/etc/postfix/ispcp/aliases

virtual_gid_maps = static:12

virtual_mailbox_base = /var/mail/virtual

virtual_mailbox_domains = hash:/etc/postfix/ispcp/domains

virtual_mailbox_limit = 0

virtual_mailbox_maps = hash:/etc/postfix/ispcp/mailboxes

virtual_minimum_uid = 12004

virtual_transport = dovecot

virtual_uid_maps = static:12004



*note: gid & uid has been changed to the vmail uid & mail gid. Please update uid & gid in your dovecot-sql-domain.conf and dovecot-sql-subdomain.conf too if it's different.



for Fedora Core 6 (that I use), please change the given code in HowTo to the code below. It solves your unknown transport error.



Code:



dovecot unix - n n - - pipe

flags=DRhu user=vmail:mail argv=/usr/libexec/dovecot/deliver -d ${recipient}

*note: argv=/usr/lib/dovecot/deliver changed to argv=/usr/libexec/dovecot/deliver



and on the client (Outlook etc.) please tick on "My outgoing server (SMTP) requires authentication" under Outgoing Server in advanced setting. Please refer to your version on setting this.



The rest of the setting on Postfix is the default setting upon installation. I manage to solve this by uninstalling Postfix & re-install Postfix and edit the default /etc/postfix/main.cf based on values given in /etc/ispcp/postfix/main.cf. If you have installed ispCP then uninstall the Postfix, your main.cf & master.cf will be backed up with main.cf.rpmsave & master.cf.rpmsave.



Now, i'm going to solve the webmail issue



Quote:Error opening ../data/default_pref

Could not create initial preference file!

../data/ should be writable by user apache

Please contact your system administrator and report this error.



gonna check Squrrelmail FAQ for this.





--------------------------------------------------------------------------------

RE: 554 5.7.1 Relay access denied - joximu - 10-20-2007 06:24 PM



Could you change the title to "[solved] ..."



and for the other issue make a new thread...



/Joxi





--------------------------------------------------------------------------------

[solved] RE: 554 5.7.1 Relay access denied - measaura - 10-20-2007 10:15 PM



Thanks for your guidance.



This case is closed. webmail issue on other thread.

วันเสาร์ที่ 23 ตุลาคม พ.ศ. 2553

rsync

Simple command line

rsync -r -a -v -e "ssh -l root"  /source/dir_to_upload/   xxx.xxx.xxx.xxx:/desination/




How to sync data between 2 servers automatically

http://www.howtomonster.com/2007/08/08/how-to-sync-data-between-2-servers-automatically/
Have you ever wanted to know how to easily synchronize the data between multiple servers automatically?

In this article I’ll explain how to setup 2 Linux servers to automatically synchronize data between a specific directory on each server. To do this we will use rsync, ssh key authentication, and a cron job.


Let’s call the 2 servers ‘SOURCESERVER’ and ‘DESTSERVER’ for

SOURCESERVER = Source server (the server we’re connecting from to upload the data)

DESTSERVER = Destination server (the server we’re connecting to receive the data)





Part 1 - Setting up SSH key authentication



First, we need to make sure the DESTSERVER has the ability to use key authentication enabled. Find your sshd configuration file (usually ‘/etc/ssh/sshd_config’) and enable the following options if they are not already set.



RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys



If you edit the file be sure to restart sshd afterwards.



# /etc/init.d/sshd restart



Next, on the SOURCESERVER we will create the public / private key pair to be used for authentication with the following command.



# ssh-keygen -t rsa



*Note: Do not enter a passphrase for this, just hit enter when prompted.



This should create 2 files, a public key file and a private key file.

The public key file (usually [homedir]/.ssh/id_rsa.pub) we will upload to the DESTSERVER.

The private key file (usually [homedir]/.ssh/id_rsa) we will keep on the SOURCESERVER.

*Be sure to keep this private key safe. With it anyone will be able to connect to the DESTSERVER that contains the public key.



Now we will plant the public key we created on to the DESTSERVER.

Choose the user account which you will use to connect to on DESTSERVER, we’ll call this user ‘destuser’ for now.

In that account’s home directory, create a ‘.ssh’ subdirectory, and in that directory create a new text file called ‘authorized_keys’. If it already exists, great, use the existing file.

Open the ‘authorized_keys’ file and paste in the contents of the public key you created in the previous step (id_rsa.pub). It should look something like the following



ssh-rsa sourceuser@SOURCESERVER



Save the file and change the permissions to 600 for the file and 700 for the ‘.ssh’ directory.



Now to test that the keys are working.

From the SOURCESERVER try logging in as normal using ssh to the DESTSERVER.



# ssh destuser@DESTSERVER



If all is working you should not be prompted for a password but instead connected directly to a shell on the DESTSERVER.





Part 2 - Creating the rsync script



Now for the rsync script.

I use a simple script such as the following



——————————————-



#!/bin/bash



SOURCEPATH=’/source/directory’

DESTPATH=’/destination’

DESTHOST=’123.123.123.123′

DESTUSER=’destuser’

LOGFILE=’rsync.log’



echo $’\n\n’ >> $LOGFILE

rsync -av –rsh=ssh $SOURCEPATH $DESTUSER@$DESTHOST:$DESTPATH 2>&1 >> $LOGFILE

echo “Completed at: `/bin/date`” >> $LOGFILE



——————————————-



Copy this file into the home directory of the sourceuser on the SOURCESERVER

and modify the first 4 variables in the file.

SOURCEPATH (Source path to be synced)

DESTPATH (Destination path to be synced)

DESTHOST (Destination IP address or host name)

DESTUSER (User on the destination server)

Save it as something like ‘rsync.sh’

Set the permissions on the file to 700.

# chmod 700 rsync.sh



Now you should be able to run the script, have it connect to the DESTSERVER, and transfer the files all without your interaction.

The script will send all output to the ‘rsync.log’ file specified in the script.





Part 3 - Setting up the cron job



Assuming everything has worked so far all that’s left is to setup a cron job to run the script automatically at a predefined interval.



As the same sourceuser use the ‘crontab’ command to create a new cron job.



# crontab -e



This will open an editor where you can schedule the job.

Enter the following to have the script run once every hour



——————————————-

# Run my rsync script once every hour

0 * * * * /path/to/rsync.sh

——————————————-



Your 2 servers should now be syncing the chosen directory once every hour.

Hope this helped, let me know if you have any questions.

วันศุกร์ที่ 22 ตุลาคม พ.ศ. 2553

วันพฤหัสบดีที่ 21 ตุลาคม พ.ศ. 2553

วันศุกร์ที่ 15 ตุลาคม พ.ศ. 2553

วันพฤหัสบดีที่ 14 ตุลาคม พ.ศ. 2553

migrate users on ubuntu

Migrate users from one Linux machine to another


February 14, 2010 By: mildtech Category: software

Share


Have you ever had a need to migrate current running Linux users from installation to another? That would be a simple task if the user count was low. But what happens when the user count is in the hundreds? What do you do then? If you’re not using LDAP, you know you will have to migrate the users’ data, passwords, etc from the old machine to the new. Believe it or not, this is just a matter of a few commands – not necessarily simple commands, but it’s not as complex as you would think.



In this article I am going to show you how to make this migration so your Linux users do not loose their data and their passwords are all retained.



What we migrating



The list is fairly simple:



* /etc/passwd - Contains information about the user.

* /etc/shadow – Contains the encrypted passwords.

* /etc/group – Contains group information.

* /etc/gshadow – Contains group encrypted passwords.

* /var/spool/mail – Contains users email (the location will depend upon the mail server you use).

* /home/ – Contains users data.



Unfortunately these files can not simply be copied from one machine to another – that would be too easy. Just make sure you enter the following commands correctly.

Source machine



These are the commands you will need to run on the machine you are migrating users FROM. I will assume you are doing this on a system that uses a root user (such as Fedora), so all commands will be done as root:



mkdir ~/MOVE



The above command creates a directory to house all of the files to be moved.



export UGIDLIMIT=500



The above command sets the UID filter limit to 500. NOTE: This value will be dictated by your distribution. If you use Red Hat Enterprise Linux, CentOS, or Fedora this value is shown in the command above. If you use Debian or Ubuntu that limit is 1000 (not 500).



awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534)’ /etc/passwd > ~/MOVE/passwd.mig



The above command copies only user accounts from /etc/passwd (using awk allows us to ignore system accounts.)



awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534)’ /etc/group > ~/MOVE/group.mig



The above command copies the /etc/group file.



awk -v LIMIT=$UGIDLIMIT -F: ‘($3>=LIMIT) && ($3!=65534) {print $1}’ /etc/passwd
tee –
egrep -f – /etc/shadow > ~/MOVE/shadow.mig



The above command copies the /etc/shadow file.



cp /etc/gshadow ~/MOVE/gshadow.mig



The above command copies the /etc/gshadow file.



tar -zcvpf ~/MOVE/home.tar.gz /home



The above command archives /home.



tar -zcvpf ~/MOVE/mail.tar.gz /var/spool/mail



The above command archives the mail directory. NOTE: If you are using Sendmail this is the correct directory. If you are using Postfix that directory most likely will be /etc/postfix.



Now it’s time to move everything in ~/MOVE over to the new server. You can do this using the scp command like so:



scp -r ~/MOVE/* USER@IP_OF_NEW_SERVER:/home/USER/



Where USER is the username you will use to send the file and IP_OF_NEW_SERVER is the address of the new server. NOTE: If this server is not on line yet you can always copy these files onto a thumb drive and move them that way.



Target machine



Now we’re working on the new server. Follow these commands (run as the root user):



mkdir ~/newsusers.bak



The above command will create a new directory that will house the backup of the current users.



cp /etc/passwd /etc/shadow /etc/group /etc/gshadow ~/newsusers.bak



The above command will copy the necessary files to the new backup directory.



cd /PATH/TO/DIRECTORY

cat passwd.mig >> /etc/passwd

cat group.mig >> /etc/group

cat shadow.mig >> /etc/shadow

/bin/cp gshadow.mig /etc/gshadow



The above commands will restore all password files onto the new system. NOTE: Where /PATH/TO/DIRECTORY is the location where you copied the files onto the new system.



cd /

tar -zxvf /PATH/TO/DIRECTORY/home.tar.gz



The above commands will first change you to the / directory and then unpack the archived /home directory. NOTE: Where /PATH/TO/DIRECTORY is the location where you copied the files onto the new system.



cd /

tar -zxvf /PATH/TO/DIRECTORY/mail.tar.gz



The above commands will first change you to the / directory and then unpack the archived/var/spool/mail directory. NOTE: Where /PATH/TO/DIRECTORY is the location where you copied the files onto the new system.



You can now reboot your system with the users in place.

วันอาทิตย์ที่ 3 ตุลาคม พ.ศ. 2553

$ mysql --user=root --password


Enter password: ********

mysql> CREATE USER dotproject IDENTIFIED BY 'dotproject';

Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON dotproject.* TO dotproject;

Query OK, 0 rows affected (0.00 sec)

redmine

http://www.redmine.org/wiki/redmine/RedmineInstall

วันเสาร์ที่ 2 ตุลาคม พ.ศ. 2553

collabtive

http://www.howtoforge.com/web-based-project-management-with-collabtive-on-ubuntu7.10-server

Database host: localhost


Database name: collabtive

Database user: collabuser

Database password: collabPW

วันพุธที่ 22 กันยายน พ.ศ. 2553

Squirrelmail 10 Language

SquirrelMail Configuration : Read: config.php (1.4.0)


---------------------------------------------------------

Language preferences

1. Default Language : th_TH

2. Default Charset : tis-620

3. Enable lossy encoding : true

วันจันทร์ที่ 13 กันยายน พ.ศ. 2553

How to access the VMware ESXi hidden console

http://www.virtualizationadmin.com/articles-tutorials/vmware-esx-articles/general/how-to-access-the-vmware-esxi-hidden-console.html

1. push alt-F1 to enter the hidden console.
2. enter password
3. /etc/inetd.conf – this file can be used to enable services that, otherwise could not be enabled. For example, by removing the hash (#) mark before the ssh or the ftp, I can enable these services on my ESXi server.

วันเสาร์ที่ 11 กันยายน พ.ศ. 2553

math

http://www.zweigmedia.com/RealWorld/

วันจันทร์ที่ 6 กันยายน พ.ศ. 2553

วันพุธที่ 18 สิงหาคม พ.ศ. 2553

Spamassassin

http://townx.org/blog/elliot/simple_spamassassin_setup_with_postfix_and_dovecot_on_ubuntu_breezy

Simple Spamassassin setup with Postfix and Dovecot on Ubuntu Breezy

scopus

link


http://scopees.elsevier.com/ees_login.asp?journalacronym=HAZMAT&username=VBOONAMNUA
password noboonam29

วันจันทร์ที่ 16 สิงหาคม พ.ศ. 2553

VNC

http://www.samlesher.com/ubuntu/ubuntu-704-enabledisable-remote-desktop-from-the-command-line

วันจันทร์ที่ 9 สิงหาคม พ.ศ. 2553

public_html

cd to the user home directory
mkdir public_html

activated public_html with

me@myhost$ cd /etc/apache2/mods-enabled


me@myhost$ sudo ln -s ../mods-available/userdir.conf userdir.conf

me@myhost$ sudo ln -s ../mods-available/userdir.load userdir.load

me@myhost$ sudo /etc/init.d/apache2 restart

วันพฤหัสบดีที่ 5 สิงหาคม พ.ศ. 2553

Limesurvey

http://www.peyresaubes.com/IMG/pdf/Limesurvey-anglais.pdf


http://www.limesurvey.org/de/support/hilfe-foren/5-can-i-do-this-with-limesurvey/8208-done-preload-flash-movies-into-browser-cache
problem with swf

http://www.arjatiili.fi/flash/index.html

good web design

Top opensources

http://www.google.com/url?sa=t&source=web&cd=17&ved=0CDAQFjAGOAo&url=http%3A%2F%2Fcats.suffolk.lib.ny.us%2Fpdf%2FTop_Open_Source_LILC_2010.doc&ei=rGNbTLDUKsaPcNfkwNAB&usg=AFQjCNEtxZh9YrCP_rOmcMWkMDkgeN7JUw&sig2=oSIGggjWzaAxwDRfNdfqNw

วันพุธที่ 4 สิงหาคม พ.ศ. 2553

vnc

https://help.ubuntu.com/community/VNC/Servers




http://www.ehow.com/how_5089245_install-vnc-server-ubuntu.html
Instructions.1.Step 1

Open a Terminal window. The Terminal window can be found under "Start" > "Utilities."



2.Step 2

Download vnc4server and xinetd:

sudo apt-get install vnc4server xinetd



3.Step 3

Start the vnc4server:

vnc4server



You will be prompted for a password. This password will be used to log into the VNC session.



After providing a password, you will get output that looks like:

New 'laptop:3 (laptop)' desktop is laptop:3



Take notice of the number after the colon (:), in this case it is "3."



Starting the vnc4server will cause a .vnc directory to be placed in your home directory.



4.Step 4

Stop the vnc4server

vnc4server -kill :3



Replace the number "3" with the number from Step 3.



5.Step 5

Open the .vnc/xstartup file for editing:

gedit ~/.vnc/xstartup



The file will look like:

#!/bin/sh

# Uncomment the following two lines for normal desktop:

#unset SESSION_MANAGER

#exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey

vncconfig -iconic &

xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

twm &



6.Step 6

Change the .vnc/xstartup file and save it.



Uncomment the lines that start with unset and exec. Comment out the lines that start with xsetroot, vncconfig, xterm and twm.



The final file should look like:

#!/bin/sh

# Uncomment the following two lines for normal desktop:

unset SESSION_MANAGER

exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

#xsetroot -solid grey

#vncconfig -iconic &

#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

#twm &



7.Step 7

Change the permissions on the /etc/X11/xinit/xinitrc file to make it executable:

sudo chmod 755 /etc/X11/xinit/xinitrc



8.Step 8

Start the vnc4server:

vnc4server



Again, remember the number after the colon (:).



9.Step 9

Log into your remote desktop to check the configuration:

vncviewer localhost:3



Provide the password that you chose in Step 3.







Read more: How to Install a VNC Server in Ubuntu
eHow.com http://www.ehow.com/how_5089245_install-vnc-server-ubuntu.html#ixzz0vn9ThHnA

วันอังคารที่ 3 สิงหาคม พ.ศ. 2553

apps spam mail

http://sourceforge.net/apps/mediawiki/assp/index.php?title=Debian

วันจันทร์ที่ 2 สิงหาคม พ.ศ. 2553

90 days

http://www.immigration.go.th/nov2004/base.php?page=90days
การรับแจ้งอยู่ในราชอาณาจักร เกิน 90 วัน


คนต่างด้าวซึ่งได้รับอนุญาตให้อยู่ในราชอาณาจักรเป็นการชั่วคราวแล้ว ถ้าอยู่ในราชอาณาจักรเกิน 90 วัน คนต่างด้าวผู้นั้นมีหน้าที่ต้องรายงานตัวแจ้งที่พักอาศัยต่อพนักงานสำนักงานตรวจคนเข้าเมือง ทุก90 วัน หากท้องที่ใดมีที่ทำการตรวจคนเข้าเมืองตั้งอยู่จะแจ้งต่อพนักงานเจ้าหน้าที่ ณ ที่ทำการแห่งนั้น ก็ได้ ทั้งนี้ เป็นไปตาม มาตรา 37(5) แห่ง พ.ร.บ.คนเข้าเมือง พ.ศ. 2522

วิธีการแจ้ง

คนต่างด้าวแจ้งด้วยตนเองหรือ

คนต่างด้าวมอบหมายให้ผู้อื่นนำหนังสือไปแจ้งหรือ

คนต่างด้าวอาจมีหนังสือแจ้งทางไปรษณีย์ลงทะเบียน

คนต่างด้าวสามารถแจ้งที่พักอาศัยได้ ก่อนหรือหลัง 7 วัน นับจากวันครบกำหนด หากเกินกำหนดนัด หรือเกินกำหนดที่จะต้องแจ้งคนต่างด้าวต้องมารายงานตัวด้วยตนเองเพื่อดำเนินการเปรียบเทียบปรับ

กรณีที่เกินกำหนดการแจ้งที่พักอาศัยฯ คนต่างด้าวที่มารายงานตัว จะถูกดำเนินการเปรียบเทียบปรับ 2,000 บาท

กรณีคนต่างด้าวเดินทางออกนอกประเทศก่อนครบกำหนดนัดครั้งต่อไป เมื่อเดินทางกลับเข้ามาในราชอาณาจักรแล้ว ให้มารายงานตัวแจ้งที่พักอาศัยครั้งต่อไป เมื่อครบกำหนด 90 วัน นับแต่วันเดินทางเข้ามาในราชอาณาจักร ครั้งสุดท้าย



สถานที่รับแจ้ง

งานรับแจ้งที่พักอาศัย กองกำกับการ 2 กองบังคับการตรวจคนเข้าเมือง1 ศูนย์ราชการเฉลิมพระเกียรติ 80 พรรษา ถ.แจ้งวัฒนะ เขตหลักสี่ กรุงเทพฯ สำหรับคนต่างด้าวที่อาศัยอยู่ในเขตพื้นที่กรุงเทพมหานคร

ศูนย์บริการวีซ่าและใบอนุญาตทำงาน กองกำกับการ3 กองบังคับการตรวจคนเข้าเมือง 1 อาคารจัตุรัสจามจุรีสแควร์ ชั้น 18 เขตปทุมวัน กรุงเทพฯ สำหรับคนต่างด้าวที่ทำงานในนิติบคุคคลซึ่งมีทุนจดทะเบียนไม่ต่ำกว่า 30 ล้านบาท

ด่านตรวจคนเข้าเมืองทุกแห่ง โดยแจ้งตามเขตพื้นที่ที่คนต่างด้าวพักอาศัย



การปฏิบัติเมื่อแจ้งทางไปรษณีย์ลงทะเบียน

สำเนาหนังสือเดินทางทุกหน้า(ถึงหน้าที่ได้รับอนุญาตให้อยู่ในราชอาณาจักรครั้งสุดท้าย หรือหน้าที่ได้รับการตรวจลงตราครั้งสุดท้าย)

สำเนาบัตร ตม.6 ขาออก หน้า-หลัง (TM.6)

ใบรับแจ้งการอยู่เกิน 90 วัน (กรณีที่มีการแจ้งอยู่เกิน90 วันมาแล้ว)

กรอกรายละเอียดในแบบ ตม.47 พร้อมลงลายมือชื่อให้เรียบร้อย

ซองจดหมายพร้อมติดแสตมป์ 5 บาท จ่าหน้าซองถึงคนต่างด้าว เพื่อพนักงานเจ้าหน้าที่จะได้จัดส่งใบนัดส่วนล่างของแบบ ตม.47 เมื่อรับแจ้งอยู่เกิน 90 วัน แล้ว พร้อมแบบ ตม.47 เพื่อใช้แจ้งอยู่เกิน 90 วันในครั้งต่อไป

นำเอกสารตามข้อ 1-5 ใส่ซองและจัดส่งโดยไปรษณีย์ลงทะเบียน ก่อนวันครบกำหนดการแจ้ง(ตามใบนัด) 7 วัน ทั้งนี้คนต่างด้าวจะต้องเก็บหลักฐานการลงทะเบียนไว้ โดยจ่าหน้าซองมาที่

งานรับแจ้งที่พักอาศัย

กองกำกับการ 2 กองบังคับการตรวจคนเข้าเมือง 1 สำนักงานตรวจคนเข้าเมือง

ศูนย์ราชการเฉลิมพระเกียรติ 80 พรรษา อาคารบี

120 หมู่ 3 ถนนแจ้งวัฒนะ ซอย 7 แขวงทุ่งสองห้อง เขตหลักสี่ กรุงเทพมหานคร 10120



หรือ



90 Days Report Section

Immigration Division 1 , Immigration Bureau,

Chalermprakiat Government Complex B Building

120 Moo 3 , Chaengwattana Rd., Soi 7, Toongsonghong, Laksi,

Bangkok. 10210



หมายเหตุ

การรับแจ้งที่พักอาศัย กรณีคนต่างด้วอยู่เกิน 90 วัน มิใช่ เป็นการขออยู่ต่อในราชอาณาจักร

คนต่างด้าวผู้ใดอยู่เกินกว่า 90 วัน ไม่แจ้งที่พักอาศัยต่อพนักงานเจ้าหน้าที่ หรือแจ้งช้ากว่าที่กำหนด ต้องมารายงานตัวด้วยตนเอง และเสียค่าปรับ จำนวน 2000 บาท หรือคนต่างด้าวถูกจับกุมตัวมาไม่ว่ากรณีใดๆ ต้องเสียค่าปรับ จำนวน 4000 บาท

เมื่อคนต่างด้าวเดินทางออกนอกราชอาณาจักร เมื่อเดินทางกลับมาให้เริ่มนับเวลา 90 วันใหม่ทุกกรณี

สอบถามได้ที่ โทรศัพท์ 0-2141-7881 begin_of_the_skype_highlighting 0-2141-7881 end_of_the_skype_highlighting

วันอาทิตย์ที่ 1 สิงหาคม พ.ศ. 2553

openerp

If ubuntu server is used  you have to install ubuntu-desktop first
apt-get install ubuntu-desktop


http://doc.openerp.com/book/1/1_1_Inst_Config/1_1_Inst_Config_install.html#technical-procedure-initial-installation-and-configuration
 
$ sudo apt-get update




$ sudo apt-get upgrade



$ sudo apt-get install openerp-server openerp-client pgadmin3
To avoid having some of the labels untranslated in the GTK client, install the language-pack-gnome-YOURLANG-base package. The following command installs the spanish language pack:




$ sudo apt-get install language-pack-gnome-es-basePostgres Database configuration:



$ sudo vi /etc/postgresql/8.3/main/pg_hba.confReplace the following line:



# “local” is for Unix domain socket connections only

local all all ident sameuserwith:



#”local” is for Unix domain socket connections only

local all all md5Restart Postgres:



$ sudo /etc/init.d/postgresql-8.3 restart



* Restarting PostgreSQL 8.3 database server [ OK ]The following two commands will avoid problems with /etc/init.d/openerp-web INIT script:



$ sudo mkdir /home/openerp



$ sudo chown openerp.nogroup /home/openerpCreate a user account called openerp with password “openerp” and with privileges to create Postgres databases:



$ sudo su postgres



$ createuser openerp -P



Enter password for new role: (openerp)



Enter it again:



Shall the new role be a superuser? (y/n) n



Shall the new role be allowed to create databases? (y/n) y



Shall the new role be allowed to create more new roles? (y/n) nQuit from user postgres:



$ exit



exitEdit OpenERP configuration file:



$ sudo vi /etc/openerp-server.confReplace the following two lines (we don’t force to use a specific database and we add the required password to gain access to postgres):



db_name =



db_user = openerp



db_password = openerpTroubles with Python releases: Python 2.6 is not yet supported by OpenERP 5.0, but it is the default Python release on Ubuntu 9.0.4. We need to launch OpenERP 5.0 with Python 2.5 or earlier. There’s also a problem with python-xml package in Ubuntu so we will reinstall it.



Python 2.5 setting up:



$ sudo apt-get install python2.5 python2.5-dev python-profilerReinstall python-xml:



$ wget http://freefr.dl.sourceforge.net/sourceforge/pyxml/PyXML-0.8.4.tar.gz



$ tar xvzf PyXML-0.8.4.tar.gz



$ cd PyXML-0.8.4/



$ sudo python2.5 setup.py installMake the following symbolic link:



$ sudo ln -s /usr/lib/python2.6/dist-packages/oldxml/_xmlplus/utils/boolean.so /usr/lib/python2.5/site-packages/oldxml/_xmlplus/utils/Force openerp-server to be launched with Python2.5:



$ cd /usr/bin/



$ sudo cp openerp-server openerp-server.ORIG



$ sudo vi openerp-serverReplace the following line:



exec /usr/bin/python ./openerp-server.py $@with



exec /usr/bin/python2.5 ./openerp-server.py $@We can now restart openerp-server:



$ sudo /etc/init.d/openerp-server restart



Restarting openerp-server: openerp-server.Check out the logs:



$ sudo cat /var/log/openerp.log



[2009-06-14 21:06:39,314] INFO:server:version – 5.0.0



[2009-06-14 21:06:39,314] INFO:server:addons_path – /usr/lib/openerp-server/addons



[2009-06-14 21:06:39,314] INFO:server:database hostname – localhost



[2009-06-14 21:06:39,315] INFO:server:database port – 5432



[2009-06-14 21:06:39,315] INFO:server:database user – openerp



[2009-06-14 21:06:39,315] INFO:objects:initialising distributed objects services



[2009-06-14 21:06:39,502] INFO:web-services:starting XML-RPC services, port 8069



[2009-06-14 21:06:39,502] INFO:web-services:starting NET-RPC service, port 8070



[2009-06-14 21:06:39,502] INFO:web-services:the server is running, waiting for connections…OpenERP is now up and running, connected to Postgres database on port 5432 and listening on ports 8069 and 8070



$ ps uaxww
grep -i openerp



root 2276 0.0 2.3 185576 23708 begin_of_the_skype_highlighting 185576 23708 end_of_the_skype_highlighting ? Sl 13:09 0:00 /usr/bin/python2.5 ./openerp-server.py –config=/etc/openerp-server.conf$ sudo lsof -i :8069



COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME



python2.5 2276 openerp 3u IPv4 6515 TCP localhost:8069 (LISTEN)$ sudo lsof -i :8070



COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME



python2.5 2276 openerp 5u IPv4 6520 TCP *:8070 (LISTEN)Start the Open ERP GTK client by clicking its icon in the Applications menu, or by opening a terminal window and typing tinyerp-client . The Open ERP login dialog box should open and show the message No database found you must create one!.

python2.5.5

Download the release


Source code

gzip-compressed source code: Python-2.5.5.tgz



bzip2-compressed source code: Python-2.5.5.tar.bz2, the source archive.



The bzip2-compressed version is considerably smaller, so get that one if your system has the appropriate tools to deal with it.



Unpack the archive with tar -zxvf Python-2.5.5.tgz (or bzcat Python-2.5.5.tar.bz2
tar -xf -). Change to the Python-2.5.5 directory and run the "./configure", "make", "make install" commands to compile and install Python. The source archive is also suitable for Windows users who feel the need to build their own version.

วันศุกร์ที่ 30 กรกฎาคม พ.ศ. 2553

scp

* Using SCP you could copy files remotely. Following is the general syntax.




scp @:



* Here are some examples.



Lets say user 'me' has to send the file with name test to the user 'you', while being in the me's account.



scp test you@192.168.1.1:



* The default destination is /home/you here. Unless you specify otherwise file will be copied on to the default location as in the example above. If you want to specify location, the following example will help you.



scp test you@192.168.1.1:/home/you/directory

วันพฤหัสบดีที่ 29 กรกฎาคม พ.ศ. 2553

web service

http://mpathirage.com/getting-started-with-web-services-in-php-with-ubuntu-804-4/

Denyhosts installed servers

164.115.5.126     http://www.knit.or.th/   denyhosts installed
202.44.11.50       http://www.turpif.or.th/  denyhosts installed
164.115.5.127     http://mail2.knit.or.th/     denyhosts installed
164.115.5.124     http://sp2.knit.or.th/ 

164.115.5.123     http://db.knit.or.th/

164.115.5.122     http://ns.knit.or.th/

164.115.5.128     http://riti.knit.or.th/        denyhosts installed

202.44.11.55      http://www.turpif.or.th/           denyhosts installed

First of all, references to WORK_DIR point to /var/lib/denyhosts/ or something similar on your system.


The default location for the hosts.deny file is /etc/hosts.deny.



Here's the method I used to unblock an IP:



Stop DenyHosts
/etc/init.d/denyhosts stop

Remove the IP address from hosts.deny

Remove all lines containing the IP address from the following files:



WORK_DIR/hosts

WORK_DIR/hosts-restricted

WORK_DIR/hosts-root

WORK_DIR/hosts-valid

WORK_DIR/users-hosts

Consider adding the IP address to WORK_DIR/allowed-hosts

Start DenyHosts

วันอาทิตย์ที่ 25 กรกฎาคม พ.ศ. 2553

uninstall install php 5.3

Check installed program
dpkg --get-selections

sudo apt-get remove --purge

http://php.net/downloads.php
PHP 5.3.3


Complete Source Code

■PHP 5.3.3 (tar.bz2) [10,412Kb] - 22 July 2010

md5: 21ceeeb232813c10283a5ca1b4c87b48

■PHP 5.3.3 (tar.gz) [13,595Kb] - 22 July 2010

md5: 5adf1a537895c2ec933fddd48e78d8a2
 
 
http://hublog.hubmed.org/archives/001924.html
Installing PHP 5.3 etc on Ubuntu Karmic (9.10)


Fetch and extract the latest version of PHP.

sudo apt-get build-dep php5

./configure --prefix=/opt/php5.3 \

--enable-mbstring \

--enable-soap \

--enable-sqlite-utf8 \

--enable-zip \

--with-bz2 \

--with-curl \

--with-gd \

--with-gettext \

--with-gmp \

--with-ldap \

--with-openssl \

--with-xmlrpc \

--with-zlib \

--with-xsl \

--with-mysql=mysqlnd \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-apxs2=/usr/bin/apxs2

make

sudo make -i install

(-i to ignore the error about httpd.conf)

sudo ln -s /etc/php5/apache2/php.ini /opt/php5.3/lib/php.ini

Optional: install APCsudo /opt/php5.3/bin/pecl install apc-beta

sudo nano /opt/php5.3/lib/php.ini

extension_dir = "/opt/php5.3/lib/php/extensions/no-debug-non-zts-20090626"

extension=apc.so

Optional: install FirePHPsudo /opt/php5.3/bin/pear channel-discover pear.firephp.org

sudo /opt/php5.3/bin/pear install firephp/FirePHPCore

sudo apache2ctl restart

http://thirdpartycode.com/2009/08/building-php-5-3-packages-on-ubuntu-9-04-jaunty-for-apache-2/
Prep your system


Setup your development server to be able to compile things. By default, most installations will not come with compilers installed.

view sourceprint?

1 apt-get install checkinstall

Say yes, and let it follow the dependencies as needed.

Get the development headers for some of the extensions you’ll be compiling in.

view sourceprint?

1 apt-get install postgresql-8.3 postgresql-client-8.3 postgresql-client-common postgresql-common postgresql-server-dev-8.3



2 aptitude install mysql-client mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 mysql-server-core-5.0



3



4 apt-get install libtidy-dev curl libcurl4-openssl-dev libcurl3 libcurl3-gnutls zlib1g zlib1g-dev libxslt1-dev libzip-dev libzip1 libxml2 libsnmp-base libsnmp15 libxml2-dev libsnmp-dev libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev zlib1g zlib1g-dev libfreetype6 libfreetype6-dev libbz2-dev libxpm4-dev libmcrypt-dev libmcrypt4

Download PHP and Compile it

view sourceprint?

mkdir ~/srcs
cd ~/srcs
wget http://us3.php.net/get/php-5.3.0.tar.gz/from/this/mirror
tar xvfz php-5-3-0.tar.gz
cd php-5.3.0

Now, you can either do the ./configure –help and pick your options, or you can use my configure options for PHP 5.3

./configure --prefix=/opt/php5.3 \
--enable-mbstring \
--enable-soap \
--enable-sqlite-utf8 \
--enable-zip \
--with-bz2 \
--with-curl \
--with-gd \
--with-gettext \
--with-gmp \
--with-ldap \
--with-openssl \
--with-xmlrpc \
--with-zlib \
--with-xsl \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-apxs2=/usr/bin/apxs2

View sourceprint?
make
make test
checkinstall

checkinstall will ask you some basic questions about the package, answer and let it build the package for you. You will run into an interesting issue at first, apxs2 will complain about a LoadModule not being in the httpd.conf file. This is an artifact of how Ubuntu/Debian likes to handle it’s configuration files. The simplest thing is to add a line at the bottom of your httpd.conf that loads a benign module. Mod Pony seems cute .



Configure your PHP like any normal apache server. Reload apache, put the handy phpinfo(); in your documentroot, and then have fun.

Be sure to remove the phpinfo(); from your production servers.



If you want MySQL 5.1, just do apt-get install mysql-server-5.1 , be sure to change the dev header packages to the same version as well.


I got this error when trying to configure php 5.2.6:




configure: error: xml2-config not found. Please check your libxml2 installation.



I’m using Debian and it showed that I had libxml2 installed (and it was the latest version).



It turns out that the latest stable version of libxml2 doesn’t include a file named xml2-config. I suppose I could have linked that file to the config file that the stable version of libxml2 uses, but the easy fix is to just install the newer development version of libxml2 using the following command:



apt-get install libxml2-dev

Ununtu server setup

apt-get install ubuntu-desktop

Ubuntu 10.4 installation

Step 0
During installation, select apache-php-mysql server + openssh server
Change networking from auto to manual
Input   ip address, network mask, gateway, dns server



Step 1  vi /etc/ssh/sshd_config

add
AllowUsers root viroteb
to #Authentication

restart with
/etc/init.d/ssh restart

Improve vi by install vim-nox
aptitude install vim-nox


Step 2  if  you want to change IP later,
vi /etc/network/interfaces
# This file describes the network interfaces available on your system


# and how to activate them. For more information, see interfaces(5).



# The loopback network interface

auto lo

iface lo inet loopback



# The primary network interface

auto eth0

iface eth0 inet static

address 192.168.0.100

netmask 255.255.255.0

network 192.168.0.0

broadcast 192.168.0.255

gateway 192.168.0.1

/etc/init.d/networking restart


Step 3 vi /etc/hosts

127.0.0.1 localhost.localdomain localhost


192.168.0.100 server1.example.com server1



# The following lines are desirable for IPv6 capable hosts

::1 localhost ip6-localhost ip6-loopback

fe00::0 ip6-localnet

ff00::0 ip6-mcastprefix

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

ff02::3 ip6-allhosts

echo server1.example.com > /etc/hostname


... and reboot the server:


reboot

Afterwards, run




hostname

hostname -f



Both should show server1.example.com now.




Step 4 Edit /etc/apt/sources.list. Comment out or remove the installation CD from the file and make sure that the universe and multiverse repositories are enabled. It should look like this:


vi /etc/apt/sources.list
aptitude update



to update the apt package database and


aptitude safe-upgrade



to install the latest updates (if there are any). If you see that a new kernel gets installed as part of the updates, you should reboot the system afterwards:


reboot


Step 5 aptitude install ntp ntpdate

Step  6  Install postfix
            aptitude install postfix

Step 7 Install phpmyadmin
apt-get install phpmyadmin


To set up under Apache all you need to do is include the following line in /etc/apache2/apache2.conf, first type the following command to open up this file:

vi  /etc/apache2/apache2.conf

Add the following line of code inside apache2.conf:

Include /etc/phpmyadmin/apache.conf



Now restart Apache:

sudo /etc/init.d/apache2 restart


Step 8 Install webmin
http://viroteb.blogspot.com/2010/06/how-to-install-webmin.html

Step 8 Install syslog-ng
apt-get install syslog-ng

change the path to syslog-ng in System configuration in webmin
to /etc/syslog-ng/syslog-ng.conf  so that webmin can view the syslog-ng

Step 9 Install denyhosts
apt-get install denyhosts

วันพฤหัสบดีที่ 22 กรกฎาคม พ.ศ. 2553

วันพุธที่ 21 กรกฎาคม พ.ศ. 2553

วันอังคารที่ 13 กรกฎาคม พ.ศ. 2553

วันจันทร์ที่ 12 กรกฎาคม พ.ศ. 2553

Fail2ban

http://www.cpeclub.com/board/server/fail2ban-ubuntu-9-04/

another good website explaining postfix fail2ban
http://www.howtoforge.com/forums/showthread.php?t=28781



การติดตั้ง Fail2ban บน Ubuntu 9.04


Fail2ban เป็นโปรแกรมตรวจสอบ log files และแบน IP ที่ล็อกอินผิดหลายๆครั้ง โดยสนับสนุน Service หลายตัวเช่น apache, vsftpd, proftpd, postfix, couriersmtp, named (DNS),ssl เป็นต้น

มีหลักการทำงานดังนี้ โปรแกรม Fail2ban จะตรวจสอบ Log Files เป็นระยะ ว่ามี IP ที่ล๊อคอินเข้าระบบแล้ว Fail ติดๆกัน ครบตามจำนวนที่ตั้งไว้ในไฟล์คอนฟิก จะแบน IP หมายเลขนั้นโดยไปกำหนดที่ iptable ให้ Block IP Address เมื่อแบน IP ครบตามกำหนดเวลาที่ตั้งไว้ในไฟล์คอนฟิก Fail2ban จะไปแก้ไข iptable ให้ IP Address นั้นสามารถใช้งานได้ตามเดิม

Login เป็น Root

ในการติดตั้ง Fail2ban ให้ติดตั้ง openssh ก่อน เพราะในการทดสอบ Fail2ban จะล็อกอินผ่าน openssh เพื่อทดสอบว่า Fail2ban บล็อกไอพีที่ล๊อคอินผิดเกินกว่าที่กำหนดไว้

ติดตั้ง Fail2ban โดยใช้คำสั่ง

sudo apt-get install fail2ban

โค๊ด:



ทำ การแก้ไขไฟล์คอนฟิค

โค๊ด:



cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local



โค๊ด:



nano /etc/fail2ban/jail.local





แก้ไข ไฟล์ /etc/fail2ban/jail.local ดังนี้

โค๊ด:



[DEFAULT]

ignoreip = 127.0.0.1 //กำหนด IP Address ที่ไม่มีการ Ban

bantime = 600 //กำหนดเวลา Ban IP 600 วิ = 10 นาที

//ถ้ากำหนดเป็น -1 จะหมายถึง Ban IP จนกว่าจะ Reboot

maxretry = 3 //กำหนดจำนวนครั้งของการล๊อคอินที่ผิดพลาด

destemail = mooglom@eng-ru.com //กำหนดให้ส่ง mail แจ้งเตือนไปเมล์ชื่อ mooglom@eng-ru.com



[ssh]

enabled = true

port = ssh

filter = sshd

logpath = /var/log/auth.log

maxretry = 3 //แก้จำนวนครั้งของการล๊อคอินที่ผิดพลาดจาก 6 เป็น 3



//Fail2ban สามารถตรวจสอบ Process ของโปรแกรมอื่นได้ด้วย ถ้าต้องการให้ตรวจสอบโปรแกรมใด

ให้ตั้งค่า enabled = true ตรงโปรแกรมนั้น ตัวอย่างเช่น



[ssh-ddos] //ตัวอย่างการกำหนดให้ Fail2ban ตรวจสอบ Service SSH DDos

enabled = true //เปลี่ยนจาก false เป็น true เพื่อตรวจสอบ SSH DDos

port = ssh, sftp

filter = sshd-ddos

logpath = /var/log/auth.log

maxretry = 3 //แก้จำนวนครั้งของการล๊อคอินที่ผิดพลาดจาก 6 เป็น 3



[Apache] //ในหัวข้อ Apache ให้กำหนด enabled = false

enabled = false





เมื่อ แก้ไขไฟล์ /etc/fail2ban/jail.local เสร็จ ให้บันทึกไฟล์โดยกดปุ่ม Ctrl + O แล้วกดปุ่ม Enter จากนั้นออกจากโปรแกรม nano โดยกดปุ่ม Ctrl + X

รีสตา ร์ท Fail2ban โดยใช้คำสั่ง



โค๊ด:



sudo /etc/init.d/fail2ban restart



ตรวจ สอบการทำงานของ Fail2ban

ใช้โปรแกรม PuTTY ssh เข้าไปที่เครื่องเซิพเวอร์ที่ติดตั้ง Fail2ban ลองทำการ Login โดยกรอก user และ Password ที่ผิด ตามจำนวนครั้งที่ตั้งให้แบน

ตรวจสอบ log ของ Fail2ban โดยใช้คำสั่ง

โค๊ด:



tail /var/log/fail2ban.log





จะ แสดง log ของ fail2ban



คุณไม่มีสิทธิ ในการดูไฟล์ภาพนะจ้ะ

Please register or login



จาก Log ระบบสามารถทำงานได้ปกติ โดย WARNING [ssh] Ban 192.168.130.1 คือ IP ที่ถูกแบน

ตรวจสอบไอพีที่ถูกแบนโดยใช้คำสั่ง



โค๊ด:



iptables -n -L



จะ แสดง IPtables จะพบว่า 192.168.130.1 ถูกแบนใน iptable



คุณไม่มี สิทธิ ในการดูไฟล์ภาพนะจ้ะ

Please register or login



จาก นั้นระบุ IP ที่ต้องการยกเลิกแบนไอพี โดยใช้คำสั่ง

โค๊ด:



iptables -D fail2ban-ssh -s 192.168.130.1 -j DROP



ตรวจสอบว่าได้ยกเลิกแบนไอพีหรือยัง โดยใช้คำสั่ง

โค๊ด:



iptables -n -L





จะ แสดง IPtables



คุณไม่มีสิทธิ ในการดูไฟล์ภาพนะจ้ะ

Please register or login



จะ สังเกตว่า IP 192.168.130.1 ถูกลบจาก IPtables แล้ว สามารถ login ได้ตามปกติ



เอกสารอ้างอิง

คุณไม่สามารถมองเห็นลิ้งได้.

Register or Login

crontab

http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/

How do I add jobs to cron under Linux or UNIX oses?


by Vivek Gite · 105 comments



Q. How do I add cron job under Linux or UNIX like operating system?



A. Cron job are used to schedule commands to be executed periodically i.e. to setup commands which will repeatedly run at a set time, you can use the cron jobs.



crontab is the command used to install, deinstall or list the tables used to drive the cron daemon in Vixie Cron. Each user can have their own crontab, and though these are files in /var/spool/cron/crontabs, they are not intended to be edited directly. You need to use crontab command for editing or setting up your own cron jobs.



To edit your crontab file, type the following command:



$ crontab -e

Syntax of crontab

Your cron job looks like as follows:

1 2 3 4 5 /path/to/command arg1 arg2



Where,



■1: Minute (0-59)

■2: Hours (0-23)

■3: Day (0-31)

■4: Month (0-12 [12 == December])

■5: Day of the week(0-7 [7 or 0 == sunday])

■/path/to/command - Script or command name to schedule

Same above five fields structure can be easily remembered with following diagram:



* * * * * command to be executed

- - - - -












----- Day of week (0 - 7) (Sunday=0 or 7)




------- Month (1 - 12)



--------- Day of month (1 - 31)


----------- Hour (0 - 23)

------------- Minute (0 - 59)Example(s)

If you wished to have a script named /root/backup.sh run every day at 3am, my crontab entry would look like as follows:

(a) Install your cronjob:

# crontab -e(b)Append following entry:

0 3 * * * /root/backup.shRun five minutes after midnight, every day:

5 0 * * * /path/to/commandRun at 2:15pm on the first of every month:

15 14 1 * * /path/to/commandRun at 10 pm on weekdays:

0 22 * * 1-5 /path/to/command Run 23 minutes after midnigbt, 2am, 4am ..., everyday:

23 0-23/2 * * * /path/to/commandRun at 5 after 4 every sunday:

5 4 * * sun /path/to/command





Use of operators

An operator allows you to specifying multiple values in a field. There are three operators:



1.The asterisk (*) : This operator specifies all possible values for a field. For example, an asterisk in the hour time field would be equivalent to every hour or an asterisk in the month field would be equivalent to every month.

2.The comma (,) : This operator specifies a list of values, for example: "1,5,10,15,20, 25".

3.The dash (-) : This operator specifies a range of values, for example: "5-15" days , which is equivalent to typing "5,6,7,8,9,....,13,14,15" using the comma operator.

How do I disabling Email output?

By default the output of a command or a script (if any produced), will be email to your local email account. To stop receiving email output from crontab you need to append >/dev/null 2>&1. For example:

0 3 * * * /root/backup.sh >/dev/null 2>&1To mail output to particluer email account let us say vivek@nixcraft.in you need to define MAILTO variable to your cron job:

MAILTO="vivek@nixcraft.in"

0 3 * * * /root/backup.sh >/dev/null 2>&1





Task:To list your crontab jobs use the command

Type the following command:

# crontab -lTo remove or erase all crontab jobs use the command:

# crontab -r

Use special string to save time

Instead of the first five fields, you can use any one of eight special strings. It will not just save your time but it will improve readability.



Special string Meaning

@reboot Run once, at startup.

@yearly Run once a year, "0 0 1 1 *".

@annually (same as @yearly)

@monthly Run once a month, "0 0 1 * *".

@weekly Run once a week, "0 0 * * 0".

@daily Run once a day, "0 0 * * *".

@midnight (same as @daily)

@hourly Run once an hour, "0 * * * *".



Run ntpdate every hour:



@hourly /path/to/ntpdate

Make a backup everyday:



@daily /path/to/backup/script.sh

Understanding /etc/crontab file and /etc/cron.d/* directories

/etc/crontab is system crontabs file. Usually only used by root user or daemons to configure system wide jobs. All individual user must must use crontab command to install and edit their jobs as described above. /var/spool/cron/ or /var/cron/tabs/ is directory for personal user crontab files. It must be backup with users home directory.



Typical /etc/crontab file entries:



SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

HOME=/



# run-parts

01 * * * * root run-parts /etc/cron.hourly

02 4 * * * root run-parts /etc/cron.daily

22 4 * * 0 root run-parts /etc/cron.weekly

42 4 1 * * root run-parts /etc/cron.monthlyAdditionally, cron reads the files in /etc/cron.d/ directory. Usually system daemon such as sa-update or sysstat places their cronjob here. As a root user or superuser you can use following directories to configure cronjobs. You can directly drop your scripts here. run-parts command run scripts or programs in a directory via /etc/crontab



Directory Description

/etc/cron.d/ Put all scripts here and call them from /etc/crontab file.

/etc/cron.daily/ Run all scripts once a day

/etc/cron.hourly/ Run all scripts once an hour

/etc/cron.monthly/ Run all scripts once a month

/etc/cron.weekly/ Run all scripts once a week



How do I use above directories to put scripts?

Here is a sample shell script (clean.cache) to clean up cached files every 10 days. This script is directly created at /etc/cron.daliy/ directory i.e. create a file called /etc/cron.daily/clean.cache:



#!/bin/bash

CROOT="/tmp/cachelighttpd/"

DAYS=10

LUSER="lighttpd"

LGROUP="lighttpd"



# start cleaning

/usr/bin/find ${CROOT} -type f -mtime +${DAYS}
xargs -r /bin/rm



# if directory deleted by some other script just get it back

if [ ! -d $CROOT ]

then

/bin/mkdir -p $CROOT

/bin/chown ${LUSER}:${LGROUP} ${CROOT}

fi

how to create new ubuntu vm

how to create new ubuntu vm




Tuesday, January 19, 2010

10:56 AM



1. Solve problem of eth1

When image of VM is created as new VM the problem of eth1 will occure and we can see



cat /etc/udev/rules.d/70-persistent-net.rules

 looked like this:

# PCI device 0x1022:0x2000 (pcnet32)


SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:50:xx:xx", ATTR{type}=="1", NAME="eth0" (this first group has to be deleted)



# PCI device 0x1022:0x2000 (pcnet32)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:36:xx:xx", ATTR{type}=="1", NAME="eth1"



We have to change /etc/udev/rules.d/70-persistent-net.rules to

delete the first group and change the second group to "eth0"

# PCI device 0x1022:0x2000 (pcnet32)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:36:xx:xx", ATTR{type}=="1", NAME="eth0"



2. Change the ip of the vm to new ip as in

vi /etc/network/interfaces



3. reboot

4. check ifconfig

firewall

https://help.ubuntu.com/9.04/serverguide/C/firewall.html

http://www.cyberciti.biz/faq/how-do-i-block-an-ip-on-my-linux-server/


http://www.cyberciti.biz/tips/howto-block-ipaddress-with-iptables-firewall.html

How do I block specific incoming ip address?


Following iptable rule will drop incoming connection from host/IP 202.54.20.22:



iptables -A INPUT -s 202.54.20.22 -j DROP

iptables -A OUTPUT -d 202.54.20.22 -j DROPA simple shell script to block lots of IP address

If you have lots of IP address use the following shell script:



A) Create a text file:



# vi /root/ip.blocked

Now append IP address:



# Ip address block file

202.54.20.22

202.54.20.1/24

#65.66.36.87B) Create a script as follows or add following script line to existing iptables shell script:



BLOCKDB=”/root/ip.blocked”

IPS=$(grep -Ev "^#" $BLOCKDB)

for i in $IPS

do

iptables -A INPUT -s $i -j DROP

iptables -A OUTPUT -d $i -j DROP

doneC) Save and close the file.

วันอาทิตย์ที่ 11 กรกฎาคม พ.ศ. 2553

วันเสาร์ที่ 3 กรกฎาคม พ.ศ. 2553

FCKEditor

http://www.mediawiki.org/wiki/Extension:FCKeditor_%28Official%29

Internal link plugin

http://labs.groupwave.be/index.php/2007/10/23/fck-editor-plugin-internal-links/

Tar extraction

tar -xzf MeanEditor.tgz -C /usr/share/mediawiki/extensions/

วันอังคารที่ 29 มิถุนายน พ.ศ. 2553

ค่าบริการ อีเอมเอส ต่างประเทศ

http://www2.thailandpost.co.th/search_ems.asp

EMS (package) From Thai to Japan
0.5 kg        600  Baht
1.0             750
1.5            900
2.0            1050
2.5            1200
3.0            1350
3.5            1500
4.0            1630
4.5            1760
5.0            1890
5.5            2010
6.0            2130
6.5            2250
7.0            2370
7.5            2490
8.0            2610
8.5            2730
9.0           2850
9.5            2970
10.0          3090