Forum Moderators: coopster
The issue I have is populating the sites after it is provisioned.... I am able to provision, create the databases, populate the databases, ftp a tarball to the new site all using my PHP script but I need to know how to untar the file. I have tried shell_exec, exec, etc... and as PHP runs as "nobody", I get no love. Anybody overcome this issue in a "secure" way? Any help would be appreciated.
[edited by: Bluesprocket at 10:07 pm (utc) on July 11, 2008]
I can of course ftp individual files to the new account but the page I am trying to populate the site with is a complete site in a tar file.....ALOT of coding to create a script that creates directories and moves each file by itself....trying to cut down on that and just get this project finished....anyone know of a solution? And no..it isnt running in safe mode
[edited by: Bluesprocket at 5:14 pm (utc) on July 12, 2008]
destination_directory = "/home/#{user_name}/www/"
`sudo cp -rRp #{$source_directory}/. #{destination_directory}`
`sudo chown -R newguy:newgrp #{destination_directory}`
I don't remember exactly why though.
Hope it helps.
I imagine you could untar using sudo as well. Not sure if you can find a secure way of letting php use sudo though, especially if it's running as 'nobody'.
I imagine that you can specify a user for php to run as. Maybe in the conf file?
$output = array();
$return = null;
$command = 'Your command...';
exec($command, $output, $return);
# debug info
echo '<pre>'; print_r($output); echo '</pre>';
echo 'Return value: ' . $return;
Tell me what this script outputs.
tar -xf /path_to_dir/file.tar
simple untar command. Does absolutely nothing to the tar file. tried changing ownership of the tar file to nobody and the the account holder...doesnt work. Pretty much ready to give up and try ftp'ing each file in the tar file individually but I may have issues with creating directories so Im pretty screwed unless grant all permissions to nobody right? Huge security hole there....
I can upload a site specific script that will untar the file in the newly created directory but I cant touch off the script as the script is owned by the site.
As I said, this is so that I can dynamically provision and populate sites using whm's api. Is the only answer to this to upload each page individually? It would be so much easier if I can just send a tar or zip file to the site and open it.
[edited by: Bluesprocket at 8:36 pm (utc) on July 14, 2008]