At master, create a file editvs.php in /usr/local/virtualizor/hooks
I made an example with hetzner webservice API (need to create a user for that in hetzner robot):
PHP Code <?php
function __editvs($old_vps, $new_vps){
#Hetzner Curlcall:#curl -u user:password https://robot-ws.your-server.de/rdns/[IP] -d ptr=[HOSTNAME] -X PUT}
# Translated into PHP curl:
$ch = curl_init();
//we take the first value from $new_vps['ips'] => reset
curl_setopt($ch, CURLOPT_URL, 'https://robot-ws.your-server.de/rdns/'.reset($new_vps["ips"]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, "ptr=".$new_vps['hostname']);curl_setopt($ch, CURLOPT_USERPWD, 'YOURWEBSERVICEUSER' . ':' . 'YOURWEBSERVICEPASSWORD');
$headers = array();$headers[] = 'Content-Type: application/x-www-form-urlencoded';curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) { echo 'Error:' . curl_error($ch);}
curl_close($ch);
?>
I did not test this, but it should be enough to point you into the right direction.
remember to change your username and password in this example and to secure access to your webservice user by setting Ip restriction in the robot.
Edited by wolke : November 18, 2019, 2:50 pm |