all_post.sh variables behavior question

ilan

Verified User
Joined
Feb 5, 2004
Messages
48
Location
Mexico City
I'm trying to build a custom email filter for one of our clients, and for that I'm trying to use the all_post.sh custom script, but something strange happens and I some guidance.

Basically what the script does that it appends to the user's filter file some extra filters, and to avoid overriding this addendum when the filters are re-writen by directadmin, I use the all_post.sh script

My problem is that the $domain variable appears to be empty for some things and not empty for others.

Trying to figure out the problem I did the following test, I wrote in the all_post.sh with only the following content:

Code:
#!/bin/sh
echo start > /tmp/deleteme.txt 
echo "$domain"  >> /tmp/deleteme.txt
echo "$command" >> /tmp/deleteme.txt
echo end  >> /tmp/deleteme.txt
exit 0;

and the output I'm receiving is:

Code:
cat /tmp/deleteme.txt
start

/CMD_EMAIL_FILTER
end

(just an empty row where the domain name should be)

Seemingly no value for $domain but apparently the following statement does work:

Code:
if ([ "$command" = "/CMD_EMAIL_FILTER" ] || [ "$command" = "/CMD_SPAMASSASSIN" ]) && [ "$domain" = "mydomain.com" ];

and it does evaluate properly both sides of the condition so the variable $domain must be having come content.

Any ideas?

Thanks in advance
 
$domain is a temporary variable. In your second code example you set it within the line, but in your script you don't set it.

Jeff
 
Thanks Jeff,

That means that in my second code, I'm not really testing for which domain the form was summited (at the email filter change), rather I'm just assigning a value to a local temporary variable. ups!

I was basing my idea on this example:
http://help.directadmin.com/item.php?id=163

I guess that the all_pre.sh and all_post.sh don't have the same variables.

Is there a way to know the domain being updated in the all_post.sh script?

Actually, what I would like to do is to test if the domain being updated is contained inside a "domains file" (in this case /etc/virtual/use_personalized_filter), something like this:

Code:
#!/bin/sh

#the following variable is grater than 0 if the domain is in the file
TMPDOMAINCOUNT=`egrep -ic "$domain" "/etc/virtual/use_personalized_filter"` 

#this checks if the file filter could be updated:
if [ "$command" = "/CMD_EMAIL_FILTER" ] || [ "$command" = "/CMD_SPAMASSASSIN" ]; then 

#this checks if the domain is in the use_personalized_filter file
  if [ $TMPDOMAINCOUNT -gt 0 ]; then 

    ... code ...

  fi
fi
exit 0;

But sadly it doesn't work.

Any suggestions would be greatly appreciated.

Ilan
 
I've never studied DirectAdmin's use of scripts; hopefully someone else will be able to reply.

Jeff
 
Can some one of the DirectAdmin team verify if this is a bug on the all_post.sh script or if the domain variable is intentionally not passed to the script.

Thanks
Ilan
 
Back
Top