'.PHP_EOL;
switch(strtolower($_POST['command'])){
case "eject_disk":
action_eject_disk();
break;
case "remove_device":
action_remove_device();
break;
case "connect_new_device":
action_connect_new_device();
break;
case "insert_disk":
action_insert_disk();
break;
case "delete_file":
action_delete_file();
break;
case "create_new_image":
action_create_new_image();
break;
case "restart_rascsi_service":
action_restart_rascsi_service();
break;
case "stop_rascsi_service":
action_stop_rascsi_service();
break;
case "reboot_raspberry_pi":
action_reboot_raspberry_pi();
break;
case "shutdown_raspberry_pi":
action_shutdown_raspberry_pi();
break;
default:
action_unknown_command();
break;
}
}
// // parameter check
// if(isset($_GET['restart_rascsi_service'])){
// // Restart the RaSCSI service
// exec("sudo /bin/systemctl restart rascsi.service");
// } else if(isset($_GET['stop_rascsi_service'])){
// // Stop the RaSCSI Service
// exec("sudo /bin/systemctl stop rascsi.service");
// } else if(isset($_GET['reboot_rasbperry_pi'])){
// // Reboot the Raspberry Pi
// exec("sudo /sbin/reboot");
// } 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");';
// }
// // Check if we're passed an ID
// if(isset($_GET['id'])){
// $id = $_GET['id'];
// }
// else {
// html_generate_warning('Page opened without arguments');
// }
// if(isset($_GET['type'])){
// $type = type_string_to_rasctl_type($_GET['type']);
// if(strlen($type) < 1){
// html_generate_warning('Unknown drive type: '.$_GET['type']);
// }
// $cmd = 'rasctl -i '.$id.' -c attach -t '.$type;
// // Check to see if the file name is specified
// if(isset($_GET['file'])){
// if(strcasecmp($_GET['file'],"None") != 0)
// {
// $cmd = $cmd.' -f '.$FILE_PATH.'/'.$_GET['file'];
// }
// }
// $result = "Command not ran.....";
// // Go do the actual action
// if(strlen($type) > 0){
// $result = exec($cmd);
// echo ' ';
// echo 'Ran command:
'.$cmd.'
';
// echo ' ';
// }
// // Check to see if the command succeeded
// if(strlen($result) > 0){
// html_generate_warning($result);
// }
// else {
// html_generate_success_message();
// }
// echo ' ';
// html_generate_ok_to_go_home();
// }
// else {
// html_generate_add_new_device(trim($id));
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';
echo '
Go execute...... '.$command.PHP_EOL;
// 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 disconnect SCSI ID ' . $_POST['id'].'? If the host is running, this could cause undesirable behavior.');
}
}
// function action_connect_new_device(){}
function action_insert_disk(){}
function action_create_new_image(){}
function action_delete_file(){
// Check to see if the user has confirmed
if(isset($_POST['confirmed'])){
echo ' exec(rm '.$_POST['file'].')'.PHP_EOL;
html_generate_ok_to_go_home();
}
else{
check_are_you_sure('Are you sure you want to PERMANENTLY delete '.$_POST['file'].'?');
}
}
function action_restart_rascsi_service(){
// Restart the RaSCSI service
$command = "sudo /bin/systemctl restart rascsi.service 2>&1";
exec($command, $retArray, $result);
check_result($result, $command,$retArray);
html_generate_ok_to_go_home();
}
function action_stop_rascsi_service(){
// Stop the RaSCSI service
$command = "sudo /bin/systemctl stop rascsi.service 2>&1";
exec($command, $retArray, $result);
check_result($result, $command,$retArray);
html_generate_ok_to_go_home();
}
function action_reboot_raspberry_pi(){
// Check to see if the user has confirmed
if(isset($_POST['confirmed'])){
echo(' exec(sudo reboot)');
// The unit should reboot at this point. Doesn't matter what we do now...
}
else{
check_are_you_sure("Are you sure you want to reboot the 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)');
// The unit should reboot at this point. Doesn't matter what we do now...
html_generate_ok_to_go_home();
}
else{
check_are_you_sure("Are you sure you want to shut down the Raspberry Pi?");
}
}
function action_unknown_command(){
echo '
Unknown command: '.$_POST['command'].'
'.PHP_EOL;
html_generate_ok_to_go_home();
}
function check_result($result,$command,$output){
if(!$result){
echo '