diff --git a/etc/1-install-sys.sh b/etc/1-install-sys.sh index 33cf13e..0de4043 100755 --- a/etc/1-install-sys.sh +++ b/etc/1-install-sys.sh @@ -1,10 +1,20 @@ !/bin/bash -echo "==== System installation for rpi 4/5" +echo "==== System installation for rpi" echo sudo apt update -#sudo apt upgrade +sudo apt upgrade + +ETC="$(pwd)" + +mkdir -p $HOME/exports +mkdir -p$HOME/medias +mkdir -p /mnt/exports + +cp ../test_tube_scanner/.env.example ../test_tube_scanner/.env +echo "==== Copie .env ==> MODIFIER CE FICHIER POUR POUVOIR cONTINUER" +echo # system echo "==== system essential" @@ -15,8 +25,8 @@ sudo apt -y install python3-dev python3-pip python3-venv libpq-dev default-libmy echo "==== supervisor http access login:pass => root:toor" sudo cp supervisor-inet_http.conf /etc/supervisor/conf.d/ -sudo ln -s scanner_service.conf /etc/supervisor/conf.d/ -sudo ln -s reductstore_service.conf /etc/supervisor/conf.d/ +sudo ln -s $ETC/scanner_service.conf /etc/supervisor/conf.d/ +sudo ln -s $ETC/reductstore_service.conf /etc/supervisor/conf.d/ echo "==== restart supervisor " sudo systemctl restart supervisor diff --git a/etc/2-cargo-reductstore-install.sh b/etc/2-cargo-reductstore-install.sh index e7ea792..fe7bd38 100755 --- a/etc/2-cargo-reductstore-install.sh +++ b/etc/2-cargo-reductstore-install.sh @@ -1,8 +1,9 @@ !/bin/bash echo "--- install reductstore" +echo " machine raspberry pi4" +echo " Compilation finished `release` profile [optimized] target(s) in 16m 31s" sudo apt install libprotobuf-dev protobuf-compiler - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env @@ -10,3 +11,4 @@ cargo --version rustc --version cargo install reductstore +mkdir -p $HOME/medias diff --git a/etc/5-install_adminer.sh b/etc/5-install_adminer.sh index bc15002..32b4739 100755 --- a/etc/5-install_adminer.sh +++ b/etc/5-install_adminer.sh @@ -11,7 +11,11 @@ echo "[2/6] Installation de Nginx et PHP-FPM..." sudo apt install -y nginx # Détection de la version de PHP installée (ou installation si absente) -PHP_VERSION=$(ls /etc/php/ | grep -E '^[0-9]+\.[0-9]+$' | sort -V | tail -n 1) +VERSION=$(apt-cache policy php | awk '/Candidate:/ {print $2}') +PHP_VERSION=$(apt-cache show php | awk -F'[: ]+' '/Depends:/ {for(i=1;i<=NF;i++) if($i ~ /^php[0-9]+\.[0-9]+$/) print substr($i,4)}' | head -n1) +echo "Version du paquet php (meta): $version" +echo "Version PHP utilisée: $php_version" + if [ -z "$PHP_VERSION" ]; then echo "Aucune version de PHP détectée. Installation de PHP 8.2 par défaut..." sudo apt install -y php8.2 php8.2-fpm php8.2-mysql diff --git a/etc/6-install_django_app.sh b/etc/6-install_django_app.sh index 63ba71a..ecdf6f4 100755 --- a/etc/6-install_django_app.sh +++ b/etc/6-install_django_app.sh @@ -8,22 +8,35 @@ echo ETC="$(pwd)" APP_DIR=" ../test_tube_scanner" +echo "---- Lancer reductstore ..." +sudo supervisorctl reread +sudo supervisorctl restart reductstore + cd $APP_DIR -echo "migration de la base de données ..." +echo "---- Création des répertoires media ..." +mkdir -p $APP_DIR/media/images $APP_DIR/media/simulation +mkdir -p $APP_DIR/logs +touch $APP_DIR/logs/celery.log $APP_DIR/logs/test_tube.log + +echo "---- Migration de la base de données ..." ./manage.py migrate ./manage.py makemigrations ./manage.py migrate -echo "User / django_celery_beat ..." +echo "---- User / django_celery_beat ..." ./manage.py init_data -echo "Tables ..." +echo "---- Tables ..." ./manage.py loaddata $ETC/db/configuration.json ./manage.py loaddata $ETC/db/well.json ./manage.py loaddata $ETC/db/multiwell.json -./manage.py loaddata $ETC/db/welposition.json +echo "---- start test_tube:*" +echo +sudo supervisorctl reread +sudo supervisorctl update +sudo supervisorctl restart test_tube:* echo echo "=== Installation terminée ===" diff --git a/etc/db/configuration.json b/etc/db/configuration.json index 2727981..e4afd62 100644 --- a/etc/db/configuration.json +++ b/etc/db/configuration.json @@ -1,3 +1,2 @@ -Django BASE_DIR: /home/rpi4/django-test-tube-scanner/test_tube_scanner -Django application data: /home/rpi4/django-test-tube-scanner/test_tube_scanner + [{"model": "scanner.configuration", "pk": 1, "fields": {"name": "Configuration par défaut", "author": 1, "sidebar_width": "25%", "default_grid_columns": 3, "opencv_fourcc_format": "mp4v", "opencv_video_type": "mp4", "grbl_xmax": 350.0, "grbl_ymax": 250.0, "use_rpicam": true, "webcam_device_index": 2, "image_quality": 90, "video_jpeg_quality": 90, "video_frame_rate": 5.0, "video_width_capture": 2028, "video_height_capture": 1520, "calibration_crop_radius": 500, "calibration_default_multiwell": "HG", "calibration_default_feed": 1000, "calibration_default_step": 1.0, "calibration_default_duration": 3.0, "active": true}}] diff --git a/etc/db/multiwell.json b/etc/db/multiwell.json index a767672..6ca1657 100644 --- a/etc/db/multiwell.json +++ b/etc/db/multiwell.json @@ -1,3 +1 @@ -Django BASE_DIR: /home/rpi4/django-test-tube-scanner/test_tube_scanner -Django application data: /home/rpi4/django-test-tube-scanner/test_tube_scanner [{"model": "scanner.multiwell", "pk": 2, "fields": {"label": "Haut gauche", "author": 1, "position": "HG", "default": false, "cols": 6, "rows": 4, "diameter": 16.0, "row_def": "A,B,C,D", "row_order": "D,C,B,A", "order": 2, "duration": 12, "xbase": 156.45, "ybase": 12.75, "dx": 19.3, "dy": 19.3, "feed": 1000, "well_position": true, "active": true}}, {"model": "scanner.multiwell", "pk": 3, "fields": {"label": "Haut droit", "author": 1, "position": "HD", "default": true, "cols": 6, "rows": 4, "diameter": 16.0, "row_def": "A,B,C,D", "row_order": "D,C,B,A", "order": 0, "duration": 3, "xbase": 10.963, "ybase": 15.825, "dx": 19.4, "dy": 19.4, "feed": 1000, "well_position": true, "active": true}}, {"model": "scanner.multiwell", "pk": 4, "fields": {"label": "Bas gauche", "author": 1, "position": "BG", "default": false, "cols": 6, "rows": 4, "diameter": 16.0, "row_def": "A,B,C,D", "row_order": "D,C,B,A", "order": 3, "duration": 12, "xbase": 150.15, "ybase": 112.55, "dx": 19.5, "dy": 19.5, "feed": 1000, "well_position": true, "active": true}}, {"model": "scanner.multiwell", "pk": 5, "fields": {"label": "Bas droit", "author": 1, "position": "BD", "default": false, "cols": 6, "rows": 4, "diameter": 16.0, "row_def": "A,B,C,D", "row_order": "D,C,B,A", "order": 1, "duration": 12, "xbase": 10.15, "ybase": 111.05, "dx": 19.55, "dy": 19.55, "feed": 1000, "well_position": true, "active": true}}] diff --git a/etc/db/well.json b/etc/db/well.json index ca5739c..1c32ba1 100644 --- a/etc/db/well.json +++ b/etc/db/well.json @@ -1,3 +1 @@ -Django BASE_DIR: /home/rpi4/django-test-tube-scanner/test_tube_scanner -Django application data: /home/rpi4/django-test-tube-scanner/test_tube_scanner [{"model": "scanner.well", "pk": 1, "fields": {"author": 1, "name": "A1"}}, {"model": "scanner.well", "pk": 2, "fields": {"author": 1, "name": "A2"}}, {"model": "scanner.well", "pk": 3, "fields": {"author": 1, "name": "A3"}}, {"model": "scanner.well", "pk": 4, "fields": {"author": 1, "name": "A4"}}, {"model": "scanner.well", "pk": 5, "fields": {"author": 1, "name": "A5"}}, {"model": "scanner.well", "pk": 6, "fields": {"author": 1, "name": "A6"}}, {"model": "scanner.well", "pk": 7, "fields": {"author": 1, "name": "B1"}}, {"model": "scanner.well", "pk": 8, "fields": {"author": 1, "name": "B2"}}, {"model": "scanner.well", "pk": 9, "fields": {"author": 1, "name": "B3"}}, {"model": "scanner.well", "pk": 10, "fields": {"author": 1, "name": "B4"}}, {"model": "scanner.well", "pk": 11, "fields": {"author": 1, "name": "B5"}}, {"model": "scanner.well", "pk": 12, "fields": {"author": 1, "name": "B6"}}, {"model": "scanner.well", "pk": 13, "fields": {"author": 1, "name": "C1"}}, {"model": "scanner.well", "pk": 14, "fields": {"author": 1, "name": "C2"}}, {"model": "scanner.well", "pk": 15, "fields": {"author": 1, "name": "C3"}}, {"model": "scanner.well", "pk": 16, "fields": {"author": 1, "name": "C4"}}, {"model": "scanner.well", "pk": 17, "fields": {"author": 1, "name": "C5"}}, {"model": "scanner.well", "pk": 18, "fields": {"author": 1, "name": "C6"}}, {"model": "scanner.well", "pk": 19, "fields": {"author": 1, "name": "D1"}}, {"model": "scanner.well", "pk": 20, "fields": {"author": 1, "name": "D2"}}, {"model": "scanner.well", "pk": 21, "fields": {"author": 1, "name": "D3"}}, {"model": "scanner.well", "pk": 22, "fields": {"author": 1, "name": "D4"}}, {"model": "scanner.well", "pk": 23, "fields": {"author": 1, "name": "D5"}}, {"model": "scanner.well", "pk": 24, "fields": {"author": 1, "name": "D6"}}] diff --git a/etc/db/wellposition.json b/etc/db/wellposition.json deleted file mode 100644 index f358ad4..0000000 --- a/etc/db/wellposition.json +++ /dev/null @@ -1,2 +0,0 @@ -Django BASE_DIR: /home/rpi4/django-test-tube-scanner/test_tube_scanner -Django application data: /home/rpi4/django-test-tube-scanner/test_tube_scanner diff --git a/etc/scanner_service.conf b/etc/scanner_service.conf new file mode 100644 index 0000000..cdae740 --- /dev/null +++ b/etc/scanner_service.conf @@ -0,0 +1,46 @@ +[group:test_tube] +programs=webUI,planification,services + +[program:webUI] +process_name=%(program_name)s +priority=500 +directory=/home/rpi4/PlanarianScanner/test_tube_scanner +command= + /home/rpi4/PlanarianScanner/.venv/bin/daphne + -b 0.0.0.0 + -p 8000 + home.asgi:application +user=rpi4 +group=rpi4 +stopasgroup=true +stopsignal=SIGINT +autostart=true +autorestart=true +redirect_stderr=true + +[program:planification] +process_name=%(program_name)s +priority=800 +directory=/home/rpi4/PlanarianScanner/test_tube_scanner +command=/home/rpi4/PlanarianScanner/.venv/bin/celery -A home beat -l info +user=rpi4 +group=rpi4 +stopasgroup=true +stopsignal=SIGINT +autostart=true +autorestart=true +redirect_stderr=true + +[program:services] +process_name=%(program_name)s +priority=900 +directory=/home/rpi4/PlanarianScanner/test_tube_scanner +command=/home/rpi4/PlanarianScanner/run-workers.sh +user=rpi4 +group=rpi4 +stopasgroup=true +stopsignal=SIGINT +autostart=true +autorestart=true +redirect_stderr=true + diff --git a/run-workers.sh b/run-workers.sh index 44fc14e..beda0d8 100755 --- a/run-workers.sh +++ b/run-workers.sh @@ -1,7 +1,6 @@ #!/bin/bash -APP_DIR="/home/rpi4/django-test-tube-scanner" -#APP_DIR="/home/rpi4/PlanarianScanner" +APP_DIR="/home/rpi4/PlanarianScanner" cd "$APP_DIR/test_tube_scanner" echo "start workers" diff --git a/test_tube_scanner/.env.example b/test_tube_scanner/.env.example index 2f13a48..c1be9c1 100644 --- a/test_tube_scanner/.env.example +++ b/test_tube_scanner/.env.example @@ -35,7 +35,7 @@ EMAIL_HOST_PASSWORD=123456 EMAIL_USE_TLS=True LOGGING_FILE=test_tube.log -SECRET_KEY=django-insecure-0)4_w=pjv1ex7=s=c=ii3g@fx_=8fb=hxk€3bpk1)uj(0ph0t) +SECRET_KEY="django-insecure-0)4_w=pjv1ex7=s=c=ii3g@fx_=8fb=hxk€3bpk1)uj(0ph0t)" USER=rpi4 GROUP=rpi4 @@ -74,10 +74,10 @@ DATABASE_POSTGRES_PORT=5432 #### # database # -DATABASE_ROOT_PASSWORD=change_me +DATABASE_ROOT_PASSWORD=planaire DATABASE_NAME=test_tube DATABASE_USER=test_tube -DATABASE_PASSWORD=change_me +DATABASE_PASSWORD=planaire #### ## reductstore diff --git a/test_tube_scanner/home/static/img/zigbee2mqtt.png b/test_tube_scanner/home/static/img/zigbee2mqtt.png deleted file mode 100644 index 3eccb50..0000000 Binary files a/test_tube_scanner/home/static/img/zigbee2mqtt.png and /dev/null differ diff --git a/test_tube_scanner/scanner/templates/scanner/base.html b/test_tube_scanner/scanner/templates/scanner/base.html index c577eb6..8a2bfa4 100644 --- a/test_tube_scanner/scanner/templates/scanner/base.html +++ b/test_tube_scanner/scanner/templates/scanner/base.html @@ -77,9 +77,9 @@ {% trans "Base de données Reductstore" %} - +