diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index b2622589..10ed4522 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -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 diff --git a/src/php/lib_rascsi.php b/src/php/lib_rascsi.php index 28476e60..dd4158f6 100644 --- a/src/php/lib_rascsi.php +++ b/src/php/lib_rascsi.php @@ -6,15 +6,15 @@ '. PHP_EOL; echo ' '. PHP_EOL; echo '

RaSCSI - 68kmla Edition

'. PHP_EOL; echo ' '. PHP_EOL; - echo '
'. PHP_EOL; - echo ' '. PHP_EOL; + echo ' '. PHP_EOL; + echo ' '. PHP_EOL; echo '

'.time().'

'. PHP_EOL; echo '
'. PHP_EOL; echo ' '. PHP_EOL; @@ -61,7 +61,7 @@ function html_generate_success_message(){ } function html_generate_ok_to_go_home(){ - echo '
'. PHP_EOL; + echo ' '. PHP_EOL; echo ' '. PHP_EOL; echo '
'. PHP_EOL; } @@ -115,10 +115,10 @@ function current_rascsi_config() { echo ' '.$scsi_ids[$id]['file'].''. PHP_EOL; echo ' '. PHP_EOL; echo '
'. PHP_EOL; - echo ' '. PHP_EOL; + echo ' '. PHP_EOL; echo ' '. PHP_EOL; echo ' '. PHP_EOL; - echo ' '. PHP_EOL; + echo ' '. PHP_EOL; echo '
'. PHP_EOL; echo '
'. PHP_EOL; echo ' '. PHP_EOL; @@ -133,9 +133,9 @@ function current_rascsi_config() { echo ' -'. PHP_EOL; echo ' '. PHP_EOL; echo ' '. PHP_EOL; - echo ' '. PHP_EOL; + echo ' '. PHP_EOL; echo ' '. PHP_EOL; - echo ' '. PHP_EOL; + echo ' '. PHP_EOL; echo '
'. PHP_EOL; echo ' '. PHP_EOL; diff --git a/src/php/rascsi.php b/src/php/rascsi.php index f412e977..b2ec3471 100644 --- a/src/php/rascsi.php +++ b/src/php/rascsi.php @@ -9,44 +9,7 @@ - - + @@ -86,19 +49,20 @@ } - echo ''; - echo '
'; - echo ' SD Card'; - echo ' '.$file_name.''; - echo ' '.file_size_from_ls($this_file).''; - echo ' '.file_category_from_file_name($file_name).''; - echo ' '.mod_date_from_ls($this_file).''; - echo ' '; - echo ' '; - echo ' '; - echo ' '; - echo '
'; - echo ''; + echo ''.PHP_EOL; + echo ' SD Card'.PHP_EOL; + echo ' '.$file_name.''.PHP_EOL; + echo ' '.file_size_from_ls($this_file).''.PHP_EOL; + echo ' '.file_category_from_file_name($file_name).''.PHP_EOL; + echo ' '.mod_date_from_ls($this_file).''.PHP_EOL; + echo ' '.PHP_EOL; + echo '
'.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo '
'.PHP_EOL; + echo ' '.PHP_EOL; + echo ''.PHP_EOL; } ?> diff --git a/src/php/rascsi_action.php b/src/php/rascsi_action.php index ae94d76c..97c6df38 100644 --- a/src/php/rascsi_action.php +++ b/src/php/rascsi_action.php @@ -3,24 +3,30 @@ - - + + + -'.PHP_EOL; + echo '
'; + echo ''.PHP_EOL; + echo ' '.PHP_EOL; + echo '

Debug stuff

'; + + echo '

Post values......................'.PHP_EOL; + echo '
'.PHP_EOL; var_dump($_POST); - echo '
'.PHP_EOL; - + echo '

Running command.... '.$_POST['command'].PHP_EOL; + echo '

