Access through SAMBA and use Project folder and uploader folder throught NETWORK drive.
Hello.
Thank you for a wonderful experience in your Repetier Server. I use a server with 2 printers that I am printing my projects from and want to share a work-around (sort of) that works for me.
I DO NOT garantee that all will work forever and please check your file sizes before you use this since this is just a quick hack to get functionality with Repetier Host and SAMBA.
Also one more thing, this script do not remove the directory in the uploader part inside the server if you remove the original Project. If there is someone who are willing to put time on it then please share that.
Step 1: Create a local user in your linux server. I use in this example the name repetieruploader
adduser repetieruploader
usermod -a -G dialout repetieruploader
Pick what ever password you want. It does not matter for this function.
Step 2: Setup SAMBA on your server. I am using Debian so this is how you do that on Debian.
Thank you for a wonderful experience in your Repetier Server. I use a server with 2 printers that I am printing my projects from and want to share a work-around (sort of) that works for me.
I DO NOT garantee that all will work forever and please check your file sizes before you use this since this is just a quick hack to get functionality with Repetier Host and SAMBA.
Also one more thing, this script do not remove the directory in the uploader part inside the server if you remove the original Project. If there is someone who are willing to put time on it then please share that.
Step 1: Create a local user in your linux server. I use in this example the name repetieruploader
adduser repetieruploader
usermod -a -G dialout repetieruploader
Pick what ever password you want. It does not matter for this function.
Step 2: Setup SAMBA on your server. I am using Debian so this is how you do that on Debian.
apt-get install samba nano /etc/samba/smb.conf Add the following at the bottom of that file. If you do not want people to access it you will need to setup that yourself. I am on a network that only me have access for. [RepetierServerProjects] comment = "Project Printing Directory" path = /var/lib/Repetier-Server/projects writeable = no browseable = yes public = yes guest ok = yes force user = root [RepetierServerProjectsUpload] comment = "Project Printing Directory Uploading Area" path = /home/repetieruploader/uploads writeable = yes browseable = yes public = yes guest ok = yes force user = repetieruploaderStep 3: Create the upload directory.
mkdir /home/repetieruploader/uploads chown repetieruploader:repetieruploader repetieruploader -RStep 4: Install PHP and the needed libraries apt-get install php php-curl php-xml
Step 5: Change to the repetieruploader and setup the PHP Script. nano /home/repetieruploader/crontab.php Insert the following into the script. Change the SERVERID and the KEY to your own information: <?php $localdir = "/home/repetieruploader/uploads"; $url = "http://0.0.0.0:3344/project/SERVERID"; $sess = "KEY"; function checkupload($dir){ global $localdir; global $url; global $sess; $files_r = scandir($localdir."/".$dir); foreach($files_r as $t => $file){if($file != "." && $file != ".."){ $header = array('Content-Type: multipart/form-data'); $xml = new SimpleXMLElement(file_get_contents("/var/lib/Repetier-Server/projects/".$dir."/info.xml")); $post = array('a' => 'upload','name'=>$file,'filename'=> curl_file_create($localdir."/".$dir."/".$file)); $requesturl = $url. "/upload/".$xml->base->uuid."?a=upload&apikey=".$sess; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$requesturl); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $result=json_decode(curl_exec ($ch),1); if($result["ok"]==1){ unlink($localdir."/".$dir."/".$file); } curl_close ($ch); }} } function createdir($dir){ global $localdir; if(!is_dir($localdir."/".$dir)){ if(strpos($dir,"/")!==FALSE){ $d_r = explode("/",$dir); mkdir($localdir."/".$d_r[0]); mkdir($localdir."/".$dir); }else{ mkdir($localdir."/".$dir); } } } foreach(scandir("/var/lib/Repetier-Server/projects") as $t => $file){if($file!=".." && $file != "."){ if(is_file("/var/lib/Repetier-Server/projects/".$file."/info.xml")){ createdir($file); checkupload($file); }else{ foreach(scandir("/var/lib/Repetier-Server/projects/".$file) as $t2 => $file2){ if(is_file("/var/lib/Repetier-Server/projects/".$file."/".$file2."/info.xml")){ createdir($file."/".$file2); checkupload($file."/".$file2); } } } } } ?>
Step 6: Connect to the SAMBA from your other computer with \\IP and go into the project folder and download a STL and make the gcode for it and upload to the UPLOADER share in same folder and the script will upload to that project. Step 7: Double-check the information and try out the script. After you have double-checked the information then try the script. If it runs correct it will create a few directories inside the upload folder that is named exactly same the project names.Step 8: If everything works then add the script into the crontab
crontab -e * * * * * php /home/repetieruploader/crontab.php
Comments