Skip to content

Commit

Permalink
improve installation
Browse files Browse the repository at this point in the history
  • Loading branch information
pablobuenaposada committed Nov 4, 2024
1 parent 2a8d2c3 commit ad52b95
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 10 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ test: venv-dev
PYTHONPATH=src poetry run pytest src/tests

run_rpi:
cp -n default_setup.json setup.json
export PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring
sudo PYTHONPATH=src /home/pi/.local/bin/poetry run python src/main.py &
docker compose up --build -d nginx
sudo cp -n default_setup.json setup.json
sudo PYTHONPATH=src poetry run python /home/pi/Desktop/HonDash/src/main.py

docker/build:
docker build --no-cache --tag=$(DOCKER_IMAGE) .
Expand All @@ -31,3 +29,9 @@ docker/run:

docker/tests:
docker run --rm $(DOCKER_IMAGE) /bin/sh -c 'make test'

sd-image/create:
sudo dd bs=1024 if=$(path) of=full_size_image.img

sd-image/shrink:
docker run --privileged=true --rm --volume $(shell pwd):/workdir monsieurborges/pishrink pishrink -v full_size_image.img shrinked_image.img
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:

nginx:
image: nginx:latest
restart: always
ports:
- "9090:80"
volumes:
Expand Down
2 changes: 0 additions & 2 deletions installation/crontab

This file was deleted.

34 changes: 30 additions & 4 deletions installation/install_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,51 @@ curl -sSL https://get.docker.com | sh
sudo usermod -aG docker ${USER}
sudo systemctl enable docker
sudo apt update
sudo apt install python3 python3-pip vim unclutter
curl -sSL https://install.python-poetry.org | python3 -
sudo apt install -y python3 python3-pip vim xdotool libopenblas-dev
pip install poetry --break-system-packages
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
sudo su
pip install poetry --break-system-packages
su pi

cd /home/pi/Desktop/
git clone https://github.com/pablobuenaposada/HonDash.git
cd HonDash
git checkout refresh
export PYTHON_KEYRING_BACKEND=keyring.backends.fail.Keyring
sed -i '1i [[tool.poetry.source]]\nname = "piwheels"\nurl = "https://www.piwheels.org/simple/"\n' pyproject.toml
poetry lock
sudo su
make venv
su pi
docker compose up -d nginx
touch /home/pi/Desktop/HonDash/hondash.log
sudo chmod 777 /home/pi/Desktop/HonDash/hondash.log

cd /home/pi/Desktop/
git clone https://github.com/pablobuenaposada/HonDash-frontend.git
cd HonDash-frontend
make docker/build
docker run -d --restart=unless-stopped --network=hondash_main_network -p 80:80 hondash-frontend

crontab /home/pi/Desktop/HonDash/crontab/crontab
sudo cp /home/pi/Desktop/HonDash/installation/services/chromium.service /etc/systemd/system/
sudo cp /home/pi/Desktop/HonDash/installation/services/chromium-refresh.service /etc/systemd/system/
sudo cp /home/pi/Desktop/HonDash/installation/services/hondash.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable chromium.service
sudo systemctl start chromium.service
sudo systemctl enable chromium-refresh.service
sudo systemctl start chromium-refresh.service
sudo systemctl enable hondash.service
sudo systemctl start hondash.service

echo '@unclutter -idle 0.1' | sudo tee -a /etc/xdg/lxsession/LXDE-pi/autostart > /dev/null
env DISPLAY=:0.0 pcmanfm -w /home/pi/Desktop/HonDash/docs/wallpaper/wallpaper.png --wallpaper-mode=stretch
sudo rm /etc/xdg/lxsession/LXDE-pi/sshpwd.sh
{ echo '@xset s off'; echo '@xset -dpms'; echo '@xset s noblank'; } | sudo tee -a /etc/xdg/lxsession/LXDE-pi/autostart > /dev/null

sudo systemctl disable bluetooth.service
sudo systemctl disable hciuart.service
sudo systemctl disable cron.service
sudo systemctl disable cups-browsed.service
sudo systemctl disable triggerhappy.service
25 changes: 25 additions & 0 deletions installation/refresh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

export XAUTHORITY=/home/pi/.Xauthority
export DISPLAY=:0

# Desired window title when the page is fully loaded
EXPECTED_TITLE="hondash.local/"

# Loop until the window title contains the expected text
while : ; do
# Get the active window's title
WINDOW_TITLE=$(xdotool search --onlyvisible --class "chromium" getwindowname 2>/dev/null)

# Check if the title matches the expected page title
if [[ "$WINDOW_TITLE" == *"$EXPECTED_TITLE"* ]]; then
echo "Page loaded successfully!"
break
else
# If not, send an F5 to refresh the page and retry
echo "Page not loaded yet. Current title: $WINDOW_TITLE. Retrying..."
xdotool key F5
fi

sleep 5
done
13 changes: 13 additions & 0 deletions installation/services/chromium-refresh.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Your Description Here
After=network.target

[Service]
ExecStart=/bin/bash /home/pi/Desktop/HonDash/installation/refresh.sh
Restart=always
User=pi
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/pi/.Xauthority

[Install]
WantedBy=multi-user.target
14 changes: 14 additions & 0 deletions installation/services/chromium.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Chromium Kiosk
After=graphical.target

[Service]
User=pi
Group=pi
Environment=XAUTHORITY=/home/pi/.Xauthority
Environment=DISPLAY=:0
ExecStart=/usr/bin/chromium-browser --no-sandbox --disable-gpu --noerrdialogs --disable-infobars --disable-session-crashed-bubble --disable-features=TranslateUI --kiosk --check-for-update-interval=604800 --incognito http://hondash.local
Restart=on-failure

[Install]
WantedBy=graphical.target
15 changes: 15 additions & 0 deletions installation/services/hondash.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=HonDash Docker Service
After=local-fs.target

[Service]
Environment=DISPLAY=:0
WorkingDirectory=/home/pi/Desktop/HonDash/
ExecStart=/bin/bash -c 'make run_rpi'
Restart=always
User=pi
StandardOutput=append:/home/pi/Desktop/HonDash/hondash.log
StandardError=append:/home/pi/Desktop/HonDash/hondash.log

[Install]
WantedBy=multi-user.target

0 comments on commit ad52b95

Please sign in to comment.