Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Vesta CLI
  • Search

Blank $HOMEDIR Variable when calling cli via php exec() function

Questions regarding the Command Line Interface
CLI
Post Reply
  • Print view
Advanced search
2 posts • Page 1 of 1
emanhig
Posts: 3
Joined: Tue Feb 23, 2016 3:39 am

Blank $HOMEDIR Variable when calling cli via php exec() function
  • Quote

Post by emanhig » 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

Code: Select all

exec("sudo -u root /var/tuilder/bin/vestacp_add_domain.sh example.com 104.xxx.xxx.xx");
My shell script is:

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
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?
Top

emanhig
Posts: 3
Joined: Tue Feb 23, 2016 3:39 am

Re: Blank $HOMEDIR Variable when calling cli via php exec() function
  • Quote

Post by emanhig » Thu May 04, 2017 9:31 am

Solved the problem.

The environmental variable $VESTA was set in the php exec environment.

Solved by doing this:

exec("VESTA='/usr/local/vesta' sudo -u root /var/tuilder/bin/vestacp_add_domain.sh example.com 104.xxx.xxx.xx");
Top


Post Reply
  • Print view

2 posts • Page 1 of 1

Return to “CLI”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password