Get docroot easily via hooks
As a Developer, I want to get docroot easily via hooks, so that I don't have to store a hash or know a user's password.
Presently if you are using hooks in cPanel&WHM getting the docroot of an account is a pain. In fact some resort to directly reading cache files (which is not recommended) as a means of doing this. However there are many scenarios where knowing an account's docroot can be very useful.
Yes this data can be accessed via the APIs but that would require either storing a hash in a place users can read it (a security risk) or knowing the user's password (not advised).
As a result an easier way to get an account's docroot easily from code executing in a hook is desired.
This is a feature that has been migrated over from the cPanel Forums. All previous comments and discussions concerning this feature can be located at:
http://forums.cpanel.net/f145/consistency-whm-verbiage-241441.html
This should be able to be retrieved from the /usr/local/apache/conf/httpd.conf using the unix utilities grep and awk, which is what I do all the time.
grep -A5 -E "Server(Name|Alias).*\ $domain" /usr/local/apache/conf/httpd.conf | awk '/DocumentRoot/ {print $2}' | head -1
I would suggest a shell hook in your application would get this information just fine. Alternatively you could read the /etc/userdatadomains where this should also be stored.
sed 's/=/ /g' /etc/userdatadomains | awk "/^$domain/"'{print $6}'
This should be able to be retrieved from the /usr/local/apache/conf/httpd.conf using the unix utilities grep and awk, which is what I do all the time.
grep -A5 -E "Server(Name|Alias).*\ $domain" /usr/local/apache/conf/httpd.conf | awk '/DocumentRoot/ {print $2}' | head -1
I would suggest a shell hook in your application would get this information just fine. Alternatively you could read the /etc/userdatadomains where this should also be stored.
sed 's/=/ /g' /etc/userdatadomains | awk "/^$domain/"'{print $6}'
Due to the age of this request and limited upvotes, I have marked it as Not Planned. Changes in future interest could warrant re-opening the request.
Due to the age of this request and limited upvotes, I have marked it as Not Planned. Changes in future interest could warrant re-opening the request.
Replies have been locked on this page!