From 7e17948ff334309ba383e4a44955fd1646f74bb3 Mon Sep 17 00:00:00 2001 From: Austin Vance Date: Tue, 27 Aug 2019 23:22:03 -0500 Subject: [PATCH 01/29] Update the image generation to work with Buster --- docs/image-setup.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index e2a19c4..9ccc8b8 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -124,12 +124,22 @@ ssh "df -h . && sudo resize2fs /dev/mmcblk0p2 && df -h ." working "Enabling auto-login to CLI" # From: https://github.com/RPi-Distro/raspi-config/blob/985548d7ca00cab11eccbb734b63750761c1f08a/raspi-config#L955 SUDO_USER=pi +AUTOLOG="$(cat < Date: Sat, 7 Sep 2019 14:42:39 +0300 Subject: [PATCH 02/29] Update image-setup script to work on linux, plus first changes for Raspbian Buster. --- docs/image-setup.sh | 104 +++++++++++++++++++++++++++++++++----------- 1 file changed, 78 insertions(+), 26 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index 9ccc8b8..031c45a 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -1,27 +1,76 @@ #!/bin/bash -MOUNTED_BOOT_VOLUME="boot" # i.e. under which name is the SD card mounted under /Volumes on macOS -BOOT_CMDLINE_TXT="/Volumes/$MOUNTED_BOOT_VOLUME/cmdline.txt" -BOOT_CONFIG_TXT="/Volumes/$MOUNTED_BOOT_VOLUME/config.txt" +# exit on error; treat unset variables as errors; exit on errors in piped commands +set -euo pipefail + +# Ensure we operate from consistent pwd for the rest of the script +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" # Figure out the ABSOLUTE PATH of this script without relying on the realpath command, which may not always be available +cd "$DIR" + +if [ "$OSTYPE" == "linux-gnu" ]; then + MOUNTED_BOOT_VOLUME="/media/$(whoami)/boot" # i.e. under which name is the SD card mounted under /media in Linux (Ubuntu) + SD_DD_BS="1M" + SD_DD_PROGRESS="status=progress" +elif [ "$OSTYPE" == "darwin" ]; then + MOUNTED_BOOT_VOLUME="/Volumes/boot" # i.e. under which name is the SD card mounted under /Volumes on macOS + SD_DD_BS="1m" + SD_DD_PROGRESS="" +else + echo "Error: Unsupported platform $OSTYPE, sorry" + exit 1 +fi + +BOOT_CMDLINE_TXT="$MOUNTED_BOOT_VOLUME/cmdline.txt" +BOOT_CONFIG_TXT="$MOUNTED_BOOT_VOLUME/config.txt" SD_SIZE_REAL=2500 # this is in MB SD_SIZE_SAFE=2800 # this is in MB SD_SIZE_ZERO=3200 # this is in MB -PUBKEY="$(cat ~/.ssh/id_rsa.pub)" +SSH_PUBKEY="$(cat ~/.ssh/id_rsa.pub)" +SSH_CONNECT_TIMEOUT=30 KEYBOARD="us" # or e.g. "fi" for Finnish TIMEZONE="Etc/UTC" # or e.g. "Europe/Helsinki"; see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones +function echo-bold { + echo -e "$(tput -Txterm-256color bold)$1$(tput -Txterm-256color sgr 0)" # https://unix.stackexchange.com/a/269085; the -T arg accounts for $ENV not being set +} function working { - echo -e "\n✨ $1" + echo-bold "\n✨ $1" } function question { - echo -e "\n🛑 $1" + echo-bold "\n🛑 $1" } function ssh { - /usr/bin/ssh -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5 "pi@$IP" "$1" + /usr/bin/ssh -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout="$SSH_CONNECT_TIMEOUT" "pi@$IP" "$1" } function scp { /usr/bin/scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$@" "pi@$IP:/home/pi" } +function figureOutSdCard { + if [ "$OSTYPE" == "linux-gnu" ]; then + lsblk --fs + DISK="/dev/$(lsblk -l | grep "$MOUNTED_BOOT_VOLUME" | sed 's/[0-9].*//')" + DISK_SAMPLE="/dev/sda" + elif [ "$OSTYPE" == "darwin" ]; then + diskutil list + DISK="$(diskutil list | grep /dev/ | grep external | grep physical | cut -d ' ' -f 1 | head -n 1)" + DISK_SAMPLE="/dev/disk2" + else + echo "Error: Unsupported platform $OSTYPE, sorry" + exit 1 + fi +} +function unmountSdCard { + if [ "$OSTYPE" == "linux-gnu" ]; then + for part in $(lsblk --list "$DISK" | grep part | sed 's/ .*//'); do + udisksctl unmount -b "/dev/$part" + done + elif [ "$OSTYPE" == "darwin" ]; then + diskutil unmountDisk "$DISK" + else + echo "Error: Unsupported platform $OSTYPE, sorry" + exit 1 + fi +} question "Enter version (e.g. \"1.2.3\") being built:" read TAG @@ -44,19 +93,18 @@ question "Mount the SD card (press enter when ready)" read working "Figuring out SD card device" -diskutil list -DISK="$(diskutil list | grep /dev/ | grep external | grep physical | cut -d ' ' -f 1 | head -n 1)" +figureOutSdCard -question "Based on the above, SD card determined to be \"$DISK\" (should be e.g. \"/dev/disk2\"), press enter to continue" +question "Based on the above, SD card determined to be \"$DISK\" (should be e.g. \"$DISK_SAMPLE\"), press enter to continue" read working "Safely unmounting the card" -diskutil unmountDisk "$DISK" +unmountSdCard working "Writing the card full of zeros (for security and compressibility reasons)" echo "This may take a long time" echo "You may be prompted for your password by sudo" -sudo dd bs=1m count="$SD_SIZE_ZERO" if=/dev/zero of="$DISK" +sudo dd bs="$SD_DD_BS" count="$SD_SIZE_ZERO" if=/dev/zero of="$DISK" "$SD_DD_PROGRESS" question "Prepare baseline Raspbian:" echo "* Flash Raspbian Lite with Etcher" @@ -76,10 +124,10 @@ mv temp "$BOOT_CMDLINE_TXT" working "Enabling SSH for first boot" # https://www.raspberrypi.org/documentation/remote-access/ssh/ -touch "/Volumes/$MOUNTED_BOOT_VOLUME/ssh" +touch "$MOUNTED_BOOT_VOLUME/ssh" working "Safely unmounting the card" -diskutil unmountDisk "$DISK" +unmountSdCard question "Do initial Pi setup:" echo "* Eject the card" @@ -91,7 +139,7 @@ read IP working "Installing temporary SSH pubkey" echo -e "Password hint: \"raspberry\"" -ssh "mkdir .ssh && echo '$PUBKEY' > .ssh/authorized_keys" +ssh "mkdir .ssh && echo '$SSH_PUBKEY' > .ssh/authorized_keys" working "Figuring out partition start" ssh "echo -e 'p\nq\n' | sudo fdisk /dev/mmcblk0 | grep /dev/mmcblk0p2 | tr -s ' ' | cut -d ' ' -f 2" > temp @@ -109,11 +157,14 @@ working "Setting hostname" ssh "sudo hostnamectl set-hostname chilipie-kiosk" ssh "sudo sed -i 's/raspberrypi/chilipie-kiosk/g' /etc/hosts" +# From now on, some ssh commands will exit non-0, which should be fine +set +e + working "Rebooting the Pi" ssh "sudo reboot" echo "Waiting for host to come back up..." -until ssh "echo OK" +until SSH_CONNECT_TIMEOUT=5 ssh "echo OK" do sleep 1 done @@ -130,13 +181,11 @@ ExecStart= ExecStart=-/sbin/agetty --autologin $SUDO_USER --noclear %I \$TERM EOF )" - ssh "sudo systemctl set-default multi-user.target" +# Set auto-login for TTY's 1-3 ssh "sudo mkdir -p /etc/systemd/system/getty@tty1.service.d && sudo touch /etc/systemd/system/getty@tty1.service.d/autologin.conf && sudo echo '$AUTOLOG' | sudo tee /etc/systemd/system/getty@tty1.service.d/autologin.conf" ssh "sudo mkdir -p /etc/systemd/system/getty@tty2.service.d && sudo touch /etc/systemd/system/getty@tty2.service.d/autologin.conf && sudo echo '$AUTOLOG' | sudo tee /etc/systemd/system/getty@tty2.service.d/autologin.conf" ssh "sudo mkdir -p /etc/systemd/system/getty@tty3.service.d && sudo touch /etc/systemd/system/getty@tty3.service.d/autologin.conf && sudo echo '$AUTOLOG' | sudo tee /etc/systemd/system/getty@tty3.service.d/autologin.conf" - -# Set auto-login for TTY's 1-3 ssh "sudo ln -fs /etc/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty1.service" ssh "sudo ln -fs /etc/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty2.service" ssh "sudo ln -fs /etc/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty3.service" @@ -157,7 +206,7 @@ ssh "sudo apt-get update && sudo apt-get install -y vim matchbox-window-manager working "Setting home directory default content" ssh "rm -rfv /home/pi/*" -scp $(find ../home -type file) +scp $(find ../home -type f) working "Setting splash screen background" ssh "sudo rm /usr/share/plymouth/themes/pix/splash.png && sudo ln -s /home/pi/background.png /usr/share/plymouth/themes/pix/splash.png" @@ -171,6 +220,10 @@ ssh "sudo reboot" question "Once the Pi has rebooted into Chromium:" echo "* Tell Chromium we don't want to sign in" echo "* Configure Chromium to start \"where you left off\"" +echo " * F11 to exit full screen" +echo " * Alt + F, then S to go to Settings" +echo " * Type \"continue\" to filter the options" +echo " * Tab to select \"Continue where you left off\"" echo "* Navigate to \"file:///home/pi/first-boot.html\"" echo "(press enter when ready)" read @@ -193,12 +246,11 @@ ssh "(echo > .ssh/authorized_keys) && sudo systemctl disable ssh && sudo shutdow question "Eject the SD card from the Pi, and mount it back to this computer (press enter when ready)" read -working "Figuring out SD card device" # We do this again now just to be safe -diskutil list -DISK="$(diskutil list | grep /dev/ | grep external | grep physical | cut -d ' ' -f 1 | head -n 1)" +working "Figuring out SD card device" +figureOutSdCard -question "Based on the above, SD card determined to be \"$DISK\" (should be e.g. \"/dev/disk2\"), press enter to continue" +question "Based on the above, SD card determined to be \"$DISK\" (should be e.g. \"$DISK_SAMPLE\"), press enter to continue" read working "Making boot quieter (part 1)" # https://scribles.net/customizing-boot-up-screen-on-raspberry-pi/ @@ -216,13 +268,13 @@ cat "$BOOT_CMDLINE_TXT" \ mv temp "$BOOT_CMDLINE_TXT" working "Safely unmounting the card" -diskutil unmountDisk "$DISK" +unmountSdCard working "Dumping the image from the card" cd .. echo "This may take a long time" echo "You may be prompted for your password by sudo" -sudo dd bs=1m count="$SD_SIZE_SAFE" if="$DISK" of="chilipie-kiosk-$TAG.img" +sudo dd bs="$SD_DD_BS" count="$SD_SIZE_SAFE" if="$DISK" of="chilipie-kiosk-$TAG.img" "$SD_DD_PROGRESS" working "Compressing image" COPYFILE_DISABLE=1 tar -zcvf chilipie-kiosk-$TAG.img.tar.gz chilipie-kiosk-$TAG.img From 92579e2223372a095a12a8867007199149c9ba4c Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Wed, 4 Dec 2019 12:21:39 +0200 Subject: [PATCH 03/29] Updates for alpha2. --- docs/image-setup.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index 031c45a..83f870e 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -72,7 +72,7 @@ function unmountSdCard { fi } -question "Enter version (e.g. \"1.2.3\") being built:" +question "Enter version (e.g. \"1.2.3\") being built (without \"v\" prefix):" read TAG working "Updating version file" @@ -110,6 +110,7 @@ question "Prepare baseline Raspbian:" echo "* Flash Raspbian Lite with Etcher" echo "* Eject the SD card" echo "* Mount the card back" +echo "* Wait for your OS to mount it" echo "(press enter when ready)" read @@ -201,7 +202,7 @@ ssh "sudo rm /etc/profile.d/sshpwd.sh" ssh "echo | sudo tee /etc/motd" working "Installing packages" -ssh "sudo apt-get update && sudo apt-get install -y vim matchbox-window-manager unclutter mailutils nitrogen jq chromium-browser xserver-xorg xinit rpd-plym-splash xdotool" +ssh "sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y vim matchbox-window-manager unclutter mailutils nitrogen jq chromium-browser xserver-xorg xinit rpd-plym-splash xdotool" # We install mailutils just so that you can check "mail" for cronjob output working "Setting home directory default content" From 97eebe64102cc118c3a09efba126ebbc4c9a9b82 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 3 Mar 2020 11:06:50 +0200 Subject: [PATCH 04/29] Add notes on controlling the kiosk remotely to first-boot doc. See #38 --- docs/first-boot.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/first-boot.md b/docs/first-boot.md index 5b6d603..8fd2318 100644 --- a/docs/first-boot.md +++ b/docs/first-boot.md @@ -50,6 +50,13 @@ Finally, further tweaks can be made by changing the [Chromium command line switc Adding these options will allow you to mix secure (i.e. HTTPS) origins with insecure ones (you need to specifically white-list them). Sometimes you need stuff like this to pull together all the bits and pieces of your dashboard from different origins. We're not saying you should. But you can. +## Controlling the kiosk remotely + +Sometimes you need to do basic remote adjustments, like changing the URL that's displayed. + +- If you need a lot of flexibility, [you can install VNC](https://github.com/futurice/chilipie-kiosk/issues/38#issuecomment-442031274) to get a full remote desktop +- If you just need to set the URL, you can SSH over (not enabled by default; see above), and e.g. [run something like](https://github.com/futurice/chilipie-kiosk/issues/71#issuecomment-522035239): `export DISPLAY=:0; xdotool key F11 sleep 1 key ctrl+l sleep 1 type 'https://google.com'; xdotool sleep 1 key KP_Enter; xdotool key F11`. Very crude. Very effective. + ## Username and password If you need to login to a shell, the default username and password are `pi` and `raspberry`, as is tradition for Raspberry Pi. The `pi` user also has `sudo` access. From 17aa8f6e00cbe51adad85f1a476c5d75fcfde9d8 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 3 Mar 2020 11:08:03 +0200 Subject: [PATCH 05/29] Replace some in-place sed invocations with perl, as it's more robust. --- docs/image-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index 83f870e..57abd72 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -156,7 +156,7 @@ ssh "echo -e 'd\n2\nn\np\n2\n$START\n+${SD_SIZE_REAL}M\ny\nw\n' | sudo fdisk /de working "Setting hostname" # We want to do this right before reboot, so we don't get a lot of unnecessary complaints about "sudo: unable to resolve host chilipie-kiosk" (https://askubuntu.com/a/59517) ssh "sudo hostnamectl set-hostname chilipie-kiosk" -ssh "sudo sed -i 's/raspberrypi/chilipie-kiosk/g' /etc/hosts" +ssh "sudo perl -i -p0e 's/raspberrypi/chilipie-kiosk/g' /etc/hosts" # "perl" is more cross-platform than "sed -i" # From now on, some ssh commands will exit non-0, which should be fine set +e @@ -256,7 +256,7 @@ read working "Making boot quieter (part 1)" # https://scribles.net/customizing-boot-up-screen-on-raspberry-pi/ echo "Updating: $BOOT_CONFIG_TXT" -sed -i "" "s/#disable_overscan=1/disable_overscan=1/g" "$BOOT_CONFIG_TXT" +perl -i -p0e "s/#disable_overscan=1/disable_overscan=1/g" "$BOOT_CONFIG_TXT" echo -e "\ndisable_splash=1" >> "$BOOT_CONFIG_TXT" working "Making boot quieter (part 2)" # https://scribles.net/customizing-boot-up-screen-on-raspberry-pi/ From 72f85b375d9da4bdd285baf0257093cd6a41148d Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 09:21:42 +0200 Subject: [PATCH 06/29] Properly set locale for the image. This is to prevent e.g. the myriad of warnings during setup: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_ADDRESS = "fi_FI.UTF-8", LC_NAME = "fi_FI.UTF-8", LC_MONETARY = "fi_FI.UTF-8", LC_PAPER = "fi_FI.UTF-8", LC_IDENTIFICATION = "fi_FI.UTF-8", LC_TELEPHONE = "fi_FI.UTF-8", LC_MEASUREMENT = "fi_FI.UTF-8", LC_TIME = "fi_FI.UTF-8", LC_NUMERIC = "fi_FI.UTF-8", LANG = "en_GB.UTF-8" are supported and installed on your system. perl: warning: Falling back to a fallback locale ("en_GB.UTF-8"). locale: Cannot set LC_ALL to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory --- docs/image-setup.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index 57abd72..e7596af 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -27,6 +27,8 @@ SD_SIZE_SAFE=2800 # this is in MB SD_SIZE_ZERO=3200 # this is in MB SSH_PUBKEY="$(cat ~/.ssh/id_rsa.pub)" SSH_CONNECT_TIMEOUT=30 +LOCALE="en_US.UTF-8 UTF-8" # or e.g. "fi_FI.UTF-8 UTF-8" for Finland +LANGUAGE="en_US.UTF-8" # should match above KEYBOARD="us" # or e.g. "fi" for Finnish TIMEZONE="Etc/UTC" # or e.g. "Europe/Helsinki"; see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones @@ -173,6 +175,11 @@ done working "Finishing the root partition resize" ssh "df -h . && sudo resize2fs /dev/mmcblk0p2 && df -h ." +working "Setting locale" +ssh "echo $LOCALE | sudo tee /etc/locale.gen" +ssh "sudo locale-gen" +ssh "echo -e \"LANGUAGE=$LANGUAGE\nLC_ALL=$LANGUAGE\" | sudo tee /etc/environment" + working "Enabling auto-login to CLI" # From: https://github.com/RPi-Distro/raspi-config/blob/985548d7ca00cab11eccbb734b63750761c1f08a/raspi-config#L955 SUDO_USER=pi From 09b0b4fa0e04b7368d767823b97ee13c6f6a9305 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 10:17:30 +0200 Subject: [PATCH 07/29] Update CLI-auto-login to match updated raspi-config. --- docs/image-setup.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index e7596af..cde0c2d 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -180,23 +180,19 @@ ssh "echo $LOCALE | sudo tee /etc/locale.gen" ssh "sudo locale-gen" ssh "echo -e \"LANGUAGE=$LANGUAGE\nLC_ALL=$LANGUAGE\" | sudo tee /etc/environment" +# From raspi-config: https://github.com/RPi-Distro/raspi-config/blob/c0ddae8a2e99ecf15759c7cb8f0681cb0e7ce63a/raspi-config#L1141 +# See also: https://github.com/futurice/chilipie-kiosk/issues/61#issuecomment-524622522 working "Enabling auto-login to CLI" -# From: https://github.com/RPi-Distro/raspi-config/blob/985548d7ca00cab11eccbb734b63750761c1f08a/raspi-config#L955 -SUDO_USER=pi -AUTOLOG="$(cat < Date: Tue, 10 Mar 2020 10:30:07 +0200 Subject: [PATCH 08/29] Properly silence console logins. --- docs/image-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index cde0c2d..440e13f 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -200,9 +200,9 @@ ssh "(echo '$TIMEZONE' | sudo tee /etc/timezone) && sudo dpkg-reconfigure --fron working "Setting keyboard layout" ssh "(echo -e 'XKBMODEL="pc105"\nXKBLAYOUT="$KEYBOARD"\nXKBVARIANT=""\nXKBOPTIONS=""\nBACKSPACE="guess"\n' | sudo tee /etc/default/keyboard) && sudo dpkg-reconfigure --frontend noninteractive keyboard-configuration" -working "Shortening message-of-the-day for logins" -ssh "sudo rm /etc/profile.d/sshpwd.sh" -ssh "echo | sudo tee /etc/motd" +working "Silencing console logins" # this is to avoid a brief flash of the console login before X comes up +ssh "sudo rm /etc/profile.d/sshpwd.sh /etc/profile.d/wifi-check.sh" # remove warnings about default password and WiFi country (https://raspberrypi.stackexchange.com/a/105234) +ssh "touch .hushlogin" # https://scribles.net/silent-boot-on-raspbian-stretch-in-console-mode/ working "Installing packages" ssh "sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y vim matchbox-window-manager unclutter mailutils nitrogen jq chromium-browser xserver-xorg xinit rpd-plym-splash xdotool" From dce7209800f5b6d6e81fd4d9293b448bd954e589 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 10:31:23 +0200 Subject: [PATCH 09/29] Replace high-unicode progress markers with clearer ones. --- docs/image-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index 440e13f..3f3331d 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -36,10 +36,10 @@ function echo-bold { echo -e "$(tput -Txterm-256color bold)$1$(tput -Txterm-256color sgr 0)" # https://unix.stackexchange.com/a/269085; the -T arg accounts for $ENV not being set } function working { - echo-bold "\n✨ $1" + echo-bold "\n[WORKING] $1" } function question { - echo-bold "\n🛑 $1" + echo-bold "\n[QUESTION] $1" } function ssh { /usr/bin/ssh -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout="$SSH_CONNECT_TIMEOUT" "pi@$IP" "$1" From afa230e4f9fb5eb91826ad8acf100b5dc65d7622 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 10:40:02 +0200 Subject: [PATCH 10/29] Install rng-tools to support Pi Zero. Closes #49 --- docs/image-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index 3f3331d..88e3988 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -205,7 +205,7 @@ ssh "sudo rm /etc/profile.d/sshpwd.sh /etc/profile.d/wifi-check.sh" # remove war ssh "touch .hushlogin" # https://scribles.net/silent-boot-on-raspbian-stretch-in-console-mode/ working "Installing packages" -ssh "sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y vim matchbox-window-manager unclutter mailutils nitrogen jq chromium-browser xserver-xorg xinit rpd-plym-splash xdotool" +ssh "sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y vim matchbox-window-manager unclutter mailutils nitrogen jq chromium-browser xserver-xorg xinit rpd-plym-splash xdotool rng-tools" # We install mailutils just so that you can check "mail" for cronjob output working "Setting home directory default content" From b78549e4feff80fdef904e1768437212ac7044eb Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 11:03:12 +0200 Subject: [PATCH 11/29] Move locale setup up in the process. --- docs/image-setup.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index 88e3988..34e8dec 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -155,6 +155,12 @@ read working "Resizing the root partition on the Pi" ssh "echo -e 'd\n2\nn\np\n2\n$START\n+${SD_SIZE_REAL}M\ny\nw\n' | sudo fdisk /dev/mmcblk0" +working "Setting locale" +# We want to do this as early as possible, so perl et al won't complain about misconfigured locales for the rest of the image prep +ssh "echo $LOCALE | sudo tee /etc/locale.gen" +ssh "sudo locale-gen" +ssh "echo -e \"LANGUAGE=$LANGUAGE\nLC_ALL=$LANGUAGE\" | sudo tee /etc/environment" + working "Setting hostname" # We want to do this right before reboot, so we don't get a lot of unnecessary complaints about "sudo: unable to resolve host chilipie-kiosk" (https://askubuntu.com/a/59517) ssh "sudo hostnamectl set-hostname chilipie-kiosk" @@ -175,11 +181,6 @@ done working "Finishing the root partition resize" ssh "df -h . && sudo resize2fs /dev/mmcblk0p2 && df -h ." -working "Setting locale" -ssh "echo $LOCALE | sudo tee /etc/locale.gen" -ssh "sudo locale-gen" -ssh "echo -e \"LANGUAGE=$LANGUAGE\nLC_ALL=$LANGUAGE\" | sudo tee /etc/environment" - # From raspi-config: https://github.com/RPi-Distro/raspi-config/blob/c0ddae8a2e99ecf15759c7cb8f0681cb0e7ce63a/raspi-config#L1141 # See also: https://github.com/futurice/chilipie-kiosk/issues/61#issuecomment-524622522 working "Enabling auto-login to CLI" From f98837b0d0166ee536f445cda0474111a23fd0e1 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 11:03:29 +0200 Subject: [PATCH 12/29] Fix permissions for auto-login setup. --- docs/image-setup.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index 34e8dec..be98250 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -184,13 +184,13 @@ ssh "df -h . && sudo resize2fs /dev/mmcblk0p2 && df -h ." # From raspi-config: https://github.com/RPi-Distro/raspi-config/blob/c0ddae8a2e99ecf15759c7cb8f0681cb0e7ce63a/raspi-config#L1141 # See also: https://github.com/futurice/chilipie-kiosk/issues/61#issuecomment-524622522 working "Enabling auto-login to CLI" -ssh "systemctl set-default multi-user.target" -ssh "ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty1.service" -ssh "ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty2.service" -ssh "ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty3.service" -ssh "mkdir -p /etc/systemd/system/getty@tty1.service.d" -ssh "mkdir -p /etc/systemd/system/getty@tty2.service.d" -ssh "mkdir -p /etc/systemd/system/getty@tty3.service.d" +ssh "sudo systemctl set-default multi-user.target" +ssh "sudo ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty1.service" +ssh "sudo ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty2.service" +ssh "sudo ln -fs /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@tty3.service" +ssh "sudo mkdir -p /etc/systemd/system/getty@tty1.service.d" +ssh "sudo mkdir -p /etc/systemd/system/getty@tty2.service.d" +ssh "sudo mkdir -p /etc/systemd/system/getty@tty3.service.d" ssh "echo -e '[Service]\nExecStart=\nExecStart=-/sbin/agetty --autologin pi --noclear %I \$TERM\n' | sudo tee /etc/systemd/system/getty@tty1.service.d/autologin.conf" ssh "echo -e '[Service]\nExecStart=\nExecStart=-/sbin/agetty --autologin pi --noclear %I \$TERM\n' | sudo tee /etc/systemd/system/getty@tty2.service.d/autologin.conf" ssh "echo -e '[Service]\nExecStart=\nExecStart=-/sbin/agetty --autologin pi --noclear %I \$TERM\n' | sudo tee /etc/systemd/system/getty@tty3.service.d/autologin.conf" From 2e74cab4833f5e59f9073f4c42fe71eed8f36eaa Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 12:21:29 +0200 Subject: [PATCH 13/29] Improve instructions for providing the tag being built. --- docs/image-setup.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index be98250..9cf7e1b 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -74,7 +74,11 @@ function unmountSdCard { fi } -question "Enter version (e.g. \"1.2.3\") being built (without \"v\" prefix):" +question "Enter version (e.g. \"1.2.3\") being built" +echo "Omit the \"v\" prefix, it'll be added where needed" +echo "For alpha/beta builds, use a \"-betaN\" suffic" +echo "For RC builds, DO NOT use any suffix, as then the same image can't be promoted to stable without rebuilding" +echo "Enter version:" read TAG working "Updating version file" From e65b60057fcb2ee6e26c99d500543c2264c7bdc9 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 12:21:54 +0200 Subject: [PATCH 14/29] Fully silent login on tty1. --- docs/image-setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index 9cf7e1b..bc5194f 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -208,6 +208,7 @@ ssh "(echo -e 'XKBMODEL="pc105"\nXKBLAYOUT="$KEYBOARD"\nXKBVARIANT=""\nXKBOPTION working "Silencing console logins" # this is to avoid a brief flash of the console login before X comes up ssh "sudo rm /etc/profile.d/sshpwd.sh /etc/profile.d/wifi-check.sh" # remove warnings about default password and WiFi country (https://raspberrypi.stackexchange.com/a/105234) ssh "touch .hushlogin" # https://scribles.net/silent-boot-on-raspbian-stretch-in-console-mode/ +ssh "sudo perl -i -p0e 's#--autologin pi#--skip-login --noissue --login-options \"-f pi\"#g' /etc/systemd/system/getty@tty1.service.d/autologin.conf" # "perl" is more cross-platform than "sed -i" working "Installing packages" ssh "sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y vim matchbox-window-manager unclutter mailutils nitrogen jq chromium-browser xserver-xorg xinit rpd-plym-splash xdotool rng-tools" From 79a6539fac83e6449a547657d996b9ab8f70c2b6 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 12:22:09 +0200 Subject: [PATCH 15/29] Add comment on why perl -i. --- docs/image-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index bc5194f..ea2212c 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -265,7 +265,7 @@ read working "Making boot quieter (part 1)" # https://scribles.net/customizing-boot-up-screen-on-raspberry-pi/ echo "Updating: $BOOT_CONFIG_TXT" -perl -i -p0e "s/#disable_overscan=1/disable_overscan=1/g" "$BOOT_CONFIG_TXT" +perl -i -p0e "s/#disable_overscan=1/disable_overscan=1/g" "$BOOT_CONFIG_TXT" # "perl" is more cross-platform than "sed -i" echo -e "\ndisable_splash=1" >> "$BOOT_CONFIG_TXT" working "Making boot quieter (part 2)" # https://scribles.net/customizing-boot-up-screen-on-raspberry-pi/ From 4fe960a6668339edd1a0fd983265515dabce723b Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 12:24:35 +0200 Subject: [PATCH 16/29] Separate the SSH disabling and eventual poweroff steps in image-setup. --- docs/image-setup.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index ea2212c..5b8e424 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -250,8 +250,11 @@ rm temp working "Removing SSH host keys & enable regeneration" ssh "sudo rm -f -v /etc/ssh/ssh_host_*_key* && sudo systemctl enable regenerate_ssh_host_keys" -working "Removing temporary SSH pubkey, disabling SSH & shutting down" -ssh "(echo > .ssh/authorized_keys) && sudo systemctl disable ssh && sudo shutdown -h now" +working "Removing temporary SSH pubkey & disabling SSH" +ssh "(echo > .ssh/authorized_keys) && sudo systemctl disable ssh" + +working "Powering off the Pi" +ssh "sudo poweroff" question "Eject the SD card from the Pi, and mount it back to this computer (press enter when ready)" read From a8965565964dba745da8e3cedc2948c8dc8b0d8f Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 12:26:33 +0200 Subject: [PATCH 17/29] Improve consistency on some instructions. --- docs/image-setup.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index 5b8e424..c1d08ef 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -95,7 +95,8 @@ cp ../docs/first-boot.md md-input ./node_modules/.bin/html-inline -i md-output/first-boot.html > ../home/first-boot.html rm -rf md-input md-output -question "Mount the SD card (press enter when ready)" +question "Physically mount the SD card to this machine " +echo "(press enter when ready)" read working "Figuring out SD card device" @@ -256,7 +257,8 @@ ssh "(echo > .ssh/authorized_keys) && sudo systemctl disable ssh" working "Powering off the Pi" ssh "sudo poweroff" -question "Eject the SD card from the Pi, and mount it back to this computer (press enter when ready)" +question "Eject the SD card from the Pi, and mount it back to this computer" +echo "(press enter when ready)" read # We do this again now just to be safe From 9ccabb10cf16517c726f61a8f2601c82068f5384 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 16:57:22 +0200 Subject: [PATCH 18/29] Include xinput_calibrator in installed packages, as it's referenced in the first-boot doc. --- docs/image-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index c1d08ef..4d4ba05 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -212,7 +212,7 @@ ssh "touch .hushlogin" # https://scribles.net/silent-boot-on-raspbian-stretch-in ssh "sudo perl -i -p0e 's#--autologin pi#--skip-login --noissue --login-options \"-f pi\"#g' /etc/systemd/system/getty@tty1.service.d/autologin.conf" # "perl" is more cross-platform than "sed -i" working "Installing packages" -ssh "sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y vim matchbox-window-manager unclutter mailutils nitrogen jq chromium-browser xserver-xorg xinit rpd-plym-splash xdotool rng-tools" +ssh "sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y vim matchbox-window-manager unclutter mailutils nitrogen jq chromium-browser xserver-xorg xinit rpd-plym-splash xdotool rng-tools xinput-calibrator" # We install mailutils just so that you can check "mail" for cronjob output working "Setting home directory default content" From 69b8916a7e0cd86726671b60287d1f78de47ff6f Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 16:57:43 +0200 Subject: [PATCH 19/29] Update boot graphics example to something that works (the old link had rotten away). --- docs/first-boot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/first-boot.md b/docs/first-boot.md index 8fd2318..1672967 100644 --- a/docs/first-boot.md +++ b/docs/first-boot.md @@ -82,7 +82,7 @@ Exotic screens may require a bit more fiddling. See issues [#41](https://github. The image that's displayed while the kiosk is starting can be changed by just replacing `~/background.png`. -To change the default chilipie-kiosk boot graphics to a nice doge, for example, try `wget -O background.png bit.ly/2w1P4Il`. +To change the default chilipie-kiosk boot graphics to a [nice Windoge one](https://mcdn.wallpapersafari.com/medium/93/77/8xKLeg.png), for example, try `wget -O background.png https://bit.ly/2Q4GF1t`. ## Increasing boot show delay From b5a4a991569c9e734e1c6eb639d127ea48750179 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 18:05:40 +0200 Subject: [PATCH 20/29] Update formatting in example wpa_supplicant config. --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 550b861..f550ecf 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,10 @@ Easy-to-use **Raspberry Pi** image for booting directly into **full-screen Chrom ### Automatic WiFi setup 1. After flashing remount your SD card. -2. Create a wpa_supplicant.conf in your SD cards boot folder +2. Create a `wpa_supplicant.conf` in your SD cards boot folder 3. Copy the [sample wpa_supplicant.conf](#sample-wpasupplicantconf) file into the boot folder on the SD card. 4. Replace `WiFi-SSID` and `WiFi-PASSWORD` with your WiFi configuration. -5. *Optional*: Set the country code to your country code e.g. DE. +5. Optional: Set the country code to your country code e.g. `DE`. #### Sample wpa_supplicant.conf ``` @@ -47,9 +47,9 @@ update_config=1 country=US network={ - ssid="WiFi-SSID" - psk="WiFi-PASSWORD" - key_mgmt=WPA-PSK + ssid="WiFi-SSID" + psk="WiFi-PASSWORD" + key_mgmt=WPA-PSK } ``` From e6ae2ca1cbfbee4d768a54efca3b9f02eebaf053 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 18:06:00 +0200 Subject: [PATCH 21/29] Add note about disabling dtoverlay=vc4-fkms-v3d when rotating display with the Pi 4. See #92 --- docs/first-boot.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/first-boot.md b/docs/first-boot.md index 1672967..f83621d 100644 --- a/docs/first-boot.md +++ b/docs/first-boot.md @@ -76,6 +76,8 @@ Press `Ctrl + Alt + F3` to get to a virtual terminal, and use your favorite edit Save the file, and `sudo reboot`. +Note that on the Pi 4, you'll need to disable the `dtoverlay=vc4-fkms-v3d` line in `/boot/config.txt` for this to work. But then that [may cause other issues](https://www.reddit.com/r/raspberry_pi/comments/dw1376/dtoverlayvc4fkmsv3d_causes_display_to_shift_right/). This is hopefully fixed in a future Raspbian release. + Exotic screens may require a bit more fiddling. See issues [#41](https://github.com/futurice/chilipie-kiosk/issues/41) and [#58](https://github.com/futurice/chilipie-kiosk/issues/58) for ideas. ## Replacing the boot graphics From e2692db8555c8f1516c2fa6629798834c9423447 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 18:15:41 +0200 Subject: [PATCH 22/29] Split the chromium switches on different lines. --- home/.xsession | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/home/.xsession b/home/.xsession index 73cda67..4fb810c 100755 --- a/home/.xsession +++ b/home/.xsession @@ -31,7 +31,11 @@ find .config/chromium/ -name "Last *" | xargs rm # Start and detach Chromium # http://peter.sh/experiments/chromium-command-line-switches/ # Note that under matchbox, starting in full-screen without a window size doesn't behave well when you try to exit full screen (see https://unix.stackexchange.com/q/273989) -chromium-browser --start-fullscreen --window-size=1920,1080 --disable-infobars & +chromium-browser \ + --start-fullscreen \ + --window-size=1920,1080 \ + --disable-infobars \ + & # Hide Chromium while it's starting/loading the page wid=`xdotool search --sync --onlyvisible --class chromium` From a1a035a28459b1d2a3db699206c45fc4a6be1f40 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 10 Mar 2020 18:17:11 +0200 Subject: [PATCH 23/29] Attempt getting rid of the "Can't update Chromium" dialogs. See #99 --- home/.xsession | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home/.xsession b/home/.xsession index 4fb810c..25d2b49 100755 --- a/home/.xsession +++ b/home/.xsession @@ -35,7 +35,9 @@ chromium-browser \ --start-fullscreen \ --window-size=1920,1080 \ --disable-infobars \ + --check-for-update-interval=1 --simulate-critical-update \ & +# See https://github.com/futurice/chilipie-kiosk/issues/99#issuecomment-597119842 for the need for the fishy-sounding "--check-for-update-interval=1 --simulate-critical-update" switches; TODO: remove when not needed # Hide Chromium while it's starting/loading the page wid=`xdotool search --sync --onlyvisible --class chromium` From c3ef0c9d6ec4466997c67c795f92613a547acde4 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Fri, 13 Mar 2020 10:08:35 +0200 Subject: [PATCH 24/29] Remove problematic window sizing, and open window outside of visible display to remove a white flash during startup. --- home/.xsession | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/.xsession b/home/.xsession index 25d2b49..df4cf26 100755 --- a/home/.xsession +++ b/home/.xsession @@ -33,7 +33,7 @@ find .config/chromium/ -name "Last *" | xargs rm # Note that under matchbox, starting in full-screen without a window size doesn't behave well when you try to exit full screen (see https://unix.stackexchange.com/q/273989) chromium-browser \ --start-fullscreen \ - --window-size=1920,1080 \ + --window-position=9000,9000 \ --disable-infobars \ --check-for-update-interval=1 --simulate-critical-update \ & @@ -42,7 +42,7 @@ chromium-browser \ # Hide Chromium while it's starting/loading the page wid=`xdotool search --sync --onlyvisible --class chromium` xdotool windowunmap $wid -sleep 15 # give the web page time to load +sleep 10 # give the web page time to load xdotool windowmap $wid # Finally, switch process to our window manager From a8997d59b475b6a0f315dbe3e70749f15fbcbb1e Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Fri, 13 Mar 2020 10:22:37 +0200 Subject: [PATCH 25/29] Fix brainfart of disabling SSH and then SSH'ing over to poweroff. --- docs/image-setup.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index 4d4ba05..d5dd93c 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -251,11 +251,8 @@ rm temp working "Removing SSH host keys & enable regeneration" ssh "sudo rm -f -v /etc/ssh/ssh_host_*_key* && sudo systemctl enable regenerate_ssh_host_keys" -working "Removing temporary SSH pubkey & disabling SSH" -ssh "(echo > .ssh/authorized_keys) && sudo systemctl disable ssh" - -working "Powering off the Pi" -ssh "sudo poweroff" +working "Removing temporary SSH pubkey & disabling SSH & shutting down" +ssh "(echo > .ssh/authorized_keys) && sudo systemctl disable ssh && sudo nohup poweroff" question "Eject the SD card from the Pi, and mount it back to this computer" echo "(press enter when ready)" From 0e9736f348b191b9cce0e8c5b37478ca9db589bc Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Fri, 13 Mar 2020 10:30:58 +0200 Subject: [PATCH 26/29] Make the image setup script status messages more terse. --- docs/image-setup.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index d5dd93c..2013eed 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -102,13 +102,16 @@ read working "Figuring out SD card device" figureOutSdCard -question "Based on the above, SD card determined to be \"$DISK\" (should be e.g. \"$DISK_SAMPLE\"), press enter to continue" +question "Based on the above, SD card determined to be \"$DISK\"" +echo "Should be e.g. \"$DISK_SAMPLE\"" +echo "(press enter to confirm)" read working "Safely unmounting the card" unmountSdCard -working "Writing the card full of zeros (for security and compressibility reasons)" +working "Writing the card full of zeros" +# ...for security and compressibility reasons echo "This may take a long time" echo "You may be prompted for your password by sudo" sudo dd bs="$SD_DD_BS" count="$SD_SIZE_ZERO" if=/dev/zero of="$DISK" "$SD_DD_PROGRESS" @@ -154,10 +157,12 @@ ssh "echo -e 'p\nq\n' | sudo fdisk /dev/mmcblk0 | grep /dev/mmcblk0p2 | tr -s ' START="$(cat temp)" rm temp -question "Partition start determined to be \"$START\" (should be e.g. \"98304\"), press enter to continue" +question "Partition start determined to be \"$START\"" +echo "Should be e.g. \"98304\"" +echo "(press enter to confirm)" read -working "Resizing the root partition on the Pi" +working "Resizing the root partition" ssh "echo -e 'd\n2\nn\np\n2\n$START\n+${SD_SIZE_REAL}M\ny\nw\n' | sudo fdisk /dev/mmcblk0" working "Setting locale" @@ -248,7 +253,7 @@ ssh "chromium-browser --version | cut -d ' ' -f 1-2" > temp VERSION_CHROMIUM="$(cat temp)" rm temp -working "Removing SSH host keys & enable regeneration" +working "Removing SSH host keys & enabling regeneration" ssh "sudo rm -f -v /etc/ssh/ssh_host_*_key* && sudo systemctl enable regenerate_ssh_host_keys" working "Removing temporary SSH pubkey & disabling SSH & shutting down" @@ -262,7 +267,9 @@ read working "Figuring out SD card device" figureOutSdCard -question "Based on the above, SD card determined to be \"$DISK\" (should be e.g. \"$DISK_SAMPLE\"), press enter to continue" +question "Based on the above, SD card determined to be \"$DISK\"" +echo "Should be e.g. \"$DISK_SAMPLE\"" +echo "(press enter to confirm)" read working "Making boot quieter (part 1)" # https://scribles.net/customizing-boot-up-screen-on-raspberry-pi/ From 595443566216ec133e73fbf412e50e76902eac65 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Fri, 13 Mar 2020 16:13:10 +0200 Subject: [PATCH 27/29] Update supported models section of README. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f550ecf..c1e8fb6 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ network={ ## Hardware -Works with [Raspberry Pi versions 1, 2 & 3](https://www.raspberrypi.org/products/). The 3 series is recommended, as it's the most powerful, and comes with built-in WiFi (though both [official](https://www.raspberrypi.org/products/raspberry-pi-usb-wifi-dongle/) and [off-the-shelf](https://elinux.org/RPi_USB_Wi-Fi_Adapters) USB WiFi dongles can work equally well). +Works with [all Raspberry Pi versions](https://www.raspberrypi.org/products/). Versions 3 and 4 are recommended, though, since the smaller ones can be a bit underpowered for rendering complex dashboards. The 3 and 4 also come with built-in WiFi, which is convenient (though both [official](https://www.raspberrypi.org/products/raspberry-pi-usb-wifi-dongle/) and [off-the-shelf](https://elinux.org/RPi_USB_Wi-Fi_Adapters) USB WiFi dongles can work equally well). Make sure you have a [compatible 4+ GB SD card](http://elinux.org/RPi_SD_cards). In general, any Class 10 card will work, as they're fast enough and of high enough quality. From 905b371ad27f79704daa01b236cdb06e7cba72d7 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Mon, 1 Mar 2021 12:03:16 +0200 Subject: [PATCH 28/29] Updates for v3.0.0-rc3. --- docs/image-setup.sh | 44 +++++++++++++++++++++--------------- home/.chilipie-kiosk-version | 2 +- home/first-boot.html | 23 +++++++++++++++++-- 3 files changed, 48 insertions(+), 21 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index 2013eed..bb0c67f 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -9,15 +9,10 @@ cd "$DIR" if [ "$OSTYPE" == "linux-gnu" ]; then MOUNTED_BOOT_VOLUME="/media/$(whoami)/boot" # i.e. under which name is the SD card mounted under /media in Linux (Ubuntu) - SD_DD_BS="1M" - SD_DD_PROGRESS="status=progress" -elif [ "$OSTYPE" == "darwin" ]; then +elif [[ "$OSTYPE" == darwin* ]]; then MOUNTED_BOOT_VOLUME="/Volumes/boot" # i.e. under which name is the SD card mounted under /Volumes on macOS - SD_DD_BS="1m" - SD_DD_PROGRESS="" else - echo "Error: Unsupported platform $OSTYPE, sorry" - exit 1 + echo "Error: Unsupported platform $OSTYPE, sorry" && exit 1 fi BOOT_CMDLINE_TXT="$MOUNTED_BOOT_VOLUME/cmdline.txt" @@ -52,13 +47,12 @@ function figureOutSdCard { lsblk --fs DISK="/dev/$(lsblk -l | grep "$MOUNTED_BOOT_VOLUME" | sed 's/[0-9].*//')" DISK_SAMPLE="/dev/sda" - elif [ "$OSTYPE" == "darwin" ]; then + elif [[ "$OSTYPE" == darwin* ]]; then diskutil list DISK="$(diskutil list | grep /dev/ | grep external | grep physical | cut -d ' ' -f 1 | head -n 1)" DISK_SAMPLE="/dev/disk2" else - echo "Error: Unsupported platform $OSTYPE, sorry" - exit 1 + echo "Error: Unsupported platform $OSTYPE, sorry" && exit 1 fi } function unmountSdCard { @@ -66,11 +60,10 @@ function unmountSdCard { for part in $(lsblk --list "$DISK" | grep part | sed 's/ .*//'); do udisksctl unmount -b "/dev/$part" done - elif [ "$OSTYPE" == "darwin" ]; then + elif [[ "$OSTYPE" == darwin* ]]; then diskutil unmountDisk "$DISK" else - echo "Error: Unsupported platform $OSTYPE, sorry" - exit 1 + echo "Error: Unsupported platform $OSTYPE, sorry" && exit 1 fi } @@ -114,7 +107,13 @@ working "Writing the card full of zeros" # ...for security and compressibility reasons echo "This may take a long time" echo "You may be prompted for your password by sudo" -sudo dd bs="$SD_DD_BS" count="$SD_SIZE_ZERO" if=/dev/zero of="$DISK" "$SD_DD_PROGRESS" +if [ "$OSTYPE" == "linux-gnu" ]; then + sudo dd bs=1M count="$SD_SIZE_ZERO" if=/dev/zero of="$DISK" status=progress +elif [[ "$OSTYPE" == darwin* ]]; then + sudo dd bs=1m count="$SD_SIZE_ZERO" if=/dev/zero of="$DISK" +else + echo "Error: Unsupported platform $OSTYPE, sorry" && exit 1 +fi question "Prepare baseline Raspbian:" echo "* Flash Raspbian Lite with Etcher" @@ -191,7 +190,7 @@ done working "Finishing the root partition resize" ssh "df -h . && sudo resize2fs /dev/mmcblk0p2 && df -h ." -# From raspi-config: https://github.com/RPi-Distro/raspi-config/blob/c0ddae8a2e99ecf15759c7cb8f0681cb0e7ce63a/raspi-config#L1141 +# From raspi-config: https://github.com/RPi-Distro/raspi-config/blob/d98686647ced7c0c0490dc123432834735d1c13d/raspi-config#L1313-L1321 # See also: https://github.com/futurice/chilipie-kiosk/issues/61#issuecomment-524622522 working "Enabling auto-login to CLI" ssh "sudo systemctl set-default multi-user.target" @@ -256,8 +255,11 @@ rm temp working "Removing SSH host keys & enabling regeneration" ssh "sudo rm -f -v /etc/ssh/ssh_host_*_key* && sudo systemctl enable regenerate_ssh_host_keys" -working "Removing temporary SSH pubkey & disabling SSH & shutting down" -ssh "(echo > .ssh/authorized_keys) && sudo systemctl disable ssh && sudo nohup poweroff" +working "Removing temporary SSH pubkey, disabling SSH & shutting down" +tempFile="$(ssh mktemp)" +ssh "chmod a+x $tempFile" +ssh "echo 'rm .ssh/authorized_keys && systemctl disable ssh && poweroff' > $tempFile" +ssh "sudo nohup $tempFile" question "Eject the SD card from the Pi, and mount it back to this computer" echo "(press enter when ready)" @@ -293,7 +295,13 @@ working "Dumping the image from the card" cd .. echo "This may take a long time" echo "You may be prompted for your password by sudo" -sudo dd bs="$SD_DD_BS" count="$SD_SIZE_SAFE" if="$DISK" of="chilipie-kiosk-$TAG.img" "$SD_DD_PROGRESS" +if [ "$OSTYPE" == "linux-gnu" ]; then + sudo dd bs=1M count="$SD_SIZE_ZERO" if="$DISK" of="chilipie-kiosk-$TAG.img" status=progress +elif [[ "$OSTYPE" == darwin* ]]; then + sudo dd bs=1m count="$SD_SIZE_ZERO" if="$DISK" of="chilipie-kiosk-$TAG.img" +else + echo "Error: Unsupported platform $OSTYPE, sorry" && exit 1 +fi working "Compressing image" COPYFILE_DISABLE=1 tar -zcvf chilipie-kiosk-$TAG.img.tar.gz chilipie-kiosk-$TAG.img diff --git a/home/.chilipie-kiosk-version b/home/.chilipie-kiosk-version index 9a8f5c7..a452d06 100644 --- a/home/.chilipie-kiosk-version +++ b/home/.chilipie-kiosk-version @@ -1,3 +1,3 @@ -2.1.0 +3.0.0 https://github.com/futurice/chilipie-kiosk diff --git a/home/first-boot.html b/home/first-boot.html index 0a0d9a7..731c688 100644 --- a/home/first-boot.html +++ b/home/first-boot.html @@ -923,15 +923,34 @@ github.com style (c) Vasily Polovnyov

