Merge pull request #601 from akuker/bzeiss_restructure_project_folders
Restructure project folders for python #455
8
.gitignore
vendored
@ -5,10 +5,10 @@ core
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
*.swp
|
*.swp
|
||||||
__pycache__
|
__pycache__
|
||||||
src/web/current
|
python/web/current
|
||||||
src/web/rascsi_interface_pb2.py
|
python/web/src/rascsi_interface_pb2.py
|
||||||
src/oled_monitor/current
|
python/oled/current
|
||||||
src/oled_monitor/rascsi_interface_pb2.py
|
python/oled/src/rascsi_interface_pb2.py
|
||||||
src/raspberrypi/hfdisk/
|
src/raspberrypi/hfdisk/
|
||||||
*~
|
*~
|
||||||
messages.pot
|
messages.pot
|
||||||
|
291
easyinstall.sh
@ -50,7 +50,8 @@ USER=$(whoami)
|
|||||||
BASE=$(dirname "$(readlink -f "${0}")")
|
BASE=$(dirname "$(readlink -f "${0}")")
|
||||||
VIRTUAL_DRIVER_PATH="$HOME/images"
|
VIRTUAL_DRIVER_PATH="$HOME/images"
|
||||||
CFG_PATH="$HOME/.config/rascsi"
|
CFG_PATH="$HOME/.config/rascsi"
|
||||||
WEB_INSTALL_PATH="$BASE/src/web"
|
WEB_INSTALL_PATH="$BASE/python/web"
|
||||||
|
OLED_INSTALL_PATH="$BASE/python/oled"
|
||||||
SYSTEMD_PATH="/etc/systemd/system"
|
SYSTEMD_PATH="/etc/systemd/system"
|
||||||
HFS_FORMAT=/usr/bin/hformat
|
HFS_FORMAT=/usr/bin/hformat
|
||||||
HFDISK_BIN=/usr/bin/hfdisk
|
HFDISK_BIN=/usr/bin/hfdisk
|
||||||
@ -100,108 +101,16 @@ function installRaScsiWebInterface() {
|
|||||||
echo "Deleting old Python protobuf library rascsi_interface_pb2.py"
|
echo "Deleting old Python protobuf library rascsi_interface_pb2.py"
|
||||||
fi
|
fi
|
||||||
echo "Compiling the Python protobuf library rascsi_interface_pb2.py..."
|
echo "Compiling the Python protobuf library rascsi_interface_pb2.py..."
|
||||||
protoc -I="$BASE/src/raspberrypi/" --python_out="$WEB_INSTALL_PATH" rascsi_interface.proto
|
protoc -I="$BASE/src/raspberrypi/" --python_out="$WEB_INSTALL_PATH/src" rascsi_interface.proto
|
||||||
|
|
||||||
sudo cp -f "$BASE/src/web/service-infra/nginx-default.conf" /etc/nginx/sites-available/default
|
sudo cp -f "$WEB_INSTALL_PATH/service-infra/nginx-default.conf" /etc/nginx/sites-available/default
|
||||||
sudo cp -f "$BASE/src/web/service-infra/502.html" /var/www/html/502.html
|
sudo cp -f "$WEB_INSTALL_PATH/service-infra/502.html" /var/www/html/502.html
|
||||||
|
|
||||||
sudo usermod -a -G $USER www-data
|
sudo usermod -a -G $USER www-data
|
||||||
|
|
||||||
sudo systemctl reload nginx || true
|
sudo systemctl reload nginx || true
|
||||||
}
|
}
|
||||||
|
|
||||||
# updates configuration files and installs packages needed for the OLED screen script
|
|
||||||
function installRaScsiScreen() {
|
|
||||||
echo "IMPORTANT: This configuration requires a OLED screen to be installed onto your RaSCSI board."
|
|
||||||
echo "See wiki for more information: https://github.com/akuker/RASCSI/wiki/OLED-Status-Display-(Optional)"
|
|
||||||
echo ""
|
|
||||||
echo "Choose screen rotation:"
|
|
||||||
echo " 1) 0 degrees"
|
|
||||||
echo " 2) 180 degrees (default)"
|
|
||||||
read REPLY
|
|
||||||
|
|
||||||
if [ "$REPLY" == "1" ]; then
|
|
||||||
echo "Proceeding with 0 degrees rotation."
|
|
||||||
ROTATION="0"
|
|
||||||
else
|
|
||||||
echo "Proceeding with 180 degrees rotation."
|
|
||||||
ROTATION="180"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "Choose screen resolution:"
|
|
||||||
echo " 1) 128x32 pixels (default)"
|
|
||||||
echo " 2) 128x64 pixels"
|
|
||||||
read REPLY
|
|
||||||
|
|
||||||
if [ "$REPLY" == "2" ]; then
|
|
||||||
echo "Proceeding with 128x64 pixel resolution."
|
|
||||||
SCREEN_HEIGHT="64"
|
|
||||||
else
|
|
||||||
echo "Proceeding with 128x32 pixel resolution."
|
|
||||||
SCREEN_HEIGHT="32"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$TOKEN" ]; then
|
|
||||||
echo ""
|
|
||||||
echo "Did you protect your RaSCSI installation with a token password? [y/N]"
|
|
||||||
read -r REPLY
|
|
||||||
if [ "$REPLY" == "y" ] || [ "$REPLY" == "Y" ]; then
|
|
||||||
echo -n "Enter the password that you configured with RaSCSI at the time of installation: "
|
|
||||||
read -r TOKEN
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
stopRaScsiScreen
|
|
||||||
updateRaScsiGit
|
|
||||||
|
|
||||||
sudo apt-get update && sudo apt-get install libjpeg-dev libpng-dev libopenjp2-7-dev i2c-tools raspi-config -y </dev/null
|
|
||||||
|
|
||||||
if [ -f "$BASE/src/oled_monitor/rascsi_interface_pb2.py" ]; then
|
|
||||||
sudo rm "$BASE/src/oled_monitor/rascsi_interface_pb2.py"
|
|
||||||
echo "Deleting old Python protobuf library rascsi_interface_pb2.py"
|
|
||||||
fi
|
|
||||||
echo "Compiling the Python protobuf library rascsi_interface_pb2.py..."
|
|
||||||
protoc -I="$BASE/src/raspberrypi/" --python_out="$BASE/src/oled_monitor" rascsi_interface.proto
|
|
||||||
|
|
||||||
if [[ $(grep -c "^dtparam=i2c_arm=on" /boot/config.txt) -ge 1 ]]; then
|
|
||||||
echo "NOTE: I2C support seems to have been configured already."
|
|
||||||
REBOOT=0
|
|
||||||
else
|
|
||||||
sudo raspi-config nonint do_i2c 0 </dev/null
|
|
||||||
echo "Modified the Raspberry Pi boot configuration to enable I2C."
|
|
||||||
echo "A reboot will be required for the change to take effect."
|
|
||||||
REBOOT=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Installing the monitor_rascsi.service configuration..."
|
|
||||||
sudo cp -f "$BASE/src/oled_monitor/monitor_rascsi.service" "$SYSTEMD_PATH/monitor_rascsi.service"
|
|
||||||
sudo sed -i /^ExecStart=/d "$SYSTEMD_PATH/monitor_rascsi.service"
|
|
||||||
if [ ! -z "$TOKEN" ]; then
|
|
||||||
sudo sed -i "8 i ExecStart=$BASE/src/oled_monitor/start.sh --rotation=$ROTATION --height=$SCREEN_HEIGHT --password=$TOKEN" "$SYSTEMD_PATH/monitor_rascsi.service"
|
|
||||||
sudo chmod 600 "$SYSTEMD_PATH/monitor_rascsi.service"
|
|
||||||
echo "Granted access to the OLED Monitor with the password that you configured for RaSCSI."
|
|
||||||
else
|
|
||||||
sudo sed -i "8 i ExecStart=$BASE/src/oled_monitor/start.sh --rotation=$ROTATION --height=$SCREEN_HEIGHT" "$SYSTEMD_PATH/monitor_rascsi.service"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable monitor_rascsi
|
|
||||||
|
|
||||||
if [ $REBOOT -eq 1 ]; then
|
|
||||||
echo ""
|
|
||||||
echo "The monitor_rascsi service will start on the next Pi boot."
|
|
||||||
echo "Press Enter to reboot or CTRL-C to exit"
|
|
||||||
read
|
|
||||||
|
|
||||||
echo "Rebooting..."
|
|
||||||
sleep 3
|
|
||||||
sudo reboot
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo systemctl start monitor_rascsi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Creates the dir that RaSCSI uses to store image files
|
# Creates the dir that RaSCSI uses to store image files
|
||||||
function createImagesDir() {
|
function createImagesDir() {
|
||||||
if [ -d "$VIRTUAL_DRIVER_PATH" ]; then
|
if [ -d "$VIRTUAL_DRIVER_PATH" ]; then
|
||||||
@ -321,7 +230,7 @@ function enableRaScsiService() {
|
|||||||
# Modifies and installs the rascsi-web service
|
# Modifies and installs the rascsi-web service
|
||||||
function installWebInterfaceService() {
|
function installWebInterfaceService() {
|
||||||
echo "Installing the rascsi-web.service configuration..."
|
echo "Installing the rascsi-web.service configuration..."
|
||||||
sudo cp -f "$BASE/src/web/service-infra/rascsi-web.service" "$SYSTEMD_PATH/rascsi-web.service"
|
sudo cp -f "$WEB_INSTALL_PATH/service-infra/rascsi-web.service" "$SYSTEMD_PATH/rascsi-web.service"
|
||||||
sudo sed -i /^ExecStart=/d "$SYSTEMD_PATH/rascsi-web.service"
|
sudo sed -i /^ExecStart=/d "$SYSTEMD_PATH/rascsi-web.service"
|
||||||
echo "$TOKEN"
|
echo "$TOKEN"
|
||||||
if [ ! -z "$TOKEN" ]; then
|
if [ ! -z "$TOKEN" ]; then
|
||||||
@ -339,22 +248,59 @@ function installWebInterfaceService() {
|
|||||||
|
|
||||||
# Stops the rascsi service if it is running
|
# Stops the rascsi service if it is running
|
||||||
function stopRaScsi() {
|
function stopRaScsi() {
|
||||||
if [ -f "$SYSTEMD_PATH/rascsi.service" ]; then
|
if [[ -f "$SYSTEMD_PATH/rascsi.service" ]]; then
|
||||||
sudo systemctl stop rascsi.service
|
SERVICE_RASCSI_RUNNING=0
|
||||||
|
sudo systemctl is-active --quiet rascsi.service >/dev/null 2>&1 || SERVICE_RASCSI_RUNNING=$?
|
||||||
|
if [[ $SERVICE_RASCSI_RUNNING -eq 0 ]]; then
|
||||||
|
sudo systemctl stop rascsi.service
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Stops the rascsi-web service if it is running
|
# Stops the rascsi-web service if it is running
|
||||||
function stopRaScsiWeb() {
|
function stopRaScsiWeb() {
|
||||||
if [ -f "$SYSTEMD_PATH/rascsi-web.service" ]; then
|
if [[ -f "$SYSTEMD_PATH/rascsi-web.service" ]]; then
|
||||||
sudo systemctl stop rascsi-web.service
|
SERVICE_RASCSI_WEB_RUNNING=0
|
||||||
|
sudo systemctl is-active --quiet rascsi-web.service >/dev/null 2>&1 || SERVICE_RASCSI_WEB_RUNNING=$?
|
||||||
|
if [[ $SERVICE_RASCSI_WEB_RUNNING -eq 0 ]]; then
|
||||||
|
sudo systemctl stop rascsi-web.service
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Stops the monitor_rascsi service if it is running
|
# Stops the rascsi-oled service if it is running
|
||||||
function stopRaScsiScreen() {
|
function stopRaScsiScreen() {
|
||||||
|
if [[ -f "$SYSTEMD_PATH/monitor_rascsi.service" ]]; then
|
||||||
|
SERVICE_MONITOR_RASCSI_RUNNING=0
|
||||||
|
sudo systemctl is-active --quiet monitor_rascsi.service >/dev/null 2>&1 || SERVICE_MONITOR_RASCSI_RUNNING=$?
|
||||||
|
if [[ $SERVICE_MONITOR_RASCSI_RUNNING -eq 0 ]]; then
|
||||||
|
sudo systemctl stop monitor_rascsi.service
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ -f "$SYSTEMD_PATH/rascsi-oled.service" ]]; then
|
||||||
|
SERVICE_RASCSI_OLED_RUNNING=0
|
||||||
|
sudo systemctl is-active --quiet rascsi-oled.service >/dev/null 2>&1 || SERVICE_RASCSI_OLED_RUNNING=$?
|
||||||
|
if [[ $SERVICE_RASCSI_OLED_RUNNING -eq 0 ]]; then
|
||||||
|
sudo systemctl stop rascsi-oled.service
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# disables and removes the old monitor_rascsi service
|
||||||
|
function disableOldRaScsiMonitorService() {
|
||||||
if [ -f "$SYSTEMD_PATH/monitor_rascsi.service" ]; then
|
if [ -f "$SYSTEMD_PATH/monitor_rascsi.service" ]; then
|
||||||
sudo systemctl stop monitor_rascsi.service
|
SERVICE_MONITOR_RASCSI_RUNNING=0
|
||||||
|
sudo systemctl is-active --quiet monitor_rascsi.service >/dev/null 2>&1 || SERVICE_MONITOR_RASCSI_RUNNING=$?
|
||||||
|
if [[ $SERVICE_MONITOR_RASCSI_RUNNING -eq 0 ]]; then
|
||||||
|
sudo systemctl stop monitor_rascsi.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
SERVICE_MONITOR_RASCSI_ENABLED=0
|
||||||
|
sudo systemctl is-enabled --quiet monitor_rascsi.service >/dev/null 2>&1 || SERVICE_MONITOR_RASCSI_ENABLED=$?
|
||||||
|
if [[ $SERVICE_MONITOR_RASCSI_ENABLED -eq 0 ]]; then
|
||||||
|
sudo systemctl disable monitor_rascsi.service
|
||||||
|
fi
|
||||||
|
sudo rm $SYSTEMD_PATH/monitor_rascsi.service
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,10 +311,34 @@ function stopMacproxy() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Starts the monitor_rascsi service if installed
|
# Starts the rascsi-oled service if installed
|
||||||
|
function isRaScsiScreenInstalled() {
|
||||||
|
SERVICE_RASCSI_OLED_ENABLED=0
|
||||||
|
if [[ -f "$SYSTEMD_PATH/rascsi-oled.service" ]]; then
|
||||||
|
sudo systemctl is-enabled --quiet rascsi-oled.service >/dev/null 2>&1 || SERVICE_RASCSI_OLED_ENABLED=$?
|
||||||
|
elif [[ -f "$SYSTEMD_PATH/monitor_rascsi.service" ]]; then
|
||||||
|
sudo systemctl is-enabled --quiet monitor_rascsi.service >/dev/null 2>&1 || SERVICE_RASCSI_OLED_ENABLED=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $SERVICE_RASCSI_OLED_ENABLED
|
||||||
|
}
|
||||||
|
|
||||||
|
# Starts the rascsi-oled service if installed
|
||||||
|
function isRaScsiScreenRunning() {
|
||||||
|
SERVICE_RASCSI_OLED_RUNNING=0
|
||||||
|
if [[ -f "$SYSTEMD_PATH/rascsi-oled.service" ]]; then
|
||||||
|
sudo systemctl is-active --quiet rascsi-oled.service >/dev/null 2>&1 || SERVICE_RASCSI_OLED_RUNNING=$?
|
||||||
|
elif [[ -f "$SYSTEMD_PATH/monitor_rascsi.service" ]]; then
|
||||||
|
sudo systemctl is-active --quiet monitor_rascsi.service >/dev/null 2>&1 || SERVICE_RASCSI_OLED_RUNNING=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $SERVICE_RASCSI_OLED_RUNNING
|
||||||
|
}
|
||||||
|
|
||||||
|
# Starts the rascsi-oled service if installed
|
||||||
function startRaScsiScreen() {
|
function startRaScsiScreen() {
|
||||||
if [ -f "$SYSTEMD_PATH/monitor_rascsi.service" ]; then
|
if [[ $(isRaScsiScreenInstalled) -eq 0 ]] && [[ $(isRaScsiScreenRunning) -ne 1 ]]; then
|
||||||
sudo systemctl start monitor_rascsi.service
|
sudo systemctl start rascsi-oled.service
|
||||||
showRaScsiScreenStatus
|
showRaScsiScreenStatus
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -391,9 +361,9 @@ function showRaScsiWebStatus() {
|
|||||||
systemctl status rascsi-web | tee
|
systemctl status rascsi-web | tee
|
||||||
}
|
}
|
||||||
|
|
||||||
# Shows status for the monitor_rascsi service
|
# Shows status for the rascsi-oled service
|
||||||
function showRaScsiScreenStatus() {
|
function showRaScsiScreenStatus() {
|
||||||
systemctl status monitor_rascsi | tee
|
systemctl status rascsi-oled | tee
|
||||||
}
|
}
|
||||||
|
|
||||||
# Shows status for the macproxy service
|
# Shows status for the macproxy service
|
||||||
@ -758,6 +728,103 @@ function installMacproxy {
|
|||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# updates configuration files and installs packages needed for the OLED screen script
|
||||||
|
function installRaScsiScreen() {
|
||||||
|
echo "IMPORTANT: This configuration requires a OLED screen to be installed onto your RaSCSI board."
|
||||||
|
echo "See wiki for more information: https://github.com/akuker/RASCSI/wiki/OLED-Status-Display-(Optional)"
|
||||||
|
echo ""
|
||||||
|
echo "Choose screen rotation:"
|
||||||
|
echo " 1) 0 degrees"
|
||||||
|
echo " 2) 180 degrees (default)"
|
||||||
|
read REPLY
|
||||||
|
|
||||||
|
if [ "$REPLY" == "1" ]; then
|
||||||
|
echo "Proceeding with 0 degrees rotation."
|
||||||
|
ROTATION="0"
|
||||||
|
else
|
||||||
|
echo "Proceeding with 180 degrees rotation."
|
||||||
|
ROTATION="180"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Choose screen resolution:"
|
||||||
|
echo " 1) 128x32 pixels (default)"
|
||||||
|
echo " 2) 128x64 pixels"
|
||||||
|
read REPLY
|
||||||
|
|
||||||
|
if [ "$REPLY" == "2" ]; then
|
||||||
|
echo "Proceeding with 128x64 pixel resolution."
|
||||||
|
SCREEN_HEIGHT="64"
|
||||||
|
else
|
||||||
|
echo "Proceeding with 128x32 pixel resolution."
|
||||||
|
SCREEN_HEIGHT="32"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$TOKEN" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "Did you protect your RaSCSI installation with a token password? [y/N]"
|
||||||
|
read -r REPLY
|
||||||
|
if [ "$REPLY" == "y" ] || [ "$REPLY" == "Y" ]; then
|
||||||
|
echo -n "Enter the password that you configured with RaSCSI at the time of installation: "
|
||||||
|
read -r TOKEN
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
stopRaScsiScreen
|
||||||
|
updateRaScsiGit
|
||||||
|
|
||||||
|
sudo apt-get update && sudo apt-get install libjpeg-dev libpng-dev libopenjp2-7-dev i2c-tools raspi-config -y </dev/null
|
||||||
|
|
||||||
|
if [ -f "$OLED_INSTALL_PATH/src/rascsi_interface_pb2.py" ]; then
|
||||||
|
sudo rm "$OLED_INSTALL_PATH/src/rascsi_interface_pb2.py"
|
||||||
|
echo "Deleting old Python protobuf library rascsi_interface_pb2.py"
|
||||||
|
fi
|
||||||
|
echo "Compiling the Python protobuf library rascsi_interface_pb2.py..."
|
||||||
|
protoc -I="$BASE/src/raspberrypi/" --python_out="$OLED_INSTALL_PATH/src" rascsi_interface.proto
|
||||||
|
|
||||||
|
if [[ $(grep -c "^dtparam=i2c_arm=on" /boot/config.txt) -ge 1 ]]; then
|
||||||
|
echo "NOTE: I2C support seems to have been configured already."
|
||||||
|
REBOOT=0
|
||||||
|
else
|
||||||
|
sudo raspi-config nonint do_i2c 0 </dev/null
|
||||||
|
echo "Modified the Raspberry Pi boot configuration to enable I2C."
|
||||||
|
echo "A reboot will be required for the change to take effect."
|
||||||
|
REBOOT=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installing the rascsi-oled.service configuration..."
|
||||||
|
sudo cp -f "$OLED_INSTALL_PATH/service-infra/rascsi-oled.service" "$SYSTEMD_PATH/rascsi-oled.service"
|
||||||
|
sudo sed -i /^ExecStart=/d "$SYSTEMD_PATH/rascsi-oled.service"
|
||||||
|
if [ ! -z "$TOKEN" ]; then
|
||||||
|
sudo sed -i "8 i ExecStart=$OLED_INSTALL_PATH/start.sh --rotation=$ROTATION --height=$SCREEN_HEIGHT --password=$TOKEN" "$SYSTEMD_PATH/rascsi-oled.service"
|
||||||
|
sudo chmod 600 "$SYSTEMD_PATH/rascsi-oled.service"
|
||||||
|
echo "Granted access to the OLED Monitor with the password that you configured for RaSCSI."
|
||||||
|
else
|
||||||
|
sudo sed -i "8 i ExecStart=$OLED_INSTALL_PATH/start.sh --rotation=$ROTATION --height=$SCREEN_HEIGHT" "$SYSTEMD_PATH/rascsi-oled.service"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
|
||||||
|
# ensure that the old monitor_rascsi service is disabled and removed before the new one is installed
|
||||||
|
disableOldRaScsiMonitorService
|
||||||
|
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable rascsi-oled
|
||||||
|
|
||||||
|
if [ $REBOOT -eq 1 ]; then
|
||||||
|
echo ""
|
||||||
|
echo "The rascsi-oled service will start on the next Pi boot."
|
||||||
|
echo "Press Enter to reboot or CTRL-C to exit"
|
||||||
|
read
|
||||||
|
|
||||||
|
echo "Rebooting..."
|
||||||
|
sleep 3
|
||||||
|
sudo reboot
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo systemctl start rascsi-oled
|
||||||
|
}
|
||||||
|
|
||||||
# Prints a notification if the rascsi.service file was backed up
|
# Prints a notification if the rascsi.service file was backed up
|
||||||
function notifyBackup {
|
function notifyBackup {
|
||||||
if "$SYSTEMD_BACKUP"; then
|
if "$SYSTEMD_BACKUP"; then
|
||||||
@ -811,8 +878,8 @@ function runChoice() {
|
|||||||
backupRaScsiService
|
backupRaScsiService
|
||||||
installRaScsi
|
installRaScsi
|
||||||
enableRaScsiService
|
enableRaScsiService
|
||||||
if [ -f "$SYSTEMD_PATH/monitor_rascsi.service" ]; then
|
if [[ $(isRaScsiScreenInstalled) -eq 0 ]]; then
|
||||||
echo "Detected monitor_rascsi.service; will run the installation steps for the OLED monitor."
|
echo "Detected rascsi oled service; will run the installation steps for the OLED monitor."
|
||||||
installRaScsiScreen
|
installRaScsiScreen
|
||||||
fi
|
fi
|
||||||
installRaScsiWebInterface
|
installRaScsiWebInterface
|
||||||
@ -844,8 +911,8 @@ function runChoice() {
|
|||||||
backupRaScsiService
|
backupRaScsiService
|
||||||
installRaScsi
|
installRaScsi
|
||||||
enableRaScsiService
|
enableRaScsiService
|
||||||
if [ -f "$SYSTEMD_PATH/monitor_rascsi.service" ]; then
|
if [[ $(isRaScsiScreenInstalled) -eq 0 ]]; then
|
||||||
echo "Detected monitor_rascsi.service; will run the installation steps for the OLED monitor."
|
echo "Detected rascsi oled service; will run the installation steps for the OLED monitor."
|
||||||
installRaScsiScreen
|
installRaScsiScreen
|
||||||
fi
|
fi
|
||||||
showRaScsiScreenStatus
|
showRaScsiScreenStatus
|
||||||
|
0
python/common/src/.gitkeep
Normal file
0
python/common/tests/.gitkeep
Normal file
0
src/loopback_test/test.py → python/loopback_test/test.py
Executable file → Normal file
1
python/oled/.pylintrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
../.pylintrc
|
@ -9,7 +9,7 @@ $ python3 -m venv venv
|
|||||||
$ source venv/bin/activate
|
$ source venv/bin/activate
|
||||||
# Install requirements
|
# Install requirements
|
||||||
$ pip3 install -r requirements.txt
|
$ pip3 install -r requirements.txt
|
||||||
$ python3 rascsi_oled_monitor.py
|
$ python3 src/rascsi_oled_monitor.py
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
Before Width: | Height: | Size: 574 B After Width: | Height: | Size: 574 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@ -1,13 +1,13 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Monitor RaSCSI service
|
Description=RaSCSI-OLED service
|
||||||
After=network.target rascsi.service
|
After=network.target rascsi.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=2s
|
RestartSec=2s
|
||||||
ExecStart=/home/pi/RASCSI/src/oled_monitor/start.sh
|
ExecStart=/home/pi/RASCSI/python/oled/start.sh
|
||||||
ExecStop=/bin/pkill --signal 2 -f "python3 rascsi_oled_monitor.py"
|
ExecStop=/bin/pkill --signal 2 -f "python3 src/rascsi_oled_monitor.py"
|
||||||
# Sleep 2s as a crude way for the python interrupt handler to take effect and show the shutdown splash
|
# Sleep 2s as a crude way for the python interrupt handler to take effect and show the shutdown splash
|
||||||
ExecStop=/bin/sleep 2
|
ExecStop=/bin/sleep 2
|
||||||
SyslogIdentifier=RASCSIMON
|
SyslogIdentifier=RASCSIMON
|
@ -105,7 +105,7 @@ print("Will update the OLED display every " + str(DELAY_TIME_MS) + "ms (approxim
|
|||||||
# Show a startup splash bitmap image before starting the main loop
|
# Show a startup splash bitmap image before starting the main loop
|
||||||
# Convert the image to mode '1' for 1-bit color (monochrome)
|
# Convert the image to mode '1' for 1-bit color (monochrome)
|
||||||
# Make sure the splash bitmap image is in the same dir as this script
|
# Make sure the splash bitmap image is in the same dir as this script
|
||||||
IMAGE = Image.open(f"splash_start_{HEIGHT}.bmp").convert("1")
|
IMAGE = Image.open(f"resources/splash_start_{HEIGHT}.bmp").convert("1")
|
||||||
OLED.image(IMAGE)
|
OLED.image(IMAGE)
|
||||||
OLED.show()
|
OLED.show()
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ LINE_SPACING = 8
|
|||||||
# When using other fonts, you may need to adjust PADDING, FONT_SIZE,
|
# When using other fonts, you may need to adjust PADDING, FONT_SIZE,
|
||||||
# LINE_SPACING, and LINES.
|
# LINE_SPACING, and LINES.
|
||||||
# Some other nice fonts to try: http://www.dafont.com/bitmap.php
|
# Some other nice fonts to try: http://www.dafont.com/bitmap.php
|
||||||
FONT = ImageFont.truetype('type_writer.ttf', FONT_SIZE)
|
FONT = ImageFont.truetype('resources/type_writer.ttf', FONT_SIZE)
|
||||||
|
|
||||||
IP_ADDR, HOSTNAME = get_ip_and_host()
|
IP_ADDR, HOSTNAME = get_ip_and_host()
|
||||||
|
|
@ -47,10 +47,10 @@ if [ $ERROR = 1 ] ; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if pgrep -f "python3 rascsi_oled_monitor.py" &> /dev/null; then
|
if pgrep -f "python3 src/rascsi_oled_monitor.py" &> /dev/null; then
|
||||||
echo "Detected active rascsi_oled_monitor.py process"
|
echo "Detected active rascsi_oled_monitor.py process"
|
||||||
echo "Terminating before launching a new one."
|
echo "Terminating before launching a new one."
|
||||||
sudo pkill -f "python3 rascsi_oled_monitor.py"
|
sudo pkill -f "python3 src/rascsi_oled_monitor.py"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! i2cdetect -y 1 &> /dev/null ; then
|
if ! i2cdetect -y 1 &> /dev/null ; then
|
||||||
@ -88,7 +88,13 @@ if ! test -e venv; then
|
|||||||
echo "Installing requirements.txt"
|
echo "Installing requirements.txt"
|
||||||
pip3 install wheel
|
pip3 install wheel
|
||||||
CFLAGS="$COMPILER_FLAGS" pip3 install -r requirements.txt
|
CFLAGS="$COMPILER_FLAGS" pip3 install -r requirements.txt
|
||||||
git rev-parse HEAD > current
|
|
||||||
|
set +e
|
||||||
|
git rev-parse --is-inside-work-tree &> /dev/null
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
git rev-parse HEAD > current
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source venv/bin/activate
|
source venv/bin/activate
|
||||||
@ -143,4 +149,4 @@ if [ -z ${HEIGHT+x} ]; then
|
|||||||
else
|
else
|
||||||
echo "Starting with parameter $HEIGHT"
|
echo "Starting with parameter $HEIGHT"
|
||||||
fi
|
fi
|
||||||
python3 rascsi_oled_monitor.py ${ROTATION} ${HEIGHT} ${PASSWORD}
|
python3 src/rascsi_oled_monitor.py ${ROTATION} ${HEIGHT} ${PASSWORD}
|
0
python/oled/tests/.gitkeep
Normal file
1
python/web/.pylintrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
../.pylintrc
|
@ -10,7 +10,7 @@ $ source venv/bin/activate
|
|||||||
# Install requirements
|
# Install requirements
|
||||||
$ pip install -r requirements.txt
|
$ pip install -r requirements.txt
|
||||||
# Use mocks and a temp dir - start the web server
|
# Use mocks and a temp dir - start the web server
|
||||||
$ BASE_DIR=/tmp/images/ PATH=$PATH:`pwd`/mock/bin/ python3 web.py
|
$ BASE_DIR=/tmp/images/ PATH=$PATH:`pwd`/mock/bin/ cd src && python3 web.py
|
||||||
```
|
```
|
||||||
|
|
||||||
### Mocks for local development
|
### Mocks for local development
|
0
src/web/mock/bin/journalctl → python/web/mock/bin/journalctl
Executable file → Normal file
0
src/web/mock/bin/systemctl → python/web/mock/bin/systemctl
Executable file → Normal file
@ -5,7 +5,7 @@ After=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
Restart=always
|
Restart=always
|
||||||
ExecStart=/home/pi/RASCSI/src/web/start.sh
|
ExecStart=/home/pi/RASCSI/python/web/start.sh
|
||||||
SyslogIdentifier=RASCSIWEB
|
SyslogIdentifier=RASCSIWEB
|
||||||
|
|
||||||
[Install]
|
[Install]
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 904 B After Width: | Height: | Size: 904 B |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
@ -56,13 +56,18 @@ if ! test -e venv; then
|
|||||||
echo "Installing requirements.txt"
|
echo "Installing requirements.txt"
|
||||||
pip3 install wheel
|
pip3 install wheel
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
git rev-parse HEAD > current
|
|
||||||
|
git rev-parse --is-inside-work-tree &> /dev/null
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
git rev-parse HEAD > current
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source venv/bin/activate
|
source venv/bin/activate
|
||||||
|
|
||||||
# Detect if someone updates the git repo - we need to re-run pip3 install.
|
# Detect if someone updates the git repo - we need to re-run pip3 install.
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
git rev-parse --is-inside-work-tree &> /dev/null
|
git rev-parse --is-inside-work-tree &> /dev/null
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
set -e
|
set -e
|
||||||
@ -78,7 +83,7 @@ else
|
|||||||
fi
|
fi
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
pybabel compile -d translations
|
pybabel compile -d src/translations
|
||||||
|
|
||||||
# parse arguments
|
# parse arguments
|
||||||
while [ "$1" != "" ]; do
|
while [ "$1" != "" ]; do
|
||||||
@ -100,4 +105,5 @@ while [ "$1" != "" ]; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
echo "Starting web server for RaSCSI Web Interface..."
|
echo "Starting web server for RaSCSI Web Interface..."
|
||||||
|
cd src
|
||||||
python3 web.py ${PORT} ${PASSWORD}
|
python3 web.py ${PORT} ${PASSWORD}
|
0
python/web/tests/.gitkeep
Normal file
@ -1 +0,0 @@
|
|||||||
../.pylintrc
|
|
@ -1 +0,0 @@
|
|||||||
../.pylintrc
|
|