Blank $HOMEDIR Variable when calling cli via php exec() function
Posted: Thu May 04, 2017 8:04 am
I have written a custom bash script which is called by php with root permissions via sudoers. The bash script adds a web domain with letsencrypt support.
My PHP my command is
My shell script is:
In my scenario, this is the best way for me to perform these functions (rather than using the vesta web api.)
After some testing because it wasn't working, I discovered that the $HOMEDIR variable in the v-add-web-domain script was blank, and that the web domain was being created in /admin/web/ NOT /home/admin/web/.
My question is how is the $HOMEDIR variable being set, and why is it blank in the above scenario?
My PHP my command is
Code: Select all
exec("sudo -u root /var/tuilder/bin/vestacp_add_domain.sh example.com 104.xxx.xxx.xx");
Code: Select all
#!/bin/bash
domain=$1
ip=$2
/usr/local/vesta/bin/v-add-web-domain admin $domain $ip www.$domain
/usr/local/vesta/bin/v-add-letsencrypt-domain admin $domain www.$domain
After some testing because it wasn't working, I discovered that the $HOMEDIR variable in the v-add-web-domain script was blank, and that the web domain was being created in /admin/web/ NOT /home/admin/web/.
My question is how is the $HOMEDIR variable being set, and why is it blank in the above scenario?