Monday, October 18, 2010

POSTFIX - Creating a restriction on sending to a particular user or group

Requirement:

email / group email: test_group001@mydomain.com
Allowed on to send on this mail is only good.user@yahoo.com


Setup:

1. Existing working smtp postfix server.

Needed configs:


1. mkdir /etc/postfix/global_restriction
2. create a file /etc/postfix/global_restriction/global_group_allowed
#/etc/postfix/global_restriction/global_group_allowed
#entry for that file:
good.user@yahoo.com OK

3. create a file /etc/postfix/global_restriction/global_group_restriction
#/etc/postfix/global_restriction/global_group_restriction
#entry for the file below:
test_group001@ class_allowed_to_send_to_global_group

4. Create a restriction class at /etc/postfix/main.cf

Below should exist on that file:

smtpd_recipient_restrictions =
check_recipient_access hash:/etc/postfix/global_restriction/global_group_restriction
permit_mynetworks
#premit my network should be under check_recipinet_access so it will not allow thus sender with network

smtpd_client_restrictions =
check_recipient_access hash:/etc/postfix/global_restriction/global_group_restriction
permit_mynetworks


smtpd_restriction_classes = class_allowed_to_send_to_global_group
class_allowed_to_send_to_global_group = check_sender_access hash:/etc/postfix/global_restriction/global_group_allowed, reject


5. After creating, postmap all related file and postfix reload

Sunday, October 17, 2010

Bash Script to process csv

Task: To process the login id and Name using CSV, and this is only a 2 column csv.

example csv

#/$HOME/file1.txt
juan.delacruz,Juan Dela Cruz
pnoy.aquino,Ninoy Aquino
ohbet.gomez,Ohbet Gomez
#eof

#Script
#!/bin/bash
#
#
#
while IFS=, read login name
do
echo NAME:$name and LOGIN ID: $login
done < /$HOME/testtxt2
#eof



Note: IFS=, where "," is the delimiter (of course, its a csv :P)


#Output
[xxx@localhost ~]$ bin/test3.sh
NAME:Juan Dela Cruz and LOGIN ID: juan.delacruz
NAME:Ninoy Aquino and LOGIN ID: pnoy.aquino
NAME:Ohbet Gomez and LOGIN ID: ohbet.gomez

Tuesday, October 12, 2010

TIPS on Creating multiple directory on linux shell

I just want to create a multiple directory ranging from a - z on my /home

here how, just so I wont forget it, need to post it here.


the command echo {a..z} will result on
# echo {a..z}
a b c d e f g h i j k l m n o p q r s t u v w x y z


so creating under /home


mkdir /home/{a..z}


will result on, when doing ls -l /home


drwxr-xr-x 2 root root 4096 Oct 12 17:32 a
drwxr-xr-x 2 root root 4096 Oct 12 17:37 b
drwxr-xr-x 2 root root 4096 Oct 12 17:37 c
drwxr-xr-x 2 root root 4096 Oct 12 17:37 d
drwxr-xr-x 2 root root 4096 Oct 12 17:37 e
drwxr-xr-x 2 root root 4096 Oct 12 17:37 f
drwxr-xr-x 2 root root 4096 Oct 12 17:37 g
drwxr-xr-x 2 root root 4096 Oct 12 17:37 h
drwxr-xr-x 2 root root 4096 Oct 12 17:37 i
drwxr-xr-x 2 root root 4096 Oct 12 17:37 j
drwxr-xr-x 2 root root 4096 Oct 12 17:37 k
drwxr-xr-x 2 root root 4096 Oct 12 17:37 l
drwxr-xr-x 2 root root 4096 Oct 12 17:37 m
drwxr-xr-x 2 root root 4096 Oct 12 17:37 n
drwxr-xr-x 2 root root 4096 Oct 12 17:37 o
drwxr-xr-x 2 root root 4096 Oct 12 17:37 p
drwxr-xr-x 2 root root 4096 Oct 12 17:37 q
drwxr-xr-x 2 root root 4096 Oct 12 17:37 r
drwxr-xr-x 2 root root 4096 Oct 12 17:37 s
drwxr-xr-x 2 root root 4096 Oct 12 17:37 t
drwxr-xr-x 2 root root 4096 Oct 12 17:37 u
drwxr-xr-x 2 root root 4096 Oct 12 17:37 v
drwxr-xr-x 2 root root 4096 Oct 12 17:37 w
drwxr-xr-x 2 root root 4096 Oct 12 17:37 x
drwxr-xr-x 2 root root 4096 Oct 12 17:37 y
drwxr-xr-x 2 root root 4096 Oct 12 17:37 z


just as what I need to do.