From 7a43aac98f57be71b5f33d92d4bf3eac25156ad5 Mon Sep 17 00:00:00 2001 From: Jay Moran Date: Mon, 27 Nov 2023 19:01:18 -0800 Subject: [PATCH] Revise steps for building AliroEd --- raspberrypi/build_rpi/Readme.md | 38 ++++++++++++++-------- raspberrypi/build_rpi/aliroed-load.service | 15 +++++++++ raspberrypi/build_rpi/autostart | 15 ++------- raspberrypi/build_rpi/clean.sh | 13 +++++--- raspberrypi/build_rpi/docker_compress.sh | 5 +++ raspberrypi/build_rpi/docker_prune.sh | 3 ++ raspberrypi/build_rpi/install.sh | 4 +-- 7 files changed, 60 insertions(+), 33 deletions(-) create mode 100644 raspberrypi/build_rpi/aliroed-load.service create mode 100644 raspberrypi/build_rpi/docker_compress.sh create mode 100644 raspberrypi/build_rpi/docker_prune.sh diff --git a/raspberrypi/build_rpi/Readme.md b/raspberrypi/build_rpi/Readme.md index 5cfe73bc5..51aaa972f 100644 --- a/raspberrypi/build_rpi/Readme.md +++ b/raspberrypi/build_rpi/Readme.md @@ -1,24 +1,34 @@ # Raspberry Pi OS Setup Instructions 1. Use the raspberry pi imager to write Raspberry Pi OS Lite (64-bit) onto an sd card -2. Boot the Raspberry Pi OS and setup the locale, keyboard layout and initial username and password. Enable **Auto-Login** in **System Options** -**NOTE:** The following steps require that the Raspberry Pi have an active internet connection. Wifi can be configured by running `sudo raspi-config` and setting up the **Wireless LAN** in **System Options**. -3. run install.sh +2. Boot the Raspberry Pi OS +**NOTE:** The following steps require that the Raspberry Pi have an active internet connection. +Wifi can be configured by running `sudo raspi-config` and setting up the **Wireless LAN** in **System Options**. +3. Run install.sh a. verify that docker is installed. Run `docker --version` -4. save the autostart file in /etc/xdg/openbox/ -5. copy the .bash_profile file into the initial user's home directory (~/.bash_profile) -6. copy the ./Aliro/raspberrypi/intropage directory into the root directory (/intropage) -7. copy the extracted contents of the Aliro-*.zip file from the GitHub release page into the root directory. (/target) -8. change directory into /target/production/Aliro-*/ and run `docker compose pull` - **NOTE:** The docker images will only be **pulled**. The containers will not be built inside the Pi (to keep the final custom OS as light as possible) -9. copy the aliroed-compose.service file in /etc/systemd/system/ (`sudo cp aliroed-compose.service /etc/systemd/system/` -10. enable the aliroed-compose service with `sudo systemctl enable aliroed-compose.service` +4. Copy the ./Aliro/raspberrypi/intropage directory into the root directory (/intropage) +5. Open the chromium-browser (`right-click the desktop and open the web browser`) +6. Configure the browser to open a custom page when it starts `file:///home/aliroed/intropage/index.html` +4. Add the line in the `autostart` file in the existing `/etc/xdg/openbox/autostart` file. +**Note:** if the `autostart` file doesn't exist, you can copy the one here as-is. +5. Download the `Aliro-*.zip` file from the GitHub release page into the home directory. (`~/Alizo-*.zip`) +6. unzip the `.zip` file +7. Move the contents of the `~/target/production/Aliro-*/` directory into `/aliro/` (`mkdir /aliro` first) +8. Change directory into the aliro directory `cd /aliro` and run `docker compose pull` +9. run the `docker_compress.sh` script to compress the pulled docker images. +Check that the images were saved in the `/images` directory, you should see 3 .tar.gz files: +`aliro_dbmongo.tar.gz` +`aliro_lab.tar.gz` +`aliro_machine.tar.gz` +10. Remove the pulled docker images by running the `docker_prune.sh` script. This will greatly reduce +the space used by the images. +11. copy the aliroed-compose.service file in /etc/systemd/system/ (`sudo cp aliroed-compose.service /etc/systemd/system/` +12. enable the aliroed-compose service with `sudo systemctl enable aliroed-compose.service` + +# not sure if the next steps will be necessary 12. Remove any unused kernels: use `uname -r` to check the current kernel in use use `dpkg -l | grep linux-image` to see a list of installed kernels remove the ones we don't need with `sudo apt purge linux-image-` -13. Zero out free space for better compression: - This one was useless! -Inside the Raspberry Pi, run `sudo dd if=/dev/zero of=/EMPTY bs=1M` and `sudo rm -f /EMPTY` 14. run clean.sh # Building the aliro-image executable diff --git a/raspberrypi/build_rpi/aliroed-load.service b/raspberrypi/build_rpi/aliroed-load.service new file mode 100644 index 000000000..da562dd8c --- /dev/null +++ b/raspberrypi/build_rpi/aliroed-load.service @@ -0,0 +1,15 @@ +[Unit] +Description=AliroEd Load Service +After=docker.service +Requires=docker.service + +[Service] +Type=oneshot +WorkingDirectory=/images +ExecStart=/usr/bin/docker load -i /images/aliro_dbmongo.tar.gz +ExecStart=/usr/bin/docker load -i /images/aliro_lab.tar.gz +ExecStart=/usr/bin/docker load -i /images/aliro_machine.tar.gz +ExecStartPost=/bin/systemctl disable aliroed-load.service + +[Install] +WantedBy=multi-user.target diff --git a/raspberrypi/build_rpi/autostart b/raspberrypi/build_rpi/autostart index 92a86e57a..0b468d400 100644 --- a/raspberrypi/build_rpi/autostart +++ b/raspberrypi/build_rpi/autostart @@ -1,13 +1,2 @@ -# Place this file in /etc/xdg/openbox/ -# Disable any form of screen saver / screen blanking / power management -xset s off -xset s noblank -xset -dpms - -# Allow quitting the X server with CTRL-ATL-Backspace -setxkbmap -option terminate:ctrl_alt_bksp - -# Start Chromium in kiosk mode -sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State' -sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences -chromium-browser --disable-infobars --kiosk 'file:///intropage/index.html' +# Add this line at the bottom of the /etc/xdg/openbox/ file +chromium-browser --start-maximized diff --git a/raspberrypi/build_rpi/clean.sh b/raspberrypi/build_rpi/clean.sh index d0f44929d..849296a72 100644 --- a/raspberrypi/build_rpi/clean.sh +++ b/raspberrypi/build_rpi/clean.sh @@ -1,16 +1,21 @@ #/bin/bash # disable and remove bluetooth # not needed in kiosk mode -sudo systemctl disable hciuart.service -sudo systemctl disable bluealsa.service -sudo systemctl disable bluetooth.service -sudo apt purge bluez -y +#sudo systemctl disable hciuart.service +#sudo systemctl disable bluealsa.service +#sudo systemctl disable bluetooth.service +#sudo apt purge bluez -y # remove unnecessary packages and clean up apt +# these are installed by the docker shell script +sudo apt remove docker-buildx-plugin -y +# these come pre-installed +sudo apt purge htop sudo apt autoremove -y sudo apt autoclean -y sudo apt clean -y sudo journalctl --vacuum-time=7d docker builder prune --all +rm ~/get-docker.sh sudo rm -rf /var/log/* sudo rm -rf /tmp/* # clear bash history diff --git a/raspberrypi/build_rpi/docker_compress.sh b/raspberrypi/build_rpi/docker_compress.sh new file mode 100644 index 000000000..0c471229e --- /dev/null +++ b/raspberrypi/build_rpi/docker_compress.sh @@ -0,0 +1,5 @@ +#/bin/bash +mkdir /images +docker save moorelab/aliro_dbmongo | gzip > /images/aliro_dbmongo.tar.gz +docker save moorelab/aliro_lab | gzip > /images/aliro_lab.tar.gz +docker save moorelab/aliro_machine | gzip > /images/aliro_machine.tar.gz diff --git a/raspberrypi/build_rpi/docker_prune.sh b/raspberrypi/build_rpi/docker_prune.sh new file mode 100644 index 000000000..4a09bca18 --- /dev/null +++ b/raspberrypi/build_rpi/docker_prune.sh @@ -0,0 +1,3 @@ +#/bin/bash +docker system prune -a -f +docker volume prune -a \ No newline at end of file diff --git a/raspberrypi/build_rpi/install.sh b/raspberrypi/build_rpi/install.sh index 89d0e7ec1..bdc11ac84 100644 --- a/raspberrypi/build_rpi/install.sh +++ b/raspberrypi/build_rpi/install.sh @@ -3,9 +3,9 @@ sudo apt update sudo apt upgrade # install xserver, xinit, openbox, chromium-browser, pcmanfm, docker -sudo apt install --no-install-recommends xserver-xorg x11-xserver-utils xinit openbox +sudo apt install --no-install-recommends xserver-xorg x11-xserver-utils xinit sudo apt install --no-install-recommends chromium-browser -sudo apt install pcmanfm +sudo apt install openbox lxterminal lightdm pcmanfm # use the convenience script to install docker curl -fsSL https://get.docker.com -o get-docker.sh sudo sh ./get-docker.sh