setup-life-display

Instructions and scripts to setup sdl2-life on a Raspberry Pi
git clone https://www.brianlane.com/git/setup-life-display
Log | Files | Refs | README

commit bb364bf1bba3d8f088b986490a3e0747ccabb4d7
Author: Brian C. Lane <bcl@brianlane.com>
Date:   Sat,  5 Aug 2023 12:16:25 -0700

Initial commit of setup-life-display

Diffstat:
AREADME.md | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aansible.cfg | 5+++++
Aconfigs/config.txt | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aconfigs/issue | 3+++
Aconfigs/run-life-server | 14++++++++++++++
Aconfigs/tmux.conf | 16++++++++++++++++
Aconfigs/tmux.service | 10++++++++++
Aconfigs/tmux@.service | 20++++++++++++++++++++
Aconfigs/userconf | 1+
Aconfigs/watchdog.conf | 4++++
Aconfigs/wpa_supplicant.conf | 10++++++++++
Ahosts | 5+++++
Asetup.sh | 21+++++++++++++++++++++
Asetup.yml | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14 files changed, 358 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -0,0 +1,62 @@ += Initial setup of SD card for Life Display + +Download Pi OS lite version from +https://www.raspberrypi.com/software/operating-systems/ + +unxz the image and use `dd` to write it to a SD card. + +Mount the SD card / and /boot on a directory under /mnt/, eg. + +sudo mkdir -p /mnt/d1/boot /mnt/d1/root +sudo mount /dev/mmcblk0p1 /mnt/d1/boot +sudo mount /dev/mmcblk0p2 /mnt/d1/root + +Run the ./setup.sh script, passing /mnt/d1/ + +sudo ./setup.sh /mnt/d1/ + +Edit /mnt/d1/boot/wpa_supplicant.conf and change the SSID and password to your AP. + +Optionally change the password of the life user by replacing the default password in +/mnt/d1/boot/userconf with the output from: +openssl passwd -6 + +Unmount /mnt/d1/boot and /mnt/d1/root and insert the SD card into the Pi and boot it. + +It is best to do this with a display and keyboard so you can see what IP address is assigned, +or deal with any unexpected errors. + +Now you can reboot, and it should show the IP address at the login prompt, depending on the +timing of bringing up the network. + +Edit the hosts file to set the correct IP address. +Run the setup.yml playbook to setup the life display and change the boot display settings. + +ansible-playbook -v -k ./setup.yml + +the SSH password will be the password you created for the 'life' user. Or the default of +asdasdasd + += Build sdl2-life + +It is easiest to just build the sdl2-life program on the Pi. The git repo has been checked +out into /opt/sdl2-life/ and it should simply be a matter of running: + + cd /opt/sdl2-life && go build + +to build it. + += Final Steps + +At this point the system should be ready. You can run /home/life/run-life-server to test, and +then reboot to make sure it starts on its own. + +If everything looks ok you can turn off the boot logo and text by editing /boot/cmdline.txt +and adding: + + logo.nologo console=null quiet + +to the end of the kernel boot cmdline. This does make it much harder to debug problems, but +worst case you can mount the SD card on another system and remove those arguments to turn +them back on. + diff --git a/ansible.cfg b/ansible.cfg @@ -0,0 +1,5 @@ +[defaults] +inventory=./hosts +log_path=./logs/ansible.log +verbose=true +retry_files_enabled = False diff --git a/configs/config.txt b/configs/config.txt @@ -0,0 +1,100 @@ +# For more options and information see +# http://rpf.io/configtxt +# Some settings may impact device functionality. See link above for details + +# uncomment if you get no picture on HDMI for a default "safe" mode +#hdmi_safe=1 + +# uncomment the following to adjust overscan. Use positive numbers if console +# goes off screen, and negative if there is too much border +#overscan_left=16 +#overscan_right=16 +#overscan_top=16 +#overscan_bottom=16 + +# uncomment to force a console size. By default it will be display's size minus +# overscan. +#framebuffer_width=1280 +#framebuffer_height=720 + +# uncomment if hdmi display is not detected and composite is being output +#hdmi_force_hotplug=1 + +# uncomment to force a specific HDMI mode (this will force VGA) +#hdmi_group=1 +#hdmi_mode=1 + +# uncomment to force a HDMI mode rather than DVI. This can make audio work in +# DMT (computer monitor) modes +#hdmi_drive=2 + +# Used with Adafruit 800x480 display +hdmi_group=2 +hdmi_mode=87 +hdmi_cvt=800 480 60 6 0 0 0 +hdmi_drive=1 + +# uncomment to increase signal to HDMI, if you have interference, blanking, or +# no display +#config_hdmi_boost=4 + +# uncomment for composite PAL +#sdtv_mode=2 + +#uncomment to overclock the arm. 700 MHz is the default. +#arm_freq=800 + +# Uncomment some or all of these to enable the optional hardware interfaces +#dtparam=i2c_arm=on +#dtparam=i2s=on +#dtparam=spi=on + +# Enable watchdog hardware +dtparam=watchdog=on + +# Uncomment this to enable infrared communication. +#dtoverlay=gpio-ir,gpio_pin=17 +#dtoverlay=gpio-ir-tx,gpio_pin=18 + +# Additional overlays and parameters are documented /boot/overlays/README + +# Enable audio (loads snd_bcm2835) +dtparam=audio=on + +# Automatically load overlays for detected cameras +camera_auto_detect=1 + +# Automatically load overlays for detected DSI displays +display_auto_detect=1 + +# Enable DRM VC4 V3D driver +dtoverlay=vc4-kms-v3d +max_framebuffers=2 + +# Disable compensation for displays with overscan +disable_overscan=1 + +# Allow usb to source max current +max_usb_current=1 + +# Rotate the display 90 degrees so it is 480x800 portrait mode +# https://elinux.org/RPiconfig +# NOTE: Doesn't work +#display_rotate=1 + +# Disable the color bar splash +disable_splash=1 + +[cm4] +# Enable host mode on the 2711 built-in XHCI USB controller. +# This line should be removed if the legacy DWC2 controller is required +# (e.g. for USB device mode) or if USB support is not required. +otg_mode=1 + +[all] + +[pi4] +# Run as fast as firmware / board allows +arm_boost=1 + +[all] diff --git a/configs/issue b/configs/issue @@ -0,0 +1,3 @@ +Raspbian GNU/Linux 11 \n \l +\4 + diff --git a/configs/run-life-server b/configs/run-life-server @@ -0,0 +1,14 @@ +#!/usr/bin/sh +cd /opt/sdl2-life || exit 1 + +VIDEO=/dev/dri/card0 + +# Wait for video card to appear and have correct permission +echo "Waiting for $VIDEO" +while [ ! -e "$VIDEO" ] || [ ! -w "$VIDEO" ]; do + sleep 1 + ls -l "$VIDEO" +done + +echo "Starting sdl2-life" +./sdl2-life -font /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf -height 480 -width 800 -fps 20 -color -colors "#ff0000,#00ff00,#ffff00,#ffffff" -gradient 2 -rotate 270 -server -host 0.0.0.0 diff --git a/configs/tmux.conf b/configs/tmux.conf @@ -0,0 +1,16 @@ +bind -n M-tab next +bind -n F1 list-keys + +set-option -g exit-unattached off +set-option -g base-index 1 + +set-option -g history-limit 100 +set-window-option -g aggressive-resize on + +new-session -s life -n main "/home/life/run-life-server; bash --login" +set-option -s remain-on-exit on + +set-option status-right '#[fg=blue]#(echo -n "Switch tab: Alt+Tab | Help: F1 ")' + +new-window -d -n shell "bash --login" +new-window -d -n journal-log "journalctl -f" diff --git a/configs/tmux.service b/configs/tmux.service @@ -0,0 +1,10 @@ +[Unit] +Description=tmux sdl2life session +After=multi-user.target network.target + +[Service] +Type=forking +User=life +PAMName=login +WorkingDirectory=/home/life/ +ExecStart=/usr/bin/tmux -u -f /home/life/.tmux.conf start diff --git a/configs/tmux@.service b/configs/tmux@.service @@ -0,0 +1,20 @@ +[Unit] +Description=sdl2life console service +Requires=tmux.service +After=multi-user.target +ConditionKernelCommandLine=!nolife + +[Service] +Type=idle +User=life +WorkingDirectory=/home/life +Environment=LANG=en_US.UTF-8 +ExecStart=/usr/bin/tmux -u attach -t life +StandardInput=tty +StandardOutput=tty +TTYPath=/dev/%I +TTYReset=yes +TTYVHangup=yes +TTYVTDisallocate=yes +Restart=always +RestartSec=0 diff --git a/configs/userconf b/configs/userconf @@ -0,0 +1 @@ +life:$6$wl3Fk4si/8RSYBJR$x99OnwZWwqk29VHELj2QbVpbE8rhFCPBNX/PMnx2hM/AhNSfmCLYpBres7Vg7YZHaqmJa74XdwQA6eUOaslUI. diff --git a/configs/watchdog.conf b/configs/watchdog.conf @@ -0,0 +1,4 @@ +watchdog-device = /dev/watchdog +watchdog-timeout = 15 +max-load-1 = 24 + diff --git a/configs/wpa_supplicant.conf b/configs/wpa_supplicant.conf @@ -0,0 +1,10 @@ +country=US +ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev +update_config=1 + +network={ + ssid="SSID" + psk="PASSPHRASE" + key_mgmt=WPA-PSK + id_str="AP1" +} diff --git a/hosts b/hosts @@ -0,0 +1,5 @@ +[lifedisplay] +192.168.101.189 ansible_ssh_user=life ansible_ssh_port=22 + +[lifedisplay:vars] +ansible_python_interpreter=/usr/bin/python3 diff --git a/setup.sh b/setup.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# SD card /boot partition must be mounted on $1 + +[ -z "$1" ] && { echo "Usage: $0 <root-path>"; exit 1; } +[ -e "$1/boot" -a -e "$1/root" ] || { echo "boot or root is missing from $1"; exit 1; } + +ROOT=$1 +# Enable ssh +touch $ROOT/boot/ssh +cp ./configs/wpa_supplicant.conf $ROOT/boot/ +cp ./configs/userconf $ROOT/boot/ +cp ./configs/config.txt $ROOT/boot/ +cp ./configs/issue $ROOT/root/etc/issue + +# Check out the sdl2-life source +mkdir $ROOT/root/opt/ +cd $ROOT/root/opt/ +GIT_SSL_NO_VERIFY=true git clone https://github.com/bcl/sdl2-life.git + +echo "SETUP YOUR AP IN $ROOT/boot/wpa_supplicant.conf" diff --git a/setup.yml b/setup.yml @@ -0,0 +1,87 @@ +--- +- hosts: lifedisplay + become_user: root + become: true + tasks: + - name: Make sure needed applications are installed + apt: + name: + - python3 + - tmux + - watchdog + - golang + - libsdl2-2.0-0 + - libsdl2-dev + - libsdl2-ttf-2.0-0 + - libsdl2-ttf-dev + - git + state: latest + update_cache: true + + - name: Install the watchdog config + copy: + src: "./configs/{{ item }}" + dest: /etc/ + owner: root + group: root + mode: 0644 + with_items: + - watchdog.conf + + - name: Start the watchdog service + service: + name: watchdog + state: started + enabled: true + + - name: Install the systemd service files + copy: + src: "./configs/{{ item }}" + dest: /lib/systemd/system/ + owner: root + group: root + mode: 0644 + with_items: + - tmux.service + - tmux@.service + + - name: Disable getty@tty1 + systemd: + name: getty@tty1 + state: stopped + enabled: false + daemon_reload: true + + - name: Add multi-user.target.wants + file: + dest: /lib/systemd/system/multi-user.target.wants/ + state: directory + + - name: Add tmux@tty1.service to multi-user.target.wants + file: + src: /lib/systemd/system/tmux@.service + dest: /lib/systemd/system/multi-user.target.wants/tmux@tty1.service + state: link + + - name: Copy over tmux.conf + copy: + src: ./configs/tmux.conf + dest: /home/life/.tmux.conf + owner: life + group: life + + - name: Copy over run-life-server + copy: + src: ./configs/run-life-server + dest: /home/life/run-life-server + owner: life + group: life + mode: 0755 + + - name: Change ownership of /opt/sdl2-life + file: + dest: /opt/sdl2-life + owner: life + group: life + mode: u=rwX,g=rX,o=rX + recurse: true