Hi All,
I just created a domain_create_post.sh script in our DA installation that will automatically create a URL alias named "/stats" where each account's web stats data lives. That is working well for all accounts created from here forward.
Now I would like to go back an add this alias for all existing accounts. I have written a shell script for our Redhat 9 box that will call a Perl in-place substitution for each account that doesn't already have the /stats URL set up.
The script seems to work fine, but the odd thing is - something is reverting the change on me, and I can't figure out what it is. Does DA detect when the httpd.conf files have been changed "out from under it" and change them back?
The input to my shell script is like the following:
user1/httpd.conf
user2/httpd.conf
user3/httpd.conf
The script itself is this:
#!/bin/sh
# This script will add the stats URL to any site that does not
# already have it.
if [ -f /tmp/nostats.txt ]; then
for CONF in `head -1 /tmp/nostats.txt`; do
export username=`echo $CONF | cut -f1 -d/`
export domain=`cat $username/domains.list`
echo Adding stats URL to user $username...
perl -i.bak /usr/local/directadmin/scripts/custom/add_stats_url.pl /usr/local/directadmin/data/users/$username/httpd.conf
done
# Restart Apache
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
else
echo Cannot find the /tmp/nostats.txt file
exit 1
fi
And finally, the Perl script that is called is here:
$/="\0";
$_=<>;
my $statsLine = "\nAlias /stats /home/" . $ENV{'username'} . "/domains/" . $ENV{'domain'} . "/stats/";
s#^(<VirtualHost.*?)$#$1$statsLine#gm;
print;
As I said, this all seems to work fine for about 2 minutes, and then something changes the httpd.conf files back to what they were before.
If anyone has any idea why that's happening, please let me know. I don't think there is any way to do something like this with the API, so that's why I went for it at the file level.
Thank you,
Greg
I just created a domain_create_post.sh script in our DA installation that will automatically create a URL alias named "/stats" where each account's web stats data lives. That is working well for all accounts created from here forward.
Now I would like to go back an add this alias for all existing accounts. I have written a shell script for our Redhat 9 box that will call a Perl in-place substitution for each account that doesn't already have the /stats URL set up.
The script seems to work fine, but the odd thing is - something is reverting the change on me, and I can't figure out what it is. Does DA detect when the httpd.conf files have been changed "out from under it" and change them back?
The input to my shell script is like the following:
user1/httpd.conf
user2/httpd.conf
user3/httpd.conf
The script itself is this:
#!/bin/sh
# This script will add the stats URL to any site that does not
# already have it.
if [ -f /tmp/nostats.txt ]; then
for CONF in `head -1 /tmp/nostats.txt`; do
export username=`echo $CONF | cut -f1 -d/`
export domain=`cat $username/domains.list`
echo Adding stats URL to user $username...
perl -i.bak /usr/local/directadmin/scripts/custom/add_stats_url.pl /usr/local/directadmin/data/users/$username/httpd.conf
done
# Restart Apache
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
else
echo Cannot find the /tmp/nostats.txt file
exit 1
fi
And finally, the Perl script that is called is here:
$/="\0";
$_=<>;
my $statsLine = "\nAlias /stats /home/" . $ENV{'username'} . "/domains/" . $ENV{'domain'} . "/stats/";
s#^(<VirtualHost.*?)$#$1$statsLine#gm;
print;
As I said, this all seems to work fine for about 2 minutes, and then something changes the httpd.conf files back to what they were before.
If anyone has any idea why that's happening, please let me know. I don't think there is any way to do something like this with the API, so that's why I went for it at the file level.
Thank you,
Greg