OSDN Git Service

update リポジトリ更新を搭載
authornaoko1010hh <naoko561010@gmail.com>
Thu, 23 Jul 2020 12:20:51 +0000 (21:20 +0900)
committernaoko1010hh <naoko561010@gmail.com>
Thu, 23 Jul 2020 12:20:51 +0000 (21:20 +0900)
webserver/exec.php

index 8249866..d5b86a4 100644 (file)
@@ -1,43 +1,47 @@
 <?php
 
-$cmd = 'ls -l /usr';
-exec($cmd, $opt, $return);
-$opt_str="";
-foreach ($opt as $value) {
-    $opt_str.=$value."\n";
-}
-if ($return===1) {
-    $data=[
-        "status" => "ERROR",
-        "output" => $opt_str
-    ];
-    $data = json_encode($data);
-    $context = stream_context_create(
-        array(
-            'http' => array(
-                'method'=> 'POST',
-                'header'=> 'Content-type: application/json; charset=UTF-8',
-                'content' => $data
+command("/home/naoko/alterlinux-pkgbuilds/get_from_aur.sh");
+command("/home/naoko/alterlinux-repository/scripts/main.sh");
+
+function command($cmd){
+    exec($cmd, $opt, $return);
+    $opt_str="";
+    foreach ($opt as $value) {
+        $opt_str.=$value."\n";
+    }
+    if ($return===1) {
+        $data=[
+            "status" => "ERROR",
+            "output" => $cmd."\n".$opt_str
+        ];
+        $data = json_encode($data);
+        $context = stream_context_create(
+            array(
+                'http' => array(
+                    'method'=> 'POST',
+                    'header'=> 'Content-type: application/json; charset=UTF-8',
+                    'content' => $data
+                )
             )
-        )
-    );
+        );
 
-    $responses_json = file_get_contents($argv[1], false, $context);
-}elseif ($return===0) {
-    $data=[
-        "status" => "OK",
-        "output" => $opt_str
-    ];
-    $data = json_encode($data);
-    $context = stream_context_create(
-        array(
-            'http' => array(
-                'method'=> 'POST',
-                'header'=> 'Content-type: application/json; charset=UTF-8',
-                'content' => $data
+        $responses_json = file_get_contents($argv[1], false, $context);
+    }elseif ($return===0) {
+        $data=[
+            "status" => "OK",
+            "output" => $cmd."\n".$opt_str
+        ];
+        $data = json_encode($data);
+        $context = stream_context_create(
+            array(
+                'http' => array(
+                    'method'=> 'POST',
+                    'header'=> 'Content-type: application/json; charset=UTF-8',
+                    'content' => $data
+                )
             )
-        )
-    );
+        );
 
-    $responses_json = file_get_contents($argv[1], false, $context);
-}
+        $responses_json = file_get_contents($argv[1], false, $context);
+    }
+}
\ No newline at end of file