diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..5ceb3864
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+venv
diff --git a/easyinstall.sh b/easyinstall.sh
index c3535c45..a3701188 100755
--- a/easyinstall.sh
+++ b/easyinstall.sh
@@ -34,7 +34,7 @@ function initialChecks() {
fi
if [ ! -d ~/RASCSI ]; then
- echo "You must checkout RASCSI repo into /user/pi/RASCSI"
+ echo "You must checkout RASCSI repo into /home/pi/RASCSI"
echo "$ git clone git@github.com:akuker/RASCSI.git"
exit 2
fi
@@ -46,9 +46,9 @@ function initialChecks() {
function installRaScsi() {
sudo apt-get update && sudo apt-get install --yes git libspdlog-dev
- cd ~/RASCSI/src/raspberrypi
- make all CONNECT_TYPE=FULLSPEC
- sudo make install CONNECT_TYPE=FULLSPEC
+ cd ~/RASCSI/src/raspberrypi
+ make all CONNECT_TYPE=FULLSPEC
+ sudo make install CONNECT_TYPE=FULLSPEC
sudoIsReady=$(sudo grep -c "rascsi" /etc/sudoers)
@@ -61,35 +61,28 @@ www-data ALL=NOPASSWD: /bin/systemctl stop rascsi.service
www-data ALL=NOPASSWD: /sbin/shutdown, /sbin/reboot
" >> /etc/sudoers'
fi
-
- sudo systemctl restart rsyslog
- sudo systemctl enable rascsi # optional - start rascsi at boot
- sudo systemctl start rascsi
-
+
+ sudo systemctl restart rsyslog
+ sudo systemctl enable rascsi # optional - start rascsi at boot
+ sudo systemctl start rascsi
}
-# install everything required to run an HTTP server (Apache+PHP)
-# configure PHP
-# install
+function stopOldWebInterface() {
+ APACHE_STATUS=$(sudo systemctl status apache2 &> /dev/null; echo $?)
+ if [ $APACHE_STATUS -eq 0 ] ; then
+ echo "Stopping old Apache2 RaSCSI Web..."
+ sudo systemctl disable apache2
+ sudo systemctl stop apache2
+ fi
+}
+
+# install everything required to run an HTTP server (Nginx + Python Flask App)
function installRaScsiWebInterface() {
-
- sudo apt install apache2 php libapache2-mod-php -y
-
- sudo cp ~/RASCSI/src/php/* /var/www/html
+ stopOldWebInterface
+ sudo apt install genisoimage python3 python3-venv nginx -y
-
- PHP_CONFIG_FILE=/etc/php/7.3/apache2/php.ini
-
- #Comment out any current configuration
- sudo sed -i.bak 's/^post_max_size/#post_max_size/g' $PHP_CONFIG_FILE
- sudo sed -i.bak 's/^upload_max_filesize/#upload_max_filesize/g' $PHP_CONFIG_FILE
-
- sudo bash -c 'PHP_CONFIG_FILE=/etc/php/7.3/apache2/php.ini && echo "
-# RaSCSI high upload limits
-upload_max_filesize = 1200M
-post_max_size = 1200M
-
-" >> $PHP_CONFIG_FILE'
+ sudo cp -f ~/RASCSI/src/web/service-infra/nginx-default.conf /etc/nginx/sites-available/default
+ sudo cp -f ~/RASCSI/src/web/service-infra/502.html /var/www/html/502.html
mkdir -p $VIRTUAL_DRIVER_PATH
chmod -R 775 $VIRTUAL_DRIVER_PATH
@@ -97,30 +90,38 @@ post_max_size = 1200M
sudo usermod -a -G pi www-data
groups www-data
- sudo /etc/init.d/apache2 restart
+ sudo systemctl reload nginx
+
+ sudo cp ~/RASCSI/src/web/service-infra/rascsi-web.service /etc/systemd/system/rascsi-web.service
+ sudo systemctl daemon-reload
+ sudo systemctl enable rascsi-web
+ sudo systemctl start rascsi-web
}
-
+function updateRaScsiGit() {
+ cd ~/RASCSI
+ git pull
+}
function updateRaScsi() {
+ updateRaScsiGit
sudo systemctl stop rascsi
- cd ~/RASCSI/src/raspberrypi
-
- make clean
- make all CONNECT_TYPE=FULLSPEC
- sudo make install CONNECT_TYPE=FULLSPEC
- sudo systemctl start rascsi
+ cd ~/RASCSI/src/raspberrypi
+
+ make clean
+ make all CONNECT_TYPE=FULLSPEC
+ sudo make install CONNECT_TYPE=FULLSPEC
+ sudo systemctl start rascsi
}
function updateRaScsiWebInterface() {
- sudo /etc/init.d/apache2 stop
- cd ~/RASCSI
- git fetch --all
- cd ~/RASCSI/src/raspberrypi
- sudo cp ~/RASCSI/src/php/* /var/www/html
-
- sudo /etc/init.d/apache2 start
+ stopOldWebInterface
+ updateRaScsiGit
+ sudo cp -f ~/RASCSI/src/web/service-infra/nginx-default.conf /etc/nginx/sites-available/default
+ sudo cp -f ~/RASCSI/src/web/service-infra/502.html /var/www/html/502.html
+ sudo systemctl restart rascsi-web
+ sudo systemctl restart nginx
}
function showRaScsiStatus() {
diff --git a/src/php/.editorconfig b/src/php/.editorconfig
deleted file mode 100644
index d03ab4e6..00000000
--- a/src/php/.editorconfig
+++ /dev/null
@@ -1,8 +0,0 @@
-root = true
-
-[*.{html,php,htm}]
-indent_style = space
-indent_size = 3
-charset = utf-8
-trim_trailing_whitespace = true
-insert_final_newline = true
diff --git a/src/php/LICENSE b/src/php/LICENSE
deleted file mode 100644
index ffef9a2f..00000000
--- a/src/php/LICENSE
+++ /dev/null
@@ -1,31 +0,0 @@
-BSD 3-Clause License
-
-Copyright (C) 2001-2006 PI.(ytanaka@ipc-tokai.or.jp)
-Copyright (C) 2014-2020 GIMONS
-Copyright (c) 2020, akuker
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-3. Neither the name of the copyright holder nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/php/concept_wireframe.png b/src/php/concept_wireframe.png
deleted file mode 100644
index 1aea0024..00000000
Binary files a/src/php/concept_wireframe.png and /dev/null differ
diff --git a/src/php/lib_rascsi.php b/src/php/lib_rascsi.php
deleted file mode 100644
index fb483a47..00000000
--- a/src/php/lib_rascsi.php
+++ /dev/null
@@ -1,260 +0,0 @@
-
-
-
-
-
-
-'. PHP_EOL;
- echo '
';
- }
-
- if(isset($_POST['command']))
- {
- 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;
- }
- }
- else{
- html_generate_warning("HTTP command was missing POST information. Are you trying to access this page directly? That won't work");
- echo " ".PHP_EOL;
- html_generate_ok_to_go_home();
- }
-
-function action_eject_disk(){
- $command = 'rasctl -i '.$_POST['id'].' -c eject 2>&1'.PHP_EOL;
- exec($command, $retArray, $result);
- check_result($result, $command,$retArray);
- html_generate_ok_to_go_home();
-}
-
-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'.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(){
- $command = 'rasctl -i '.$_POST['id'].' -c insert -f '.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'].' 2>&1'.PHP_EOL;
- exec($command, $retArray, $result);
- check_result($result, $command,$retArray);
- html_generate_ok_to_go_home();
-}
-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);
- check_result($result, $command, $retArray);
- html_generate_ok_to_go_home();
- }
- else{
- echo '
Create a new empty file
'.PHP_EOL;
- echo ''.PHP_EOL;
- echo ' Note: Creating a large file may take a long time!'.PHP_EOL;
- echo '
'.PHP_EOL;
- echo ''.PHP_EOL;
- }
-}
-
-function action_delete_file(){
- // Check to see if the user has confirmed
- if(isset($_POST['confirmed'])){
- $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_name'].'?');
- }
-}
-
-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'])){
- $command = "sleep 2 && sudo reboot 2>&1";
- exec($command, $retArray, $result);
- // The unit should reboot at this point. Doesn't matter what we do now...
- check_result($result, $command,$retArray);
- html_generate_ok_to_go_home();
- }
- 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'])){
- $command = "sleep 2 && sudo shutdown -h now 2>&1";
- exec($command, $retArray, $result);
- // The unit should shutdown at this point. Doesn't matter what we do now...
- check_result($result, $command,$retArray);
- 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(){
- html_generate_warning('