mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-26 13:49:21 +00:00
Merge branch 'master' of https://github.com/akuker/RASCSI
This commit is contained in:
commit
e962706d4e
25
.github/workflows/c-cpp.yml
vendored
25
.github/workflows/c-cpp.yml
vendored
@ -23,17 +23,14 @@ jobs:
|
||||
# - name: make distcheck
|
||||
# run: make distcheck
|
||||
|
||||
buildroot-image:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: git-fetch buildroot
|
||||
run: git clone git://git.busybox.net/buildroot
|
||||
# - uses: actions/checkout@v2
|
||||
# with:
|
||||
# repository: 'git://git.busybox.net/buildroot'
|
||||
- name: make defconfig
|
||||
run: make raspberrypi4_defconfig
|
||||
working-directory: ./buildroot
|
||||
- name: make
|
||||
run: make all
|
||||
working-directory: ./buildroot
|
||||
# buildroot-image:
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - name: git-fetch buildroot
|
||||
# run: git clone git://git.busybox.net/buildroot
|
||||
# - name: make defconfig
|
||||
# run: make raspberrypi4_defconfig
|
||||
# working-directory: ./buildroot
|
||||
# - name: make
|
||||
# run: make all
|
||||
# working-directory: ./buildroot
|
||||
|
@ -6,15 +6,15 @@
|
||||
|
||||
<?php
|
||||
|
||||
$FILE_PATH='/home/pi/images'. PHP_EOL;
|
||||
$FILE_PATH='/home/pi/images';
|
||||
|
||||
function html_generate_header(){
|
||||
echo ' <table width="100%" >'. PHP_EOL;
|
||||
echo ' <tr style="background-color: black;">'. PHP_EOL;
|
||||
echo ' <td style="background-color: black;"><a href=http://github.com/akuker/RASCSI><h1>RaSCSI - 68kmla Edition</h1></a></td>'. PHP_EOL;
|
||||
echo ' <td style="background-color: black;">'. PHP_EOL;
|
||||
echo ' <form action="/rascsi.php">'. PHP_EOL;
|
||||
echo ' <input type="submit" value="Refresh"/>'. PHP_EOL;
|
||||
echo ' <form action="rascsi.php">'. PHP_EOL;
|
||||
echo ' <input type="submit" value="Go Home"/>'. PHP_EOL;
|
||||
echo ' <p style="color:white">'.time().'</p>'. PHP_EOL;
|
||||
echo ' </form>'. PHP_EOL;
|
||||
echo ' </td>'. PHP_EOL;
|
||||
@ -61,7 +61,7 @@ function html_generate_success_message(){
|
||||
}
|
||||
|
||||
function html_generate_ok_to_go_home(){
|
||||
echo ' <form action="/rascsi.php">'. PHP_EOL;
|
||||
echo ' <form action="rascsi.php">'. PHP_EOL;
|
||||
echo ' <input type="submit" value="OK"/>'. PHP_EOL;
|
||||
echo ' </form>'. PHP_EOL;
|
||||
}
|
||||
@ -115,10 +115,10 @@ function current_rascsi_config() {
|
||||
echo ' <td>'.$scsi_ids[$id]['file'].'</td>'. PHP_EOL;
|
||||
echo ' <td>'. PHP_EOL;
|
||||
echo ' <form action="rascsi_action.php" method="post">'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="command" value="eject" />'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="command" value="eject_disk" />'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="id" value="'.$id.'" />'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="file" value="'.$scsi_ids[$id]['file'].'" />'. PHP_EOL;
|
||||
echo ' <input type="submit" name="eject" value="Eject" />'. PHP_EOL;
|
||||
echo ' <input type="submit" name="eject_disk" value="Eject" />'. PHP_EOL;
|
||||
echo ' </form>'. PHP_EOL;
|
||||
echo ' <form action="rascsi_action.php" method="post">'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="command" value="remove_device" />'. PHP_EOL;
|
||||
@ -133,9 +133,9 @@ function current_rascsi_config() {
|
||||
echo ' <td>-</td>'. PHP_EOL;
|
||||
echo ' <td>'. PHP_EOL;
|
||||
echo ' <form action="rascsi_action.php" method="post">'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="command" value="connect_new" />'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="command" value="connect_new_device" />'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="id" value="'.$id.'" />'. PHP_EOL;
|
||||
echo ' <input type="submit" name="connect_new" value="Connect New Device" />'. PHP_EOL;
|
||||
echo ' <input type="submit" name="connect_new_device" value="Connect New Device" />'. PHP_EOL;
|
||||
echo ' </form>'. PHP_EOL;
|
||||
echo ' </td>'. PHP_EOL;
|
||||
|
||||
|
@ -9,44 +9,7 @@
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="rascsi_styles.css">
|
||||
<script>
|
||||
function compute(f) {
|
||||
if (confirm("Are you sure?"))
|
||||
alert("Yes");
|
||||
else
|
||||
alert("No");
|
||||
}
|
||||
|
||||
function eject_image(id, file) {
|
||||
var url = "eject.php?id=" + encodeURIComponent(id) + "&file=" + encodeURIComponent(file);
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
function insert_image(id, file) {
|
||||
if (confirm("Not implemented yet.... would insert " + file + " into " + id))
|
||||
alert("OK");
|
||||
}
|
||||
|
||||
function add_device(id) {
|
||||
var url = "add_device.php?id=" + encodeURIComponent(id);
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
function remove_device(id) {
|
||||
confirm_message = "Are you sure you want to disconnect ID " + id +
|
||||
"? This may cause unexpected behavior on the host computer if it is still running";
|
||||
if (confirm(confirm_message)) {
|
||||
var url = "disconnect.php?id=" + encodeURIComponent(id);
|
||||
window.location.href = url;
|
||||
}
|
||||
}
|
||||
|
||||
function delete_file(f) {
|
||||
if (confirm("Are you sure you want to delete " + f + "?"))
|
||||
alert("OK");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@ -86,19 +49,20 @@
|
||||
}
|
||||
|
||||
|
||||
echo '<tr>';
|
||||
echo ' <form>';
|
||||
echo ' <td>SD Card</td>';
|
||||
echo ' <td>'.$file_name.'</td>';
|
||||
echo ' <td>'.file_size_from_ls($this_file).'</td>';
|
||||
echo ' <td>'.file_category_from_file_name($file_name).'</td>';
|
||||
echo ' <td>'.mod_date_from_ls($this_file).'</td>';
|
||||
echo ' <td>';
|
||||
echo ' <input type="button" value="Delete" onClick="delete_file(\''.$file_name.'\')" data-arg1="'.$file_name.'"/>';
|
||||
echo ' <input type="button" value="Copy to RAM Disk" disabled/>';
|
||||
echo ' </td>';
|
||||
echo ' </form>';
|
||||
echo '</tr>';
|
||||
echo '<tr>'.PHP_EOL;
|
||||
echo ' <td>SD Card</td>'.PHP_EOL;
|
||||
echo ' <td>'.$file_name.'</td>'.PHP_EOL;
|
||||
echo ' <td>'.file_size_from_ls($this_file).'</td>'.PHP_EOL;
|
||||
echo ' <td>'.file_category_from_file_name($file_name).'</td>'.PHP_EOL;
|
||||
echo ' <td>'.mod_date_from_ls($this_file).'</td>'.PHP_EOL;
|
||||
echo ' <td>'.PHP_EOL;
|
||||
echo ' <form action="rascsi_action.php" method="post">'.PHP_EOL;
|
||||
echo ' <input type="hidden" name="command" value="delete_file"/>'.PHP_EOL;
|
||||
echo ' <input type="hidden" name="file_name" value="'.$file_name.'"/>'.PHP_EOL;
|
||||
echo ' <input type="submit" value="Delete">'.PHP_EOL;
|
||||
echo ' </form>'.PHP_EOL;
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo '</tr>'.PHP_EOL;
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
@ -3,24 +3,30 @@
|
||||
<!-- Distributed under the BSD-3 Clause License -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="rascsi_styles.css">
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="rascsi_styles.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
<?php
|
||||
include 'lib_rascsi.php';
|
||||
html_generate_header();
|
||||
|
||||
echo "Post values......................".PHP_EOL;
|
||||
echo '<br>'.PHP_EOL;
|
||||
echo '<br>';
|
||||
echo '<table>'.PHP_EOL;
|
||||
echo ' <tr><td><p style="color:gray">Debug stuff</p></td></tr>'.PHP_EOL;
|
||||
echo ' <tr><td>';
|
||||
|
||||
echo '<p style="color:gray">Post values......................'.PHP_EOL;
|
||||
echo '<br> '.PHP_EOL;
|
||||
var_dump($_POST);
|
||||
echo '<br>'.PHP_EOL;
|
||||
|
||||
echo '<br><br>Running command.... '.$_POST['command'].PHP_EOL;
|
||||
echo '<br></p>'.PHP_EOL;
|
||||
echo '</td></tr></table>';
|
||||
|
||||
if(isset($_POST['command']))
|
||||
{
|
||||
echo 'Running command.... '.$_POST['command'].'<br><br>'.PHP_EOL;
|
||||
switch(strtolower($_POST['command'])){
|
||||
case "eject_disk":
|
||||
action_eject_disk();
|
||||
@ -71,7 +77,7 @@
|
||||
// } else if(isset($_GET['shutdown_raspberry_pi'])){
|
||||
// // Shut down the Raspberry Pi
|
||||
// echo "<h1>For now, shutdown is disabled....</h1>";
|
||||
// echo 'exec("sudo /sbin/shutdown -s -t 0");';
|
||||
// echo 'exec("sudo /sbin/shutdown -s -t 0");'.PHP_EOL;
|
||||
// }
|
||||
|
||||
|
||||
@ -103,9 +109,9 @@
|
||||
// // Go do the actual action
|
||||
// if(strlen($type) > 0){
|
||||
// $result = exec($cmd);
|
||||
// echo '<br>';
|
||||
// echo 'Ran command: <pre>'.$cmd.'</pre>';
|
||||
// echo '<br>';
|
||||
// echo '<br>'.PHP_EOL;
|
||||
// echo 'Ran command: <pre>'.$cmd.'</pre>'.PHP_EOL;
|
||||
// echo '<br>'.PHP_EOL;
|
||||
// }
|
||||
// // Check to see if the command succeeded
|
||||
// if(strlen($result) > 0){
|
||||
@ -114,7 +120,7 @@
|
||||
// else {
|
||||
// html_generate_success_message();
|
||||
// }
|
||||
// echo '<br>';
|
||||
// echo '<br>'.PHP_EOL;
|
||||
// html_generate_ok_to_go_home();
|
||||
// }
|
||||
// else {
|
||||
@ -126,7 +132,7 @@ function action_eject_disk(){}
|
||||
function action_remove_device(){
|
||||
// Check to see if the user has confirmed
|
||||
if(isset($_POST['confirmed'])){
|
||||
$command = 'rasctl -i '.$_POST['id'].' -c disconnect 2>&1';
|
||||
$command = 'rasctl -i '.$_POST['id'].' -c disconnect 2>&1'.PHP_EOL;
|
||||
echo '<br><br> Go execute...... '.$command.PHP_EOL;
|
||||
// exec($command, $retArray, $result);
|
||||
// check_result($result, $command,$retArray);
|
||||
@ -138,15 +144,54 @@ function action_remove_device(){
|
||||
}
|
||||
// function action_connect_new_device(){}
|
||||
function action_insert_disk(){}
|
||||
function action_create_new_image(){}
|
||||
function action_create_new_image(){
|
||||
// If we already know the size & filename, we can go create the image...
|
||||
if(isset($_POST['size']) && isset($_POST['file_name'])){
|
||||
$command = 'dd if=/dev/zero of='.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'].' bs=1M count='.$_POST['size'];
|
||||
exec($command, $retArray, $result);
|
||||
echo '<br><br>'.$command.'<br><br>';
|
||||
check_result($result, $command, $retArray);
|
||||
html_generate_ok_to_go_home();
|
||||
}
|
||||
else{
|
||||
echo '<h2>Create a new empty file</h2>'.PHP_EOL;
|
||||
echo '<form action=rascsi_action.php method="post">'.PHP_EOL;
|
||||
echo ' <input type="hidden" name="command" value="'.$_POST['command'].'"/>'.PHP_EOL;
|
||||
echo ' <table style="border: none">'.PHP_EOL;
|
||||
echo ' <tr style="border: none">'.PHP_EOL;
|
||||
echo ' <td style="border: none">File Name:</td>'.PHP_EOL;
|
||||
echo ' <td style="border: none">'.PHP_EOL;
|
||||
echo ' <input type="text" name=file_name value="'.get_new_filename().'"/>'.PHP_EOL;
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' <td style="border: none"> Size:</td>'.PHP_EOL;
|
||||
echo ' <td style="border: none">'.PHP_EOL;
|
||||
echo ' <input type="number" name=size value="10""/>'.PHP_EOL;
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' <td style="border: none">MB</td>'.PHP_EOL;
|
||||
echo ' <td style="border: none">'.PHP_EOL;
|
||||
echo ' <input type="submit" name="create" value="Create New" />'.PHP_EOL;
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' </tr>'.PHP_EOL;
|
||||
echo ' </table>'.PHP_EOL;
|
||||
echo '</form>'.PHP_EOL;
|
||||
echo '<br><i>Note: Creating a large file may take a long time!</i>'.PHP_EOL;
|
||||
echo '<br><br>'.PHP_EOL;
|
||||
echo '<form action="rascsi.php" method="post">'.PHP_EOL;
|
||||
echo ' <input type="submit" name="cancel" value="Cancel" />'.PHP_EOL;
|
||||
echo '</form>'.PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
function action_delete_file(){
|
||||
// Check to see if the user has confirmed
|
||||
if(isset($_POST['confirmed'])){
|
||||
echo '<br>exec(rm '.$_POST['file'].')'.PHP_EOL;
|
||||
$command = 'rm '.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'];
|
||||
exec($command, $retArray, $result);
|
||||
check_result($result, $command, $retArray);
|
||||
html_generate_ok_to_go_home();
|
||||
}
|
||||
else{
|
||||
check_are_you_sure('Are you sure you want to PERMANENTLY delete '.$_POST['file'].'?');
|
||||
check_are_you_sure('Are you sure you want to PERMANENTLY delete '.$_POST['file_name'].'?');
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,7 +214,7 @@ function action_stop_rascsi_service(){
|
||||
function action_reboot_raspberry_pi(){
|
||||
// Check to see if the user has confirmed
|
||||
if(isset($_POST['confirmed'])){
|
||||
echo('<br>exec(sudo reboot)');
|
||||
echo('<br>exec(sleep 2 && sudo reboot)');
|
||||
// The unit should reboot at this point. Doesn't matter what we do now...
|
||||
}
|
||||
else{
|
||||
@ -180,7 +225,7 @@ function action_reboot_raspberry_pi(){
|
||||
function action_shutdown_raspberry_pi(){
|
||||
// Check to see if the user has confirmed
|
||||
if(isset($_POST['confirmed'])){
|
||||
echo('<br>exec(sudo shutdown -h now)');
|
||||
echo('<br>exec(sleep 2 && sudo shutdown -h now)');
|
||||
// The unit should reboot at this point. Doesn't matter what we do now...
|
||||
html_generate_ok_to_go_home();
|
||||
}
|
||||
@ -196,21 +241,23 @@ function action_unknown_command(){
|
||||
|
||||
function check_result($result,$command,$output){
|
||||
if(!$result){
|
||||
echo '<br><h2>Command succeeded!<h2>'.PHP_EOL;
|
||||
echo '<br><h2>Command succeeded!</h2>'.PHP_EOL;
|
||||
}
|
||||
else{
|
||||
echo '<br><h2>Command failed!</h2>'.PHP_EOL;
|
||||
}
|
||||
echo '<br><code>'.$command.'</code>'.PHP_EOL;
|
||||
echo '<br>Output:<code>'.PHP_EOL;
|
||||
foreach($output as $line){
|
||||
echo '<br> Error message: '.$line.PHP_EOL;
|
||||
echo '<br><code>'.$command.'</code><br>'.PHP_EOL;
|
||||
if(count($output) > 0){
|
||||
echo '<br>Output:<code>'.PHP_EOL;
|
||||
foreach($output as $line){
|
||||
echo '<br> Error message: '.$line.PHP_EOL;
|
||||
}
|
||||
echo '</code>'.PHP_EOL;
|
||||
}
|
||||
echo '</code>'.PHP_EOL;
|
||||
}
|
||||
|
||||
function check_are_you_sure($prompt){
|
||||
echo '<br><h2>'.$prompt.'</h2>';
|
||||
echo '<br><h2>'.$prompt.'</h2>'.PHP_EOL;
|
||||
echo ' <table style="border: none">'.PHP_EOL;
|
||||
echo ' <tr style="border: none">'.PHP_EOL;
|
||||
echo ' <td style="border: none; vertical-align:top;">'.PHP_EOL;
|
||||
@ -224,31 +271,33 @@ function check_are_you_sure($prompt){
|
||||
echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'.PHP_EOL;
|
||||
}
|
||||
echo ' <input type="hidden" name="confirmed" value="yes" />'.PHP_EOL;
|
||||
echo ' <input type="submit" name="do_it" value="Do it!" />'.PHP_EOL;
|
||||
echo ' <input type="submit" name="do_it" value="Yes" />'.PHP_EOL;
|
||||
echo ' </form>'.PHP_EOL;
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' </tr>'.PHP_EOL;
|
||||
echo '</table>'.PHP_EOL;
|
||||
}
|
||||
|
||||
function action_connect_new_device($id){
|
||||
echo '<h2>Add New Device</h2>';
|
||||
echo '<form action=add_device.php method="post">';
|
||||
echo ' <table style="border: none">';
|
||||
echo ' <tr style="border: none">';
|
||||
echo ' <td style="border: none">SCSI ID:</td>';
|
||||
echo ' <td style="border: none">';
|
||||
echo ' <input type="hidden" name=id value="'.$id.'"/>';
|
||||
function action_connect_new_device(){
|
||||
$id = $_POST['id'];
|
||||
echo '<h2>Add New Device</h2>'.PHP_EOL;
|
||||
echo '<form action=rascsi_action.php method="post">'.PHP_EOL;
|
||||
echo ' <input type="hidden" name="command" value="'.$_POST['command'].'"/>'.PHP_EOL;
|
||||
echo ' <table style="border: none">'.PHP_EOL;
|
||||
echo ' <tr style="border: none">'.PHP_EOL;
|
||||
echo ' <td style="border: none">SCSI ID:</td>'.PHP_EOL;
|
||||
echo ' <td style="border: none">'.PHP_EOL;
|
||||
echo ' <input type="hidden" name=id value="'.$id.'"/>'.PHP_EOL;
|
||||
echo $id;
|
||||
echo ' </td>';
|
||||
echo ' <td style="border: none">Device:</td>';
|
||||
echo ' <td style="border: none">';
|
||||
html_generate_scsi_type_select_list();
|
||||
echo ' </td>';
|
||||
echo ' <td style="border: none">File:</td>';
|
||||
echo ' <td style="border: none">';
|
||||
echo ' <select name="file">';
|
||||
echo ' <option value="None">None</option>';
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' <td style="border: none">Device:</td>'.PHP_EOL;
|
||||
echo ' <td style="border: none">'.PHP_EOL;
|
||||
html_generate_scsi_type_select_list();
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' <td style="border: none">File:</td>'.PHP_EOL;
|
||||
echo ' <td style="border: none">'.PHP_EOL;
|
||||
echo ' <select name="file">'.PHP_EOL;
|
||||
echo ' <option value="None">None</option>'.PHP_EOL;
|
||||
$all_files = get_all_files();
|
||||
foreach(explode(PHP_EOL, $all_files) as $this_file){
|
||||
if(strpos($this_file, 'total') === 0){
|
||||
@ -263,17 +312,29 @@ function action_connect_new_device($id){
|
||||
continue;
|
||||
}
|
||||
|
||||
echo '<option value="'.$file_name.'">'.$file_name.'</option>';
|
||||
echo '<option value="'.$file_name.'">'.$file_name.'</option>'.PHP_EOL;
|
||||
}
|
||||
echo ' </select>';
|
||||
echo ' </td>';
|
||||
echo ' <td style="border: none">';
|
||||
echo ' <INPUT type="submit" value="Add"/>';
|
||||
echo ' </td>';
|
||||
echo ' </tr>';
|
||||
echo ' </table>';
|
||||
echo ' </select>'.PHP_EOL;
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' <td style="border: none">'.PHP_EOL;
|
||||
echo ' <INPUT type="submit" value="Add"/>'.PHP_EOL;
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' </tr>'.PHP_EOL;
|
||||
echo ' </table>'.PHP_EOL;
|
||||
}
|
||||
|
||||
function get_new_filename(){
|
||||
// Try to find a new file name that doesn't exist.
|
||||
$i=1;
|
||||
while(file_exists($GLOBALS['FILE_PATH'].'/'.'new_file'.$i.'.hda'))
|
||||
{
|
||||
$i = $i+1;
|
||||
}
|
||||
return 'new_file'.$i.'.hda';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user