Update scripts & docs for rc3.

This commit is contained in:
Jarno Rantanen 2018-08-13 15:35:02 +03:00
parent 2ee19d28de
commit 13ebba0a59
5 changed files with 114 additions and 34 deletions

View File

@ -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. Check that you have [compatible hardware](#hardware).
1. Download the [latest image](https://github.com/futurice/chilipie-kiosk/releases). 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. 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. 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. 1. You should land in the [first-boot document](first-boot.md), for further instructions & ideas.

View File

@ -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`. 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 ## Increasing boot show delay

View File

@ -1,3 +1,3 @@
v2.0.0-rc2 2.0.0
https://github.com/futurice/chilipie-kiosk https://github.com/futurice/chilipie-kiosk

View File

@ -890,30 +890,39 @@ github.com style (c) Vasily Polovnyov <vast@whiteants.net>
</head> </head>
<body> <body>
<article class="markdown-body"><h1 id="welcome-to-chilipie-kiosk"><a class="header-link" href="#welcome-to-chilipie-kiosk"></a>Welcome to chilipie-kiosk</h1> <article class="markdown-body"><h1 id="welcome-to-chilipie-kiosk"><a class="header-link" href="#welcome-to-chilipie-kiosk"></a>Welcome to chilipie-kiosk</h1>
<p><strong>Looks like this might be your first boot!</strong></p> <p><strong>Looks like this is your first boot!</strong></p>
<p>This document lists some things you can do to customize your kiosk. You&#39;ll want to plug in a keyboard at this point.</p> <p>This document lists some things you can do to customize your kiosk. You&#39;ll need to plug in a keyboard for this initial setup, but after that, it&#39;s perfectly fine to leave the kiosk running without any peripherals plugged in.</p>
<h2 id="setting-the-url"><a class="header-link" href="#setting-the-url"></a>Setting the URL</h2> <h2 id="setting-the-url"><a class="header-link" href="#setting-the-url"></a>Setting the URL</h2>
<p>Press <code>F11</code> to exit the full screen mode, and <code>Ctrl + L</code> to focus the location bar. Navigate away! Once done, press <code>F11</code> again to re-enter full screen mode.</p> <p>Press <code>F11</code> to exit the full screen mode, and <code>Ctrl + L</code> to focus the location bar. Navigate away! Once done, press <code>F11</code> again to re-enter full screen mode.</p>
<p>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!</p> <p>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!</p>
<h2 id="what-to-show"><a class="header-link" href="#what-to-show"></a>What to show</h2> <h2 id="getting-to-a-terminal"><a class="header-link" href="#getting-to-a-terminal"></a>Getting to a terminal</h2>
<p>Whatever, the Internet is your oyster! If you need simple auto-refresh, or timed cycling through several URL&#39;s, <a href="https://github.com/mieky/sideshow"><code>sideshow</code></a> is a great option.</p> <p>You can get to a virtual terminal by pressing <code>Ctrl + Alt + F2</code>, and logging in with username <code>pi</code> and password <code>raspberry</code>. Use <code>Ctrl + Alt + F1</code> to switch back to Chromium.</p>
<h2 id="getting-a-terminal"><a class="header-link" href="#getting-a-terminal"></a>Getting a terminal</h2> <h2 id="system-configuration"><a class="header-link" href="#system-configuration"></a>System configuration</h2>
<p>You can get to a virtual terminal by pressing e.g. <code>Ctrl + Alt + F5</code>, and logging in with <code>pi:raspberry</code>. Use <code>Ctrl + Alt + F8</code> to switch back to the window manager.</p> <p>Use <code>sudo raspi-config</code> in the terminal to do things like:</p>
<h2 id="enabling-wifi"><a class="header-link" href="#enabling-wifi"></a>Enabling WiFi</h2> <ul class="list">
<p>Set the SSID and password of the network you&#39;re connecting to, with:</p> <li>Join a WiFi network</li>
<pre class="hljs"><code>$ sudo <span class="hljs-keyword">vim</span> ~/wlan.<span class="hljs-keyword">conf</span></code></pre><p>Reboot to make sure your Pi joins the network automatically.</p> <li>Change the system timezone</li>
<pre class="hljs"><code><span class="hljs-variable">$ </span>sudo reboot</code></pre><h2 id="enabling-ssh"><a class="header-link" href="#enabling-ssh"></a>Enabling SSH</h2> <li>Change your keyboard layout</li>
<p>The default credentials of <code>pi:raspberry</code> aren&#39;t terribly secure, so remote access is disabled by default. To enable SSH until next reboot:</p> <li>Enable SSH access (it&#39;s disabled by default for security reasons)</li>
<pre class="hljs"><code>$ sudo systemctl <span class="hljs-literal">start</span> ssh.service</code></pre><p>Or, to enable it permanently:</p> </ul>
<pre class="hljs"><code>$ sudo systemctl <span class="hljs-built_in">enable</span> ssh.service</code></pre><p>Use <code>ifconfig</code> to figure out your IP address, and <code>ssh</code> in.</p> <h2 id="automating-things"><a class="header-link" href="#automating-things"></a>Automating things</h2>
<h2 id="controlling-the-display"><a class="header-link" href="#controlling-the-display"></a>Controlling the display</h2> <p>There&#39;s a few commonly useful snippets already on the crontab, such as:</p>
<p>The scripts <code>~/display-on.sh</code> and <code>~/display-off.sh</code> control the HDMI output of the Raspberry Pi.</p> <ul class="list">
<p>There&#39;s a sample configuration in the crontab for turning the display off outside of office hours - use <code>crontab -e</code> to uncomment it.</p> <li><strong>Rebooting the Pi every night at 3 AM</strong>. If you run resource intensive pages on your dashboard, the Pi can eventually start to slow down. A nightly reboot keeps it rested and refreshed! This is enabled by default.</li>
<h2 id="adjusting-the-output-resolution"><a class="header-link" href="#adjusting-the-output-resolution"></a>Adjusting the output resolution</h2> <li><strong>Turning the display off for the night</strong>. This helps save energy when there&#39;s no-one there to look at your dashboard. Sometimes also useful for reasons of vanity, when bright displays in the middle of a dark office would look ridiculous. Do make sure your display/television comes back on, however: especially older TV&#39;s sometimes won&#39;t know to automatically turn back on when the HDMI signal comes back on. In those cases, you may have luck with <a href="https://timleland.com/raspberry-pi-turn-tv-onoff-cec/">CEC signals</a>, but also you may not. If nothing else works, you can always just <a href="https://askubuntu.com/a/7299">blank the display</a>.</li>
<p>If the display auto-detection fails and chooses a funky default resolution for you, <a href="https://github.com/futurice/chilipie-kiosk/issues/13">there&#39;s a few things you can do</a> to try and fix that.</p> <li><strong>Automatically reloading the active page every hour</strong>. If the page you&#39;re displaying doesn&#39;t automatically update itself, this is effectively the same as hitting <code>Ctrl + R</code> every hour. Very crude. Very effective.</li>
<h2 id="changing-locale-settings"><a class="header-link" href="#changing-locale-settings"></a>Changing locale settings</h2> <li><strong>Cycling between open tabs every 5 minutes</strong>. Same as above, but for <code>Ctrl + Tab</code>. Note that if you use both at the same time, you can combine them, to send the reload command <em>just before</em> sending the tab cycle command. This causes the pages to reload while they&#39;re in the background, so the user never sees it happening.</li>
<p>To change the keyboard layout:</p> </ul>
<pre class="hljs"><code>$ sudo dpkg-reconfigure console-<span class="hljs-class"><span class="hljs-keyword">data</span></span></code></pre><p>To change the timezone:</p> <p>Use <code>crontab -e</code> to check these out, enable the ones you want, or customize them to your heart&#39;s content.</p>
<pre class="hljs"><code><span class="hljs-variable">$ </span>sudo dpkg-reconfigure tzdata</code></pre> </article> <h2 id="customizing-chromium"><a class="header-link" href="#customizing-chromium"></a>Customizing Chromium</h2>
<p>Because you&#39;re running a fully-featured Chromium, you can customize it further by <a href="https://chrome.google.com/webstore/category/extensions">installing browser extensions</a>. For instance, <a href="https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo">Tampermonkey</a> can be useful for injecting custom JS or CSS to a page you&#39;re displaying.</p>
<h2 id="adjusting-your-resolution"><a class="header-link" href="#adjusting-your-resolution"></a>Adjusting your resolution</h2>
<p>If the display auto-detection fails and chooses a funky default resolution for you, <a href="https://www.opentechguides.com/how-to/article/raspberry-pi/28/raspi-display-setting.html">there&#39;s a few things you can do</a> to try and fix that.</p>
<h2 id="replacing-the-boot-graphics"><a class="header-link" href="#replacing-the-boot-graphics"></a>Replacing the boot graphics</h2>
<p>The image that&#39;s displayed while the kiosk is starting can be changed by just replacing <code>~/background.png</code>.</p>
<p>To change the default chilipie-kiosk boot graphics to a nice doge, for example, try <code>wget -O background.png https://bit.ly/2w1P4Il</code>.</p>
<h2 id="increasing-boot-show-delay"><a class="header-link" href="#increasing-boot-show-delay"></a>Increasing boot show delay</h2>
<p>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 <code>~/.xsession</code>.</p>
</article>
</body> </body>
</html> </html>

View File

@ -3,6 +3,7 @@
MOUNTED_BOOT_VOLUME="boot" # i.e. under which name is the SD card mounted under /Volumes on macOS 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_REAL=2500 # this is in MB
SD_SIZE_SAFE=2800 # 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)" PUBKEY="$(cat ~/.ssh/id_rsa.pub)"
KEYBOARD="fi" KEYBOARD="fi"
TIMEZONE="Europe/Helsinki" 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" /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 read TAG
working "Updating version file" 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 ./node_modules/.bin/html-inline -i md-output/first-boot.html > home/first-boot.html
rm -rf md-input md-output 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)" question "Flash Raspbian Lite (2018-06-27-raspbian-stretch-lite.zip) with Etcher, then re-mount the card (press enter when ready)"
read read
@ -53,21 +72,22 @@ working "Enabling SSH for first boot"
# https://www.raspberrypi.org/documentation/remote-access/ssh/ # https://www.raspberrypi.org/documentation/remote-access/ssh/
touch "/Volumes/$MOUNTED_BOOT_VOLUME/ssh" touch "/Volumes/$MOUNTED_BOOT_VOLUME/ssh"
question "Safely unmount the card, boot the Pi from it, run \"sudo raspi-config\", and:" working "Safely unmounting the card"
echo "* Under \"Boot Options\", select \"Console Autologin\"" diskutil unmountDisk "$DISK"
echo "(press enter when ready)"
read
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 read IP
SSH="ssh -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null pi@$IP"
working "Installing temporary SSH pubkey" working "Installing temporary SSH pubkey"
echo -e "Password hint: \"raspberry\"" echo -e "Password hint: \"raspberry\""
ssh "mkdir .ssh && echo '$PUBKEY' > .ssh/authorized_keys" ssh "mkdir .ssh && echo '$PUBKEY' > .ssh/authorized_keys"
working "Figuring out partition start" 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 ssh "echo -e 'p\nq\n' | sudo fdisk /dev/mmcblk0 | grep /dev/mmcblk0p2 | tr -s ' ' | cut -d ' ' -f 2" > temp
START="$(cat temp)" START="$(cat temp)"
rm 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" 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) # 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 hostnamectl set-hostname chilipie-kiosk"
ssh "sudo sed -i 's/raspberrypi/chilipie-kiosk/g' /etc/hosts"
working "Rebooting the Pi" working "Rebooting the Pi"
ssh "sudo reboot" ssh "sudo reboot"
@ -91,6 +112,13 @@ read
working "Finishing the root partition resize" working "Finishing the root partition resize"
ssh "df -h . && sudo resize2fs /dev/mmcblk0p2 && df -h ." 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" working "Setting timezone"
ssh "(echo '$TIMEZONE' | sudo tee /etc/timezone) && sudo dpkg-reconfigure --frontend noninteractive tzdata" 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 # We install mailutils just so that you can check "mail" for cronjob output
working "Setting home directory default content" working "Setting home directory default content"
ssh "rm -rf /home/pi/*" ssh "rm -rfv /home/pi/*"
scp $(find home -type file) scp $(find home -type file)
working "Setting splash screen background" working "Setting splash screen background"
@ -125,5 +153,47 @@ echo "* Navigate to \"file:///home/pi/first-boot.html\""
echo "(press enter when ready)" echo "(press enter when ready)"
read 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" working "Removing temporary SSH pubkey, disabling SSH & shutting down"
ssh "(echo > .ssh/authorized_keys) && sudo systemctl disable ssh && sudo shutdown -h now" 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\`"