Finally, further tweaks can be made by changing the Chromium command line switches in ~/.xsession. For example:

--unsafely-treat-insecure-origin-as-secure=http://shady.example.com,http://another.example.com --user-data-dir=/home/pi/.config/chromium

Adding these options will allow you to mix secure (i.e. HTTPS) origins with insecure ones (you need to specifically white-list them). Sometimes you need stuff like this to pull together all the bits and pieces of your dashboard from different origins. We're not saying you should. But you can.

+

Controlling the kiosk remotely

+

Sometimes you need to do basic remote adjustments, like changing the URL that's displayed.

+
    +
  • If you need a lot of flexibility, you can install VNC to get a full remote desktop
  • +
  • If you just need to set the URL, you can SSH over (not enabled by default; see above), and e.g. run something like: export DISPLAY=:0; xdotool key F11 sleep 1 key ctrl+l sleep 1 type 'https://google.com'; xdotool sleep 1 key KP_Enter; xdotool key F11. Very crude. Very effective.
  • +

Username and password

If you need to login to a shell, the default username and password are pi and raspberry, as is tradition for Raspberry Pi. The pi user also has sudo access.

Adjusting your resolution

If the display auto-detection fails and chooses a funky default resolution for you, there's a few things you can do to try and fix that.

+

Rotating your screen

