Search K
Appearance
Appearance
Note: Usage of this hook is discouraged, it will only work for old command based requests.
Scripts that are called after all POST requests.
Heavy form checking is expected in your script as users can pass anything they'd like to try and fool your scripts with unexpected environmental variable values.
Be very very careful with this feature. It's very "raw" and can bite you if you're not careful.
Environment variables are set up according to this order:
CMD_COMMAND_NAMEVariables set higher in the list will override variables set lower in the list.
Hook scripts, triggered when the link /home/user/public_html is created or set (happens fairly often).
Note that when this process is skipped using public_html_link_set_pre.sh you'd be on your own for handling any issues that may arise from not having the link set (untested, unknown).
user.confhttp://ip/~username. The 0 method is a directory, e.g., http://ip/~username/domain.com.Script is called after the logs are rotated into the User logs path, but before the web logs are actually deleted/truncated.
As this script runs as root, it's not recommended to work on any data in the User's home path, or anywhere that a User has write access.
If you're using this to save a copy, we recommend copying it direct from the /var/log/httpd/domains/ path to another non-User-writable path.
Use any su trickery to run as the User at your own risk 😃
/var/log/httpd/domains/var/log/httpd/domainsAll emails generated by DirectAdmin (e.g., Message System notices, etc.,) are pushed through /usr/sbin/sendmail.
This script will allow you to override the sendmail call and handle the message yourself.
For example, if you want to use a remote SMTP server directly for all DA messages, you could set up some sort of wrapper in the sendmail_pre.sh to deliver them to some port 25.
directadmin.conf.directadmin.conf.directadmin.conf.directadmin.conf.MIME-Version=1.0&Content-Type=text/html (for the <html> as start of body case), for example.This hooks runs after a DirectAdmin update has finished.
No variables are passed.
The following example utilizes the all_post.sh hook script to chmod all files uploaded through the File Manager:
#!/bin/sh
CHMODVAL=700
ULPATH=/home/${username}${path}
setfile() {
if [ "$1" = "" ]; then
return;
fi
F=`echo $1 | cut -d/ -f4 | awk '{ print substr($1,1,length($1)-6) }'`
chmod ${CHMODVAL} ${ULPATH}${F}
}
TMP=/tmp/txt.txt
if [ "$command" = "/CMD_FILE_MANAGER/" ] || [ "$command" = "/CMD_FILE_MANAGER" ]; then
if [ "$action" = "upload" ]; then
setfile $file1
setfile $file2
setfile $file3
setfile $file4
setfile $file5
setfile $file6
setfile $file7
setfile $file8
fi
fi
exit 0;After several iterations of log ownership in ~/domains/domain.com/logs, the current state (as of August 2019) stores the logs as the User.
Users do have sufficient privileges to accidentally delete their logs.
Managing root-owned data under a User's home directory is very difficult to do securely, so keeping your long-term root logs in a non-User-writable area is recommended.
Create the file /usr/local/directadmin/scripts/custom/rotate_log_post.sh with 700 permissions, diradmin ownership, and the following code:
#!/bin/sh
DAYS_TO_KEEP=365
DOMAIN=`basename $file`
LONG_TERM=/var/log/httpd/long_term
DOMAIN_DIR=${LONG_TERM}/$DOMAIN
DATE=`date +%F`
DEST=${DOMAIN_DIR}/${DATE}
if [ ! -d ${DEST} ]; then
mkdir -p ${DEST}
fi
/bin/cp -n ${access_log} ${DEST}
if [ "${error_log}" != "" ]; then
/bin/cp -n ${error_log} ${DEST}
fi
find ${LONG_TERM}/* -mtime +${DAYS_TO_KEEP} -type d -exec rm -rf "{}" \;
exit 0;Since Users often delete things they shouldn't, it may be wise to prevent them from deleting things they shouldn't.
In this example, we'll block them from deleting their /public_html symbolic link using the File Manager.
First, edit the following script which will be doing the work for us:
/usr/local/directadmin/scripts/custom/all_pre.shInside this new script, add the code:
#!/bin/sh
if [ "${button}" = "delete" ]; then
if env|grep -m1 -q "=/public_html$$"; then
echo "You cannot delete your public_html link!"
exit 1
fi
fi
exit 0Then, fix the ownership and permissions:
chmod 700 /usr/local/directadmin/scripts/custom/all_pre.sh
chown diradmin. /usr/local/directadmin/scripts/custom/all_pre.sh