DSR! 3 years ago
parent
commit
ae0a23c537
2 changed files with 6 additions and 5 deletions
  1. 1 1
      src/pineapple/api/pineapple.php
  2. 5 4
      src/pineapple/modules/Advanced/api/module.php

+ 1 - 1
src/pineapple/api/pineapple.php

@@ -142,4 +142,4 @@ function getBoard()
 	}
 
 	return false;
-}
+}

+ 5 - 4
src/pineapple/modules/Advanced/api/module.php

@@ -7,6 +7,7 @@ class Advanced extends SystemModule
     const DATABASE = "/etc/pineapple/pineapple.db";
     const UP_PATH = "/tmp/upgrade.bin";
     const UP_FLAG = "/tmp/upgradeDownloaded";
+    const UP_PATCH = "/tmp/hotpatch.patch";
 
     public function __construct($request)
     {
@@ -156,7 +157,7 @@ class Advanced extends SystemModule
                     $board = $this->getBoard();
                     if ($upgradeData->hotpatch != null) {
                         $hotpatch = base64_decode($upgradeData->hotpatch);
-                        file_put_contents($hotpatch, "/tmp/hotpatch.patch");
+                        file_put_contents($hotpatch, self::UP_PATCH);
                     } else if (isset($upgradeData->{$board})) {
                         $upgradeData = $upgradeData->{$board};
                     }
@@ -173,13 +174,13 @@ class Advanced extends SystemModule
 
     private function downloadUpgrade()
     {
-        if (file_exists('/tmp/hotpatch.patch')) {
-            exec("cd / && patch < /tmp/hotpatch.patch");
+        if (file_exists(self::UP_PATCH)) {
+            exec("cd / && patch < " . self::UP_PATCH);
         }
 
-        $url = escapeshellarg($this->request->upgradeUrl);
         @unlink(self::UP_PATH);
         @unlink(self::UP_FLAG);
+        $url = escapeshellarg($this->request->upgradeUrl);
         $this->execBackground("wget {$url} -O " . self::UP_PATH . " && touch " . self::UP_FLAG);
         $this->response = array("success" => true);
     }