'.PHP_EOL; + echo '
'; if(isset($_POST['command'])) { - echo 'Running command.... '.$_POST['command'].'

'.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 "

For now, shutdown is disabled....

"; -// 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 '
'; - // echo 'Ran command:
'.$cmd.'
'; - // echo '
'; + // echo '
'.PHP_EOL; + // echo 'Ran command:
'.$cmd.'
'.PHP_EOL; + // echo '
'.PHP_EOL; // } // // Check to see if the command succeeded // if(strlen($result) > 0){ @@ -114,7 +120,7 @@ // else { // html_generate_success_message(); // } - // echo '
'; + // echo '
'.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 '

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 '

'.$command.'

'; + check_result($result, $command, $retArray); + html_generate_ok_to_go_home(); + } + else{ + echo '

Create a new empty file

'.PHP_EOL; + echo '
'.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo '
File Name:'.PHP_EOL; + echo ' '.PHP_EOL; + echo ' Size:'.PHP_EOL; + echo ' '.PHP_EOL; + echo ' MB'.PHP_EOL; + echo ' '.PHP_EOL; + echo '
'.PHP_EOL; + echo '
'.PHP_EOL; + echo '
Note: Creating a large file may take a long time!'.PHP_EOL; + echo '

'.PHP_EOL; + echo '
'.PHP_EOL; + echo ' '.PHP_EOL; + echo '
'.PHP_EOL; + } +} + function action_delete_file(){ // Check to see if the user has confirmed if(isset($_POST['confirmed'])){ - echo '
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('
exec(sudo reboot)'); + echo('
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('
exec(sudo shutdown -h now)'); + echo('
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 '

Command succeeded!

'.PHP_EOL; + echo '

Command succeeded!

'.PHP_EOL; } else{ echo '

Command failed!

'.PHP_EOL; } - echo '
'.$command.''.PHP_EOL; - echo '
Output:'.PHP_EOL; - foreach($output as $line){ - echo '
Error message: '.$line.PHP_EOL; + echo '
'.$command.'
'.PHP_EOL; + if(count($output) > 0){ + echo '
Output:'.PHP_EOL; + foreach($output as $line){ + echo '
Error message: '.$line.PHP_EOL; + } + echo '
'.PHP_EOL; } - echo '
'.PHP_EOL; } function check_are_you_sure($prompt){ - echo '

'.$prompt.'

'; + echo '

'.$prompt.'

'.PHP_EOL; echo ' '.PHP_EOL; echo ' '.PHP_EOL; echo ' '.PHP_EOL; echo ' '.PHP_EOL; echo '
'.PHP_EOL; @@ -224,31 +271,33 @@ function check_are_you_sure($prompt){ echo ''.PHP_EOL; } echo ' '.PHP_EOL; - echo ' '.PHP_EOL; + echo ' '.PHP_EOL; echo ' '.PHP_EOL; echo '
'.PHP_EOL; } -function action_connect_new_device($id){ - echo '

Add New Device

'; - echo '
'; - echo ' '; - echo ' '; - echo ' '; - echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo '
SCSI ID:'; - echo ' '; +function action_connect_new_device(){ + $id = $_POST['id']; + echo '

Add New Device

'.PHP_EOL; + echo ''.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '; - echo ' '; - echo ' '; - echo ' '; - echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '; - echo ' '; - echo ' '; - echo '
SCSI ID:'.PHP_EOL; + echo ' '.PHP_EOL; echo $id; - echo ' Device:'; - html_generate_scsi_type_select_list(); - echo ' File:'; - echo ' Device:'.PHP_EOL; + html_generate_scsi_type_select_list(); + echo ' File:'.PHP_EOL; + echo ' '; - echo ' '; - echo ' '; - echo '
'; + echo ' '.PHP_EOL; + echo '
'.PHP_EOL; + echo ' '.PHP_EOL; + echo '
'.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'; +} + ?> - - + + + \ No newline at end of file