Skip to content

Commit

Permalink
Add scripts to build a custom Pi SD card image.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptx2 committed Aug 25, 2020
1 parent 5d76ac5 commit 866acdc
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_modules

*.sw*
*~

deploy/pi-sdcard/pi-gen
11 changes: 11 additions & 0 deletions deploy/pi-sdcard/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -e

git clone https://github.com/RPi-Distro/pi-gen
cd pi-gen
git fetch
git fetch --tags
git checkout 2020-02-13-raspbian-buster
cp ../config config
cp -a ../stage-gymnasticon stage-gymnasticon
touch stage2/SKIP_IMAGES
./build-docker.sh
11 changes: 11 additions & 0 deletions deploy/pi-sdcard/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
IMG_NAME=Gymnasticon
RELEASE=buster
LOCALE_DEFAULT=en_US.UTF-8
TARGET_HOSTNAME=gymnasticon
KEYBOARD_KEYMAP=us
KEYBOARD_LAYOUT="English (US)"
TIMEZONE_DEFAULT=US/Eastern
FIRST_USER_NAME=pi
FIRST_USER_PASS=raspberry
ENABLE_SSH=0
STAGE_LIST="stage0 stage1 stage2 stage-gymnasticon"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libudev-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash -e

NODE_SHASUM256=de4440edf147d6b534b7dea61ef2e05eb8b7844dec93bdf324ce2c83cf7a7f3c
NODE_URL=https://unofficial-builds.nodejs.org/download/release/v12.18.3/node-v12.18.3-linux-armv6l.tar.gz
GYMNASTICON_USER=${FIRST_USER_NAME}
GYMNASTICON_GROUP=${FIRST_USER_NAME}

if [ ! -x "${ROOTFS_DIR}/opt/gymnasticon/node/bin/node" ] ; then
TMPD=$(mktemp -d)
trap 'rm -rf $TMPD' EXIT
cd $TMPD
curl -Lo node.tar.gz ${NODE_URL}
sha256sum -c <(echo "$NODE_SHASUM256 node.tar.gz")
install -v -m 644 "$TMPD/node.tar.gz" "${ROOTFS_DIR}/tmp/node.tar.gz"
on_chroot <<EOF
mkdir -p /opt/gymnasticon/node
cd /opt/gymnasticon/node
tar zxvf /tmp/node.tar.gz --strip 1
chown -R "${GYMNASTICON_USER}:${GYMNASTICON_GROUP}" /opt/gymnasticon
EOF
fi

on_chroot <<EOF
su ${GYMNASTICON_USER} -c 'export PATH=/opt/gymnasticon/node/bin:\$PATH; /opt/gymnasticon/node/bin/npm install -g gymnasticon'
EOF

install -v -m 644 files/gymnasticon.service "${ROOTFS_DIR}/etc/systemd/system/gymnasticon.service"

on_chroot <<EOF
systemctl enable gymnasticon
EOF

install -v -m 644 files/motd "${ROOTFS_DIR}/etc/motd"
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=Gymnasticon
After=bluetooth.target
Requires=bluetooth.target

[Service]
Type=simple
Environment=PATH=/opt/gymnasticon/node/bin
WorkingDirectory=/opt/gymnasticon
User=pi
Group=pi
ExecStart=/opt/gymnasticon/node/bin/gymnasticon
RestartSec=1
Restart=on-failure

AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
____ _ _
/ ___|_ _ _ __ ___ _ __ __ _ ___| |_(_) ___ ___ _ __
| | _| | | | '_ ` _ \| '_ \ / _` / __| __| |/ __/ _ \| '_ \
| |_| | |_| | | | | | | | | | (_| \__ \ |_| | (_| (_) | | | |
\____|\__, |_| |_| |_|_| |_|\__,_|___/\__|_|\___\___/|_| |_|
|___/
4 changes: 4 additions & 0 deletions deploy/pi-sdcard/stage-gymnasticon/EXPORT_IMAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
IMG_SUFFIX="-lite"
if [ "${USE_QEMU}" = "1" ]; then
export IMG_SUFFIX="${IMG_SUFFIX}-qemu"
fi
2 changes: 2 additions & 0 deletions deploy/pi-sdcard/stage-gymnasticon/EXPORT_NOOBS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NOOBS_NAME="Gymnasticon Lite"
NOOBS_DESCRIPTION="Raspbian Lite with Gymnasticon pre-installed."
5 changes: 5 additions & 0 deletions deploy/pi-sdcard/stage-gymnasticon/prerun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash -e

if [ ! -d "${ROOTFS_DIR}" ]; then
copy_previous
fi

0 comments on commit 866acdc

Please sign in to comment.