+

Press Ctrl + Alt + F3 to get to a virtual terminal, and use your favorite editor to open /boot/config.txt (remember to use sudo). Add a line to the end of the file:

+
    +
  • display_rotate=0 to disable rotation
  • +
  • display_rotate=1 to rotate 90° clockwise
  • +
  • display_rotate=2 to rotate 180°
  • +
  • display_rotate=3 to rotate 90° counter-clockwise
  • +
+

Save the file, and sudo reboot.

+

Note that on the Pi 4, you'll need to disable the dtoverlay=vc4-fkms-v3d line in /boot/config.txt for this to work. But then that may cause other issues. This is hopefully fixed in a future Raspbian release.

+

Exotic screens may require a bit more fiddling. See issues #41 and #58 for ideas.

Replacing the boot graphics

The image that's displayed while the kiosk is starting can be changed by just replacing ~/background.png.

-

To change the default chilipie-kiosk boot graphics to a nice doge, for example, try wget -O background.png bit.ly/2w1P4Il.

+

To change the default chilipie-kiosk boot graphics to a nice Windoge one, for example, try wget -O background.png https://bit.ly/2Q4GF1t.

Increasing boot show delay

By default, the browser window is hidden for a few seconds after boot, to give the page time to load. You can increase (or decrease) this delay in ~/.xsession.

- +

Using a touch screen

+

If your kiosk is interactive, and you're using a touch screen as a display, you may need to calibrate it. Press Ctrl + Alt + F3 to get to a virtual terminal, and type:

+
DISPLAY=:0 xinput_calibrator
From 1d13602819987631ba4b013bcfdaa5fdb63bb912 Mon Sep 17 00:00:00 2001 From: Jarno Rantanen Date: Tue, 28 Dec 2021 21:25:00 +0200 Subject: [PATCH 29/29] Update imaging script. --- docs/image-setup.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/image-setup.sh b/docs/image-setup.sh index db175cf..f4cf23c 100755 --- a/docs/image-setup.sh +++ b/docs/image-setup.sh @@ -115,8 +115,8 @@ else echo "Error: Unsupported platform $OSTYPE, sorry" && exit 1 fi -question "Prepare baseline Raspbian:" -echo "* Flash Raspbian Lite with Etcher" +question "Prepare baseline Raspberry Pi OS Lite:" +echo "* Flash the OS with Raspberry Pi Imager" echo "* Eject the SD card" echo "* Mount the card back" echo "* Wait for your OS to mount it" @@ -252,13 +252,10 @@ ssh "chromium-browser --version | cut -d ' ' -f 1-2" > temp VERSION_CHROMIUM="$(cat temp)" rm temp -working "Removing SSH host keys & enabling regeneration" -ssh "sudo rm -f -v /etc/ssh/ssh_host_*_key* && sudo systemctl enable regenerate_ssh_host_keys" - -working "Removing temporary SSH pubkey, disabling SSH & shutting down" -tempFile="$(ssh mktemp)" +working "Disabling SSH access & restoring safe defaults & shutting down" +tempFile="$(ssh mktemp)" # need to do this via a temp file on the host, otherwise disabling SSH while using SSH ends up being problematic ssh "chmod a+x $tempFile" -ssh "echo 'rm .ssh/authorized_keys && systemctl disable ssh && poweroff' > $tempFile" +ssh "echo 'rm -f /etc/ssh/ssh_host_*_key*; systemctl enable regenerate_ssh_host_keys; rm .ssh/authorized_keys; systemctl disable ssh; poweroff' > $tempFile" ssh "sudo nohup $tempFile" question "Eject the SD card from the Pi, and mount it back to this computer"