summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apis/exec.inc.php80
-rw-r--r--templates/exec-error.html1
-rw-r--r--templates/exec-progress.html4
-rw-r--r--templates/helloworld.html5
4 files changed, 0 insertions, 90 deletions
diff --git a/apis/exec.inc.php b/apis/exec.inc.php
deleted file mode 100644
index 60ca679f..00000000
--- a/apis/exec.inc.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-
-User::load();
-
-if (!User::hasPermission('superadmin')) die('No permission');
-
-require_once('inc/render.inc.php');
-
-error_log('**URI: '. $_SERVER['REQUEST_URI']);
-
-if (!isset($_REQUEST['id'])) die('No id');
-$id = $_REQUEST['id'];
-
-// Progress update only
-
-if (isset($_REQUEST['progress'])) {
- $progress = preg_replace('/[^a-z0-9\-]/', '', $_REQUEST['progress']);
- $pid = (isset($_REQUEST['pid']) ? (int)$_REQUEST['pid'] : 0);
- $log = '/tmp/' . $progress . '.log';
- if (!file_exists($log)) {
- echo Render::parse('exec-error');
- exit(0);
- }
- $lastLines = array();
- $fh = fopen($log, 'r');
- while (!feof($fh)) {
- $line = fgets($fh);
- $lastLines[] = $line;
- if (count($lastLines) > 10) array_shift($lastLines);
- }
- fclose($fh);
- $running = ($pid == 0 || posix_kill($pid, 0));
- echo Render::parse('exec-progress', array('progress' => $progress, 'id' => $id, 'pid' => $pid, 'running' => $running, 'text' => implode('', $lastLines)));
- if (!$running) unlink($log);
- exit(0);
-}
-
-// Actual download request
-// type ip id
-
-if (!isset($_REQUEST['type'])) die('No type');
-
-
-$type = $_REQUEST['type'];
-
-switch ($type) {
-case 'ipxe':
- if (!isset($_REQUEST['ip'])) die('No IP given');
- $ip = preg_replace('/[^0-9\.]/', '', $_REQUEST['ip']);
- $default = $_REQUEST['default'];
- if (!preg_match('/openslx|hddboot/', $default)) $default = 'openslx';
- $command = '/opt/openslx/build_ipxe.sh "' . CONFIG_IPXE_DIR . '/last-ip" "' . $ip . '"';
- $conf = Render::parse('txt-ipxeconfig', array(
- 'SERVER' => $ip
- ));
- if (false === file_put_contents('/opt/openslx/ipxe/ipxelinux.ipxe', $conf)) die('Error writing iPXE Config');
- $conf = Render::parse('txt-pxeconfig', array(
- 'SERVER' => $ip,
- 'DEFAULT' => $default,
- $default => 'MENU DEFAULT'
- ));
- if (false === file_put_contents(CONFIG_TFTP_DIR . '/pxelinux.cfg/default', $conf)) die('Error writing PXE Menu');
- Database::exec("INSERT IGNORE INTO setting_global (setting, value) VALUES ('SLX_VM_NFS', :value)", array(':value' => "$ip:/srv/openslx/nfs"));
- Database::exec("UPDATE setting_global SET value = :value WHERE setting = 'SLX_VM_NFS' AND value LIKE '%:/srv/openslx/nfs' LIMIT 1", array(':value' => "$ip:/srv/openslx/nfs"));
- break;
-default:
- die('Invalid exec type');
-}
-
-$logfile = 'slx-' . mt_rand() . '-' . time();
-error_log('**EXEC: ' . "$command '/tmp/${logfile}.log'");
-exec("$command '/tmp/${logfile}.log'", $retstr, $retval);
-if ($retval != 0) {
- echo Render::parse('exec-error', array('error' => implode(' // ', $retstr) . ' - ' . $retval));
- exit(0);
-}
-$pid = 0;
-foreach ($retstr as $line) if (preg_match('/PID: (\d+)\./', $line, $out)) $pid = $out[1];
-echo Render::parse('exec-progress', array('progress' => $logfile, 'id' => $id, 'pid' => $pid, 'running' => true));
-
diff --git a/templates/exec-error.html b/templates/exec-error.html
deleted file mode 100644
index 0a82e1df..00000000
--- a/templates/exec-error.html
+++ /dev/null
@@ -1 +0,0 @@
-<div class="alert alert-danger"><p>Ausführung fehlgeschlagen!</p>{{error}}</div>
diff --git a/templates/exec-progress.html b/templates/exec-progress.html
deleted file mode 100644
index 0583a74a..00000000
--- a/templates/exec-progress.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<div class="well well-sm">
- <pre>{{text}}</pre>
- {{#running}}<script> setTimeout(function() { $('#{{id}}').load('api.php?do=exec&progress={{progress}}&id={{id}}&pid={{pid}}'); }, 2000); // </script>{{/running}}
-</div>
diff --git a/templates/helloworld.html b/templates/helloworld.html
deleted file mode 100644
index 752f1e83..00000000
--- a/templates/helloworld.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<div>
- Hello World!<br />
- Variable wurst set to {{wurst}}
-</div>
-