76 lines
1.5 KiB
Bash
Executable file
76 lines
1.5 KiB
Bash
Executable file
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="/home/nvme/epub-gec-experiment"
|
|
INSTALL_DIR="$PROJECT_DIR/epub-corrector-ui-app"
|
|
VENV="$PROJECT_DIR/.venv-rknn"
|
|
SERVICE_NAME="epub-corrector-ui"
|
|
|
|
echo "Directory sorgente: $SOURCE_DIR"
|
|
echo "Directory installazione: $INSTALL_DIR"
|
|
|
|
test -f "$SOURCE_DIR/app.py" || {
|
|
echo "ERRORE: app.py non trovato in $SOURCE_DIR"
|
|
exit 1
|
|
}
|
|
|
|
test -f "$SOURCE_DIR/static/index.html" || {
|
|
echo "ERRORE: static/index.html non trovato"
|
|
exit 1
|
|
}
|
|
|
|
test -x "$VENV/bin/python" || {
|
|
echo "ERRORE: ambiente Python non trovato: $VENV"
|
|
exit 1
|
|
}
|
|
|
|
mkdir -p "$INSTALL_DIR/static"
|
|
|
|
cp -v \
|
|
"$SOURCE_DIR/app.py" \
|
|
"$INSTALL_DIR/app.py"
|
|
|
|
cp -v \
|
|
"$SOURCE_DIR/static/index.html" \
|
|
"$INSTALL_DIR/static/index.html"
|
|
|
|
"$VENV/bin/python" -m pip install \
|
|
flask \
|
|
requests \
|
|
lxml \
|
|
tokenizers
|
|
|
|
cat > /tmp/epub-corrector-ui.service <<EOF
|
|
[Unit]
|
|
Description=EPUB Corrector Web UI
|
|
After=network.target docker.service
|
|
Wants=docker.service
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=orangepi
|
|
WorkingDirectory=$INSTALL_DIR
|
|
ExecStart=$VENV/bin/python $INSTALL_DIR/app.py
|
|
Restart=on-failure
|
|
RestartSec=5
|
|
Environment=PYTHONUNBUFFERED=1
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
sudo cp -v \
|
|
/tmp/epub-corrector-ui.service \
|
|
/etc/systemd/system/$SERVICE_NAME.service
|
|
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable "$SERVICE_NAME"
|
|
sudo systemctl restart "$SERVICE_NAME"
|
|
|
|
echo
|
|
echo "=== STATO SERVIZIO ==="
|
|
|
|
sudo systemctl status \
|
|
"$SERVICE_NAME" \
|
|
--no-pager
|