jlandes
Verified User
Hello,
I wanted to start this thread as a means to share ideas of ways that people are automating tasks in DirectAdmin using either the API or the custom scripts that get executed whenever certain actions are performed (domain creation/deletion, user creation/deletion, etc.)
Here's what I have so far:
/usr/local/directadmin/scripts/custom/domain_create_post.sh:
/usr/local/directadmin/scripts/custom/subdomain_create_post.sh:
Anyone willing to share what they have done?
I wanted to start this thread as a means to share ideas of ways that people are automating tasks in DirectAdmin using either the API or the custom scripts that get executed whenever certain actions are performed (domain creation/deletion, user creation/deletion, etc.)
Here's what I have so far:
/usr/local/directadmin/scripts/custom/domain_create_post.sh:
Code:
#!/bin/sh
#Create default mail aliases for the domain
FILE=/etc/virtual/$domain/aliases
mv $FILE $FILE.tmp
echo "abuse: $username" > $FILE
echo "admin: $username" >> $FILE
echo "postmaster: $username" >> $FILE
echo "webmaster: $username" >> $FILE
cat $FILE.tmp >> $FILE
rm -f $FILE.tmp
chown mail:mail $FILE
chmod 600 $FILE
#Create web link for domain usage stats
DIR=/home/$username/domains/$domain/public_html
cd $DIR
ln -s ../stats stats
chown -h $username:$username stats
#Setup a link from private_html to public_html
DIR=/home/$username/domains/$domain
cd $DIR
rm -rf private_html
ln -s ./public_html private_html
chown -h $username:$username private_html
exit 0;
/usr/local/directadmin/scripts/custom/subdomain_create_post.sh:
Code:
#!/bin/sh
#Create web link for subdomain usage stats
DIR=/home/$username/domains/$domain/public_html/$subdomain
cd $DIR
ln -s ../../stats/$subdomain stats
chown -h $username:$username stats
#Create default index page for the subdomain
TEMPLATE_DIR=/usr/local/directadmin/data/templates/custom
TEMPLATE_FILE=$TEMPLATE_DIR/subdomain_placeholder.html
DEST_DIR=/home/$username/domains/$domain/public_html/$subdomain
DEST_FILE=$DEST_DIR/index.html
cp $TEMPLATE_FILE $DEST_FILE
chmod 644 $DEST_FILE
chown $username:$username $DEST_FILE
STR="perl -pi -e 's/\|SUBDOMAIN\|/$subdomain.$domain/' $DEST_FILE"
eval $STR;
exit 0;
Anyone willing to share what they have done?

Last edited: