Browse Source

command wake on lan

tags/0.1.0
Robin Thoni 8 years ago
parent
commit
1a9089db9b
1 changed files with 39 additions and 0 deletions
  1. 39
    0
      app/Http/Business/Commands/WakeOnLanCommand.php

+ 39
- 0
app/Http/Business/Commands/WakeOnLanCommand.php View File

@@ -0,0 +1,39 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: robin
5
+ * Date: 11/24/15
6
+ * Time: 5:17 PM
7
+ */
8
+
9
+namespace App\Http\Business\Commands;
10
+
11
+
12
+class WakeOnLanCommand extends AbstractCommand
13
+{
14
+
15
+    /**
16
+     * @return bool
17
+     */
18
+    public function exec()
19
+    {
20
+        $data = $this->_command->getData();
21
+        $args = [
22
+            'wakeonlan',
23
+            '-i',
24
+            $data['IP'],
25
+            '-p',
26
+            $data['Port']
27
+        ];
28
+        foreach ($data["MACs"] as $mac) {
29
+            $args[] = $mac;
30
+        }
31
+        $cli = implode(' ', $args);
32
+        $code = 0;
33
+        $output = [];
34
+        exec($cli, $output, $code);
35
+        if ($code != 0) {
36
+            abort(500, "Wakeonlan failed with code " . $code);
37
+        }
38
+    }
39
+}

Loading…
Cancel
Save