Howto : Urchin user and domain creation

interfasys

Verified User
Joined
Oct 31, 2003
Messages
2,100
Location
Switzerland
Howto : Urchin / DA Sync

This Howto will help you keep Urchin in sync with your users and domain names.

I turned on UTM reporting as default so that users can easily take advantage of that feature.

The user script creates users that use french for reporting, but you can easily change this by switching from fr to en. I'm using the edit command on FreeBSD, but pico -w works.

I'll update it to correct errors and to improve it if you give me feedback ;)

The only thing I'm not able to test and I think might not be right is the part about the log archive. Comments welcome.

LIST OF KNOWN PROBLEMS:
When you delete a domain, it is not removed from the list of profiles a user can see. This doesn't cause any problems as Urchin has an integrity verification system, but if you watch the user summary, you'll see the problem.

DISCLAIMER:
Use at your own risk. This script could wipe your data or kill your server and I won't be responsible.

ACKNOWLEDGMENT:
This is based on work from ProWebUK and the Ensim control Panel.

HISTORY:
1.4, Reporting set is now Basic All. Users needing UTM need to install the utm package and notify the sysadmin
1.3, removed the log archive profile. not needed since profile is created when a domain is added.
1.2, when a new domain is added, it's profile is added to the urchin user.
1.1, fixed the user creation problem by putting the script in user_create_pre.sh


Here it is...

///////////////
USER CREATE

# cd /usr/local/directadmin/scripts/custom
# edit user_create_pre.sh

Paste this:
Code:
#!/bin/sh

URCHINPATH="/usr/local/urchin"
OUTPUT="/tmp/urchin-temp.conf"

echo "<User Name="$username">" >> $OUTPUT
echo " cs_language=fr" >> $OUTPUT
echo " cs_region=fr" >> $OUTPUT
echo " ct_fullname="$email"" >> $OUTPUT
echo " ct_name=$username" >> $OUTPUT
echo " ct_password=$passwd" >> $OUTPUT
echo "</User>" >> $OUTPUT

$URCHINPATH/util/uconf-import -f $OUTPUT
rm -f $OUTPUT
exit 0


Modify permissions:
# chmod 755 user_create_pre.sh

Now a user should be able to log into the Urchin control panel using his DA username and password.

///////////////
DOMAIN CREATE

# edit domain_create_post.sh

Paste this :
Code:
#!/bin/sh

URCHINPATH="/usr/local/urchin"
OUTPUT="/tmp/urchin-temp.conf"

echo "<Profile Name="$domain">" > $OUTPUT
echo " cs_llist=$domain-access-log,$domain-access-log.[1-4]" >> $OUTPUT
echo " cs_reportset=UTM-Enabled_All" >> $OUTPUT
echo " cs_timeoffset=-21600" >> $OUTPUT
echo " cs_ulist=$username" >> $OUTPUT
echo " ct_defaultpage=index.html" >> $OUTPUT
echo " ct_downloads=ace,avi,bin,dmg,doc,eps,exe,fla,gz,hqx,mov,mp3,mpeg,pdf,pkg,ppt,qt,rar,sh,sit,tar,wav,xls,zip" >> $OUTPUT
echo " ct_mimes=css,cur,gif,ico,ida,jpeg,jpg,js,png,swf" >> $OUTPUT
echo " ct_name=$domain" >> $OUTPUT
echo " ct_reportdomains=www.$domain,secure.$domain,$domain" >> $OUTPUT
echo " ct_utmdomain=$domain" >> $OUTPUT
echo " ct_website=http://www.$domain" >> $OUTPUT
echo "</Profile>" >> $OUTPUT
echo >> $OUTPUT
echo "<Task Name="$domain">" >> $OUTPUT
echo " cr_enabled=off" >> $OUTPUT
echo " cr_frequency=4" >> $OUTPUT
echo " cr_runnow=0" >> $OUTPUT
echo " cr_minute=5" >> $OUTPUT
echo " ct_name=$domain" >> $OUTPUT
echo "</Task>" >> $OUTPUT
echo >> $OUTPUT
echo "<Logfile Name="$domain-access-log">" >> $OUTPUT
echo " cr_type=local" >> $OUTPUT
echo " cs_logformat=ncsa" >> $OUTPUT
echo " cs_rlist=$domain" >> $OUTPUT
echo " ct_name=$domain-access-log" >> $OUTPUT
echo " ct_affiliation=(NONE)" >> $OUTPUT
echo " ct_loglocation=/var/log/httpd/domains/$domain.log" >> $OUTPUT
echo "</Logfile>" >> $OUTPUT
echo >> $OUTPUT

$URCHINPATH/util/uconf-import -f $OUTPUT
rm -f $OUTPUT

GETPARAM=`$URCHINPATH/util/uconf-driver action=get_parameter table=user name="$username" parameter=cs_rlist`
NEWPARAM=`$URCHINPATH/util/uconf-driver action=get_parameter table=logfile name="$domain-access-log" parameter=cs_rlist | tr -d '!'`

if [ $GETPARAM -eq "-1"]
then $URCHINPATH/util/uconf-driver action=set_parameter table=user name="$username" cs_rlist=!$NEWPARAM!; echo $NEWPARAM
else $URCHINPATH/util/uconf-driver action=set_parameter table=user name="$username" cs_rlist=$GETPARAM$NEWPARAM! ;echo $GETPARAM$NEWPARAM
fi

Modify permissions:
# chmod 755 domain_create_post.sh

here is a list of parameters and their role:
http://help.urchin.com/index.cgi?id=1578


You can improve integration by replacing the webalizer link in your skins by an Urchin one. To make it easier, you can even make it automatic, without a user login.

///////////////
DELETE USER:
# edit user_destroy_post.sh

Paste this:
Code:
#!/bin/sh

URCHINPATH="/usr/local/urchin"
OUTPUT="/tmp/urchin-temp.conf"

echo "action=delete table=user Name="$username"" >> $OUTPUT 

$URCHINPATH/util/uconf-driver -f $OUTPUT
rm -f $OUTPUT

# chmod 755 user_destroy_post.sh

///////////////
DELETE DOMAIN
# edit domain_destroy_post.sh

Paste this:
Code:
#!/bin/sh

URCHINPATH="/usr/local/urchin"
OUTPUT="/tmp/urchin-temp.conf"

echo "action=delete table=task name="$domain"" > $OUTPUT
echo "action=delete table=profile name="$domain"" >> $OUTPUT
echo "action=delete table=logfile name="$domain-access-log"" >> $OUTPUT
echo "action=delete table=logfile Name="$domain-access-log.[1-4]"" >> $OUTPUT

$URCHINPATH/util/uconf-driver -f $OUTPUT
rm -f $OUTPUT

# chmod 755 domain_destroy_post.sh
 
Last edited:
If someone knows sh and urchin enough to solve this, it would be nice:

1)When you delete a domain, it is not removed from the list of profiles a user can see. This doesn't cause any problems as Urchin has an integrity verification system, but if you watch the user summary, you'll see the problem.

2)I've tried to sync password between DA and Urchin (with user_modify_post.sh), but it didn't work well.
 
Back
Top