SHARE
TWEET

Untitled

ADrobkov Jun 17th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public function store(Request $request)
  2.     {
  3.         $id = Container::create()->id;
  4.         $ct_name = "ct".$id;       
  5.         $connection = ssh2_connect(config('ovz.ssh_ip'), config('ovz.ssh_port'));
  6.         ssh2_auth_pubkey_file($connection, config('ovz.ssh_user'), config('ovz.ssh_rsa_pub'), config('ovz.ssh_rsa'));
  7.  
  8.         $stream = ssh2_exec($connection,
  9.             'prlctl create '.$ct_name.' --vmtype ct --ostemplate '.$request['ostemplate'].';
  10.              prlctl set '.$ct_name.' --memsize '.$request['memsize'].' --size '.$request['size'].' --cpus '.$request['cpus'].' --nameserver '.$request['nameserver'].' --hostname '.$request['hostname'].' --description "'.$request['description'].'";
  11.             prlctl start '.$ct_name);
  12.  
  13.         stream_set_blocking($stream, true);
  14.         $stream_err = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
  15.         $result_err = stream_get_contents($stream_err);
  16.         if (!$result_err) {
  17.            
  18.             // return redirect('/admin/containers/'.$ct_name);  
  19.             echo $ct_name;
  20.         }
  21.         else {
  22.             echo $result_err;
  23.         }
  24.  
  25.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top