Quote Hi again,
I don't think you're following me.
I dont want to assign an IP because Virtualizor does that.
I want to run the receipt in order to change the network of the VPS.
My FreeBSD template DOESN'T AUTO CONFIGURE, so I need to insert in
the NEW VPS /etc/rc.conf file some lines so the NETWORK Works.
I understood that Receipt will run inside the VPS the bash script
BUT that doesnt work unless i can pass to the SCRIPT the IP ASSIGN TO
THE VPS by Virtualizor.
I can't be much more explicit sir..
Hi,
Ok, in that case no information will be available inside the VPS.
In such what you can do is you can mount the VPS and alter the /etc/rc.conf file.
For that firstly you will need to shutdown the VPS, then mount the VPS.
To get the gateway of the IP assigned to the VPS you will first need to get the ippool id to fetch the ippool details from the ippool table.
You can get the IPpool id from the ips table.
You can use the following code to do your task.
Let me know if you face any issue.
PHP Code include_once(dirname(__DIR__)'/main/funtions.php');
function __after_createvps($vps){
$vid = $vps['vpsid'];
$res = mysql_query("SELECT ippid from ips where vpsid = '.$vid.' AND primary = 1");
$row = mysql_fetch_assoc($res);
$res = mysql_query("SELECT * from ippool where ippid = '.$row['ippid'].'");
$row = mysql_fetch_assoc($res);
$gateway = $row['gateway '];
exec('virsh destroy '.$vps['vps_name']);
sleep(5);
// Mount it
$mount = mount($vid);
// Did it mount ?
if(!is_array($mount)){
return false;
}
$code = '
ifconfig_em0="inet IP.FAIL.OVER netmask 255.255.255.255 broadcast IP.FAIL.OVER"
static_routes="net1 net2"
route_net1="-net '.$gateway.'/32 IP.FAIL.OVER"
route_net2="default "'.$gateway;
file_put_contents($mount['mount_point'].'/etc/rc.conf', $code, FILE_APPEND);
// Unmount it
$umount = umount($mount);
}
Edited by asim_shaikh : September 14, 2016, 7:01 am
----------------------- Regards,
Virtualizor Team
http://www.virtualizor.com
|