diff --git a/README.md b/README.md index 2f43cdc..682ce1e 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Easy-to-use **Raspberry Pi** image for booting directly into **full-screen Chrom 1. Check that you have [compatible hardware](#hardware). 1. Download the [latest image](https://github.com/futurice/chilipie-kiosk/releases). +1. Decompress it. 1. Flash the image onto your SD card. We recommend [Etcher](https://etcher.io/) for this: it's delightfully easy to use, cross platform, and will verify the result automatically. If you know what you're doing, you can of course also just `sudo dd bs=1m if=chilipie-kiosk-vX.Y.Z.img of=/dev/rdisk2`. 1. Insert the SD card to your Pi and power it up. 1. You should land in the [first-boot document](first-boot.md), for further instructions & ideas. diff --git a/first-boot.md b/first-boot.md index 08bca94..82a2760 100644 --- a/first-boot.md +++ b/first-boot.md @@ -46,7 +46,7 @@ If the display auto-detection fails and chooses a funky default resolution for y 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 https://bit.ly/2w1P4Il`. +To change the default chilipie-kiosk boot graphics to a nice doge, for example, try `wget -O background.png bit.ly/2w1P4Il`. ## Increasing boot show delay diff --git a/home/.chilipie-kiosk-version b/home/.chilipie-kiosk-version index 7660b0c..fe82a37 100644 --- a/home/.chilipie-kiosk-version +++ b/home/.chilipie-kiosk-version @@ -1,3 +1,3 @@ -v2.0.0-rc2 +2.0.0 https://github.com/futurice/chilipie-kiosk diff --git a/home/first-boot.html b/home/first-boot.html index 0a7a254..551c1e1 100644 --- a/home/first-boot.html +++ b/home/first-boot.html @@ -890,30 +890,39 @@ github.com style (c) Vasily Polovnyov

Welcome to chilipie-kiosk

-

Looks like this might be your first boot!

-

This document lists some things you can do to customize your kiosk. You'll want to plug in a keyboard at this point.

+

Looks like this is your first boot!

+

This document lists some things you can do to customize your kiosk. You'll need to plug in a keyboard for this initial setup, but after that, it's perfectly fine to leave the kiosk running without any peripherals plugged in.

Setting the URL

Press F11 to exit the full screen mode, and Ctrl + L to focus the location bar. Navigate away! Once done, press F11 again to re-enter full screen mode.

-

Chromium is configured to remember the URL where you left off (and all logins etc), so this might be all the configuration you need to do!

-

What to show

-

Whatever, the Internet is your oyster! If you need simple auto-refresh, or timed cycling through several URL's, sideshow is a great option.

-

Getting a terminal

-

You can get to a virtual terminal by pressing e.g. Ctrl + Alt + F5, and logging in with pi:raspberry. Use Ctrl + Alt + F8 to switch back to the window manager.

-

Enabling WiFi

-

Set the SSID and password of the network you're connecting to, with:

-
$ sudo vim ~/wlan.conf

Reboot to make sure your Pi joins the network automatically.

-
$ sudo reboot

Enabling SSH

-

The default credentials of pi:raspberry aren't terribly secure, so remote access is disabled by default. To enable SSH until next reboot:

-
$ sudo systemctl start ssh.service

Or, to enable it permanently:

-
$ sudo systemctl enable ssh.service

Use ifconfig to figure out your IP address, and ssh in.

-

Controlling the display

-

The scripts ~/display-on.sh and ~/display-off.sh control the HDMI output of the Raspberry Pi.

-

There's a sample configuration in the crontab for turning the display off outside of office hours - use crontab -e to uncomment it.

-

Adjusting the output 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.

-

Changing locale settings

-

To change the keyboard layout:

-
$ sudo dpkg-reconfigure console-data

To change the timezone:

-
$ sudo dpkg-reconfigure tzdata
+

Chromium is configured to remember the URL where you left off (and all logins, etc), so this might be all the configuration you need to do!

+

Getting to a terminal

+

You can get to a virtual terminal by pressing Ctrl + Alt + F2, and logging in with username pi and password raspberry. Use Ctrl + Alt + F1 to switch back to Chromium.

+

System configuration

+

Use sudo raspi-config in the terminal to do things like:

+ +

Automating things

+

There's a few commonly useful snippets already on the crontab, such as:

+ +

Use crontab -e to check these out, enable the ones you want, or customize them to your heart's content.

+

Customizing Chromium

+

Because you're running a fully-featured Chromium, you can customize it further by installing browser extensions. For instance, Tampermonkey can be useful for injecting custom JS or CSS to a page you're displaying.

+

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.

+

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 https://bit.ly/2w1P4Il.

+

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.

+ diff --git a/image-setup.sh b/image-setup.sh index c64d26c..0aa2216 100755 --- a/image-setup.sh +++ b/image-setup.sh @@ -3,6 +3,7 @@ MOUNTED_BOOT_VOLUME="boot" # i.e. under which name is the SD card mounted under /Volumes on macOS 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)" KEYBOARD="fi" TIMEZONE="Europe/Helsinki" @@ -20,7 +21,7 @@ function scp { /usr/bin/scp -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$@" "pi@$IP:/home/pi" } -question "Enter version being built (e.g. \"1.2.3\")" +question "Enter version (e.g. \"1.2.3\") being built:" read TAG working "Updating version file" @@ -37,6 +38,24 @@ cp 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)" +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)" + +question "Based on the above, SD card determined to be \"$DISK\" (should be e.g. \"/dev/disk2\"), press enter to continue" +read + +working "Safely unmounting the card" +diskutil unmountDisk "$DISK" + +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" + question "Flash Raspbian Lite (2018-06-27-raspbian-stretch-lite.zip) with Etcher, then re-mount the card (press enter when ready)" read @@ -53,21 +72,22 @@ working "Enabling SSH for first boot" # https://www.raspberrypi.org/documentation/remote-access/ssh/ touch "/Volumes/$MOUNTED_BOOT_VOLUME/ssh" -question "Safely unmount the card, boot the Pi from it, run \"sudo raspi-config\", and:" -echo "* Under \"Boot Options\", select \"Console Autologin\"" -echo "(press enter when ready)" -read +working "Safely unmounting the card" +diskutil unmountDisk "$DISK" -question "Enter the IP address of the Pi (use \"ifconfig\" if in doubt)" +question "Do initial Pi setup:" +echo "* Eject the card" +echo "* Boot the Pi from it" +echo "* Log in with \"pi:raspberry\"" +echo "* Use \"ifconfig\" to check the IP address of the Pi" +echo "Enter the IP address:" read IP -SSH="ssh -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null pi@$IP" working "Installing temporary SSH pubkey" echo -e "Password hint: \"raspberry\"" ssh "mkdir .ssh && echo '$PUBKEY' > .ssh/authorized_keys" working "Figuring out partition start" -enter='\\n' ssh "echo -e 'p\nq\n' | sudo fdisk /dev/mmcblk0 | grep /dev/mmcblk0p2 | tr -s ' ' | cut -d ' ' -f 2" > temp START="$(cat temp)" rm temp @@ -81,6 +101,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" working "Rebooting the Pi" ssh "sudo reboot" @@ -91,6 +112,13 @@ read working "Finishing the root partition resize" 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 +ssh "sudo systemctl set-default multi-user.target" +ssh "sudo sed /etc/systemd/system/autologin@.service -i -e \"s#^ExecStart=-/sbin/agetty --autologin [^[:space:]]*#ExecStart=-/sbin/agetty --autologin $SUDO_USER#\"" +ssh "sudo ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service" + working "Setting timezone" ssh "(echo '$TIMEZONE' | sudo tee /etc/timezone) && sudo dpkg-reconfigure --frontend noninteractive tzdata" @@ -106,7 +134,7 @@ ssh "sudo apt-get update && sudo apt-get install -y vim matchbox-window-manager # We install mailutils just so that you can check "mail" for cronjob output working "Setting home directory default content" -ssh "rm -rf /home/pi/*" +ssh "rm -rfv /home/pi/*" scp $(find home -type file) working "Setting splash screen background" @@ -125,5 +153,47 @@ echo "* Navigate to \"file:///home/pi/first-boot.html\"" echo "(press enter when ready)" read +working "Figuring out software versions" +ssh "hostnamectl | grep 'Operating System:' | tr -s ' ' | cut -d ' ' -f 4-" > temp +VERSION_LINUX="$(cat temp)" +ssh "hostnamectl | grep 'Kernel:' | tr -s ' ' | cut -d ' ' -f 3-4" > temp +VERSION_KERNEL="$(cat temp)" +ssh "chromium-browser --version | cut -d ' ' -f 1-2" > temp +VERSION_CHROMIUM="$(cat temp)" +rm temp + working "Removing temporary SSH pubkey, disabling SSH & shutting down" ssh "(echo > .ssh/authorized_keys) && sudo systemctl disable ssh && sudo shutdown -h now" + +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)" + +question "Based on the above, SD card determined to be \"$DISK\" (should be e.g. \"/dev/disk2\"), press enter to continue" +read + +working "Safely unmounting the card" +diskutil unmountDisk "$DISK" + +working "Dumping the image from the card" +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" + +working "Compressing image" +COPYFILE_DISABLE=1 tar -zcvf chilipie-kiosk-$TAG.img.tar.gz chilipie-kiosk-$TAG.img + +working "Listing image sizes" +du -hs chilipie-kiosk-$TAG.img* + +working "Calculating image hashes" +openssl sha1 chilipie-kiosk-$TAG.img* + +working "Software versions are:" +echo "* Linux: \`$VERSION_LINUX\`" +echo "* Kernel: \`$VERSION_KERNEL\`" +echo "* Chromium: \`$VERSION_CHROMIUM\`"