Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise steps for building AliroEd #638

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions raspberrypi/build_rpi/Readme.md
Original file line number Diff line number Diff line change
@@ -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-<kernel-name>`
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
Expand Down
15 changes: 15 additions & 0 deletions raspberrypi/build_rpi/aliroed-load.service
Original file line number Diff line number Diff line change
@@ -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
15 changes: 2 additions & 13 deletions raspberrypi/build_rpi/autostart
Original file line number Diff line number Diff line change
@@ -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
13 changes: 9 additions & 4 deletions raspberrypi/build_rpi/clean.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions raspberrypi/build_rpi/docker_compress.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions raspberrypi/build_rpi/docker_prune.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#/bin/bash
docker system prune -a -f
docker volume prune -a
4 changes: 2 additions & 2 deletions raspberrypi/build_rpi/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading