Well, after two days I was finally able to make the transfer successful with a PDO object. Learnes quite a lot the last to days, I’m updating the code again. After that I’ll have a look if I’m able to write it that way that it could be used for the fog project aswell (like the right UPDATE query and so on).
Posts made by Gamienator
-
RE: Choose the right location on PXE Boot - Is that possible?
-
RE: Choose the right location on PXE Boot - Is that possible?
@george1421 I promised you to stay in the loop about this topic. First the bad news: Our full stack developer just doesn’t have the time to support me with this. So what did I do? On my own 🤪 I guess if @Sebastian-Roth sees this code he’s puking or cringing how bad the code is But I’m a firsttime php coder, so please have mercy with me
So at first I created a new table with the information needed to connect to the other hosts. After that a simple PHP file with a form, that querys all of my available images and locations:
<html> <form method="post" action="transmitter.php" id="transmitting"> <?php $link = mysqli_connect("127.0.0.1", "secret", "damnsecret", "fog"); //connect Database //Check if Connection was successful and print error if not if (!$link) { echo "Fehler: konnte nicht mit MySQL verbinden." . PHP_EOL; echo "Debug-Fehlernummer: " . mysqli_connect_errno() . PHP_EOL; echo "Debug-Fehlermeldung: " . mysqli_connect_error() . PHP_EOL; exit; } //Gather all Images and create Dropdown Menu for User. if($result2 = $link->query("SELECT `imageID`,`imageName`,`imageDesc`,`imagePath`,`imageProtect`,`imageMagnetUri`,`imageDateTime`,`imageCreateBy`,`imageBuilding`,`imageSize`,`imageTypeID`,`imagePartitionTypeID`,`imageOSID`,`imageFormat`,`imageLastDeploy`,`imageCompress`,`imageEnabled`,`imageReplicate`,`imageServerSize` FROM `images`")){ echo "Transferiere Image "; echo "<select id=image name=image class='form-control' style='width:300px;'>"; while ($row = $result2->fetch_assoc()) { echo "<option value=$row[imageID]>$row[imageName]</option>"; } echo "</select>"; }else{ echo $link->error; } //Gather all installed Nodes that User can select if($result3 = $link->query("SELECT `ID`, `NodeName`, `IPAddress`, `Localmount`, `dbuser`, `dbpw`, `bwlimit` FROM `externalNode`")){ echo " zum Node "; echo "<select id=destination name=destination class='form-control' style='width:300px;'>"; while ($row = $result3->fetch_assoc()) { echo "<option value=$row[ID]>$row[NodeName]</option>"; } echo "</select>"; }else{ echo $link->error; } mysqli_close($link); ?> <input id="Senden" type="submit" name="senden" value="Senden"></html>
Then I made every storagenode available and mounted it via NFS into seperate folders into /mnt. After sending the form following php script got called:
<?php $link = mysqli_connect("127.0.0.1", "secretsauce", "damnsecretsauce", "fog"); //connect Database //Check if Connection was successful and print error if not if (!$link) { echo "Fehler: konnte nicht mit MySQL verbinden." . PHP_EOL; echo "Debug-Fehlernummer: " . mysqli_connect_errno() . PHP_EOL; echo "Debug-Fehlermeldung: " . mysqli_connect_error() . PHP_EOL; exit; } //getting all POST informations into useable variables $gotimage = $_POST["image"]; $gotdestination = $_POST["destination"]; //Query main table to retrieve all informations about the image that has to be transfered if($result = $link->query("SELECT `imageID`,`imageName`,`imageDesc`,`imagePath`,`imageProtect`,`imageMagnetUri`,`imageDateTime`,`imageCreateBy`,`imageBuilding`,`imageSize`,`imageTypeID`,`imagePartitionTypeID`,`imageOSID`,`imageFormat`,`imageLastDeploy`,`imageCompress`,`imageEnabled`,`imageReplicate`,`imageServerSize` FROM `images` WHERE `imageID`=$gotimage")){ $resultexp = $result->fetch_array(); }else{ echo $link->error; } //Query Second Table to retrieve needed information for destination host if($result2 = $link->query("SELECT `ID`, `NodeName`, `IPAddress`, `Localmount`, `dbuser`, `dbpw`, `bwlimit` FROM `externalNode`")){ $resultexp2 = $result2->fetch_array(); }else{ echo $link->error; } //making needed information useable $imageID=$resultexp['imageID']; $imagepath=$resultexp['imagePath']; echo 'Transferiere Image ' . $resultexp['imageName'] . ' ans Ziel ' . $resultexp2['NodeName']; //Query Storagegroup table to get information on which storage the image is located if($result3 = $link->query("SELECT `igaStorageGroupID` FROM `imageGroupAssoc` WHERE `igaImageID`=$imageID AND `igaPrimary`='1'")){ $resultexp3 = $result3->fetch_array(); }else{ echo $link->error; } $storageID=$resultexp3['igaStorageGroupID']; //set storagepath to needed variable if ($storageID==1) { $storagepath="/mnt/localnode/"; } elseif ($storageID==2){ $storagepath="/mnt/nvme/"; } else {echo "gibt nen Fehler, StorageID nicht gefunden."; exit; } $destpath=$resultexp2['Localmount']; echo "<p>"; //exec shell command to transfer image via rsync to destination and send mail notification after completion echo shell_exec("/usr/bin/screen -d -m /var/lib/transfer/transfer.sh " . $storagepath . " " . $imagepath . " " . $destpath . " 2>&1"); //make destination variables useable $destdbaddress=$resultexp2['IPAddress']; $destdbuser=$resultexp2['dbuser']; $destdbpw=$resultexp2['dbpw']; //connect to destination Database $link2 = mysqli_connect($destdbaddress, $destdbuser, $destdbpw, "fog_dev"); //Check if Connection was successful and print error if not if (!$link2) { echo "Fehler: konnte nicht mit MySQL verbinden." . PHP_EOL; echo "Debug-Fehlernummer: " . mysqli_connect_errno() . PHP_EOL; echo "Debug-Fehlermeldung: " . mysqli_connect_error() . PHP_EOL; exit; }
The reason I didn’t use the Replicationserve on FOG is, that I just want a simple Browserinput und when I click “send” just send it. On the other replicationservice I would log into the server and enable the service. Therefore I decided ot use rsync and let php call a little bashscript that copies is and send a mail when it’s done. The current status anyway can be looked up via SSH and screen resume command:
#!/bin/sh #start rsync with given variables /usr/bin/rsync -a -P $1$2 $3$2 #sendmail after image got transferred subject="Imagetransfer $2 abgeschlossen" /usr/sbin/sendmail mailadress@lol.de <<EOF subject:$subject Viel Erfolg! EOF echo "Sync abgeschlossen"
And what I’m now struggeling is, how to put the data into the destination database . At the moment I’m not even sure how to get the data. I already made the SQL statement: and even put in every SQL Result into a single variable
$vresultexpimageID=$resultexp['imageID']; $vresultexpimageName=$resultexp['imageName']; $vresultexpimageDesc=$resultexp['imageDesc']; $vresultexpimagePath=$resultexp['imagePath']; $vresultexpimageProtect=$resultexp['imageProtect']; $vresultexpimageMagnetUri=$resultexp['imageMagnetUri']; $vresultexpimageDateTime=$resultexp['imageDateTime']; $vresultexpimageCreateBy=$resultexp['imageCreateBy']; $vresultexpimageBuilding=$resultexp['imageBuilding']; $vresultexpimageSize=$resultexp['imageSize']; $vresultexpimageTypeID=$resultexp['imageTypeID']; $vresultexpimagePartitionTypeID=$resultexp['imagePartitionTypeID']; $vresultexpimageOSID=$resultexp['imageOSID']; $vresultexpimageFormat=$resultexp['imageFormat']; $vresultexpimageLastDeploy=$resultexp['imageLastDeploy']; $vresultexpimageCompress=$resultexp['imageCompress']; $vresultexpimageEnabled=$resultexp['imageEnabled']; $vresultexpimageReplicate=$resultexp['imageReplicate']; $vresultexpimageServerSize=$resultexp['imageServerSize']; //echo shell_exec("/var/lib/transfer/dbupdate.sh $destdbaddress $destdbuser $destdbpw $imageID"; ?>
But even then, the transmition to the destination database isn’t sucessfull. My next approach was to do it into a second batchfile, that querys the main database, export it INTO a File and then import it into the destination database, without success at the moment.
But after 12 hours straight PHP coding I need a little break I never coded php, and I can imagine I forget a lot of things, for example escaping. But after the progress I had already yesterday I though I could finish today, but it looks like no.
If I’m successul I’m answering again. But I can imagine that the approach I did isn’t quite helpful for the FOG Project
-
RE: Where are the general iPXE settings?
@Junkhacker Wow! Thanks for the hints! I’m trying out tomorrow if there are easy changes for me or not But with that said year, should be possible. I already build the normal PXE Menu:
DEFAULT menu.c32 PROMPT 0 MENU TITLE Test Boot Menu TIMEOUT 100 LABEL netboot kernel ... initrd blablabla
so maybe I’m able to chain it to that menu. Since I never used iPXE I have to investigate.
But thanks again for your help!
-
Where are the general iPXE settings?
Good Morning gentlemen,
I got a small question. Now I got another task to do: We want to establish in one of our locations a Thin Client System. My Idea is: Besides our FOG Server on that side, that on specific MAC Adresses it should just start a Live Linux System via Netboot.
Well years ago I used only the normal PXE, where I was able to write a “config” file for every MAC-Adress that asking, if I don’t had any specific config file, it just loaded the menu from the default config.
Where is that in iPXE / FOG? Or the other way asked: How could I set it up, that specific MAC-Adresses doesn’t see the iPXE Menu and boot straight into the Live Linux that I’m sharing via NFS?
Thanks in Advance for any help!
Cheers,
Gamie -
RE: Choose the right location on PXE Boot - Is that possible?
@george1421 Ok, good thing is we got a programmer in our team that can php. I’ll talk with him about that and maybe we can contribute it too.
-
RE: Choose the right location on PXE Boot - Is that possible?
@george1421 @Sebastian-Roth Sorry to dig out that older thread. I wasn’t able to work sooner on that change. Wouldn’t it be possible to automate the meta data sync? I’m thinking of using the FOG API. It should be possible to grab all the needed Informations and then update it on every other FOG server in the diffent locations. We’ve got 7 Locations and update every 3 - 4 months. So year manually updating an image could be a solution, but automated would be much better imho
Thanks!
Gamie
-
RE: Choose the right location on PXE Boot - Is that possible?
@george1421 Year, deploying directly without registration. But then we have to register every host and assign it to the location. Thanks for the clarification @george1421
-
RE: Choose the right location on PXE Boot - Is that possible?
@george1421 Okay, so it can’t be automated? Because when I was deploying without set to a specific location, it took the main storage node.
Could be a solution to use the site plugin and on every location there is a specific user?
-
Choose the right location on PXE Boot - Is that possible?
Hello erverybody,
out project to let FOG replace our currect Symantic Ghost Servers is making progress. Today we installed our first storage node on a different location. As we tried to deploy an image we noticed that the client was getting the image over WAN from the main Storage node. After we set on that host the specific location it took then the local node.
So to confirm: Every node is in the same storage group, location Plugin is enabled and the nodes are set to the specific locations. Is there anything else I have to care? Thanks for your help
Cheers,
Gamie -
RE: DHCP Service
Then you should search how to DHCP Proxy or your current DHCP Server on how to specifiy the boot file.
Search for the term “DHCP Proxy” if your current DHCP Server can’t specify a boot file.
-
Control Location replication
Hi there,
in an old Forum post I found a way to shedule replicating by disabling the two Services FOGImageReplication and FOGSnipInReplication. Since we have multiple locations and a limited upload WAN I wanted to ask you how can I control how much Replications can be done at the time? On our Internal testing I found out it checks if a replication needs to be done and start to replicate on every location at the same time.
Any Idea out there how to control that?
Cheers,
GamieBTW: I changed IMAGEREPSLEEPTIME to 60, so that after enabling the service via CRON it only takes one minute until it starts replication. Is that correct? And what happens with the replication, wenn I stop it via CRON and systemctl, does it interrupt the replication process aswell or finish it?
-
RE: Question about Variables in iPXE Configuration
Year I read the article and now watched the video.
IIUC it only uses this for the images that I created and NOT the self generated Boot entrys. But thanks for all the help. My next step is now to find out how to configure how often it should be replicated. I’ll have a look at it
-
RE: Question about Variables in iPXE Configuration
@Sebastian-Roth Sorry for the late response!
I installed the location Plugin but tbh, I don’t understand how to use it
-
RE: Question about Variables in iPXE Configuration
@Sebastian-Roth okay,
I’m using the latest version and NOT the dev branch.
-
Question about Variables in iPXE Configuration
Hello everyone,
one quick question to you: Are in the iPXE Menu settings more variables available as
${fog-ip}
The reason I’m asking is the following. I added some custom entries like the Live Mint boot, but since we have the different location, someone could then start this entry in switzerland and occupie all of our VPN Traffic while it loads all data via NFS. Not the best solution
To “resolve” this issue I had two ideas: Either I’m creating users for every location and somehow restrict the acces to that menu (if thats possible) or I’m rsync the data to every storage node and edit the bootmenu somehow with a variable like
${storage-ip}
Does such variable exist?
Cheers,
Gamie
-
RE: Linux Mint 19 V2 Emergency mode with toram Parameters
@Gurf What is the exact error message? I’m a bit confused about your line:
quiet splash
Maybe the vmlinuz and initrd.lz are in the wrong location?
-
RE: How can I troubleshoot the Diskusage Problem on the Webinterface?
Okay, everyone, I found the reason why it wasn’t working. @george1421 and @Sebastian-Roth it was NOT because I used /image1. It was a complete dumb reason!
I set up the server, that every HTTP traffic gets redirected to HTTPS. My dumb mistake: I forgot to setup SSL on the NODE! So it looks like that because I used https://fog.xyz/fog it trys to reach the nodes via SSL as well! After setting up SSL on the node, Boom:
So sorry for directing you on a complete wrong path
-
RE: How can I troubleshoot the Diskusage Problem on the Webinterface?
@george1421 Hi again,
sadly it still doesn’t work. Still with the issue, can’t retrieve server information. I’ll try now with a complete different PC on that. But is somewhere a cache that needs to be cleared?Guys, I’ll maybe found out why it wasn’t working. I’m now confirming it with some changes I’ll make. Latest tomorrow I’ll write back what was wrong the whole time!