Skip to content

Commit

Permalink
Merge pull request #4 from learningequality/update_to_bookworm
Browse files Browse the repository at this point in the history
Update to bookworm
  • Loading branch information
rtibbles authored Nov 14, 2024
2 parents 7e15287 + 2e66bdd commit 63a60ea
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 127 deletions.
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.PHONY: get-deb clean-deb clean-images clean-tools clean install-dependencies

SOURCE_FILE = images/source.xz
SOURCE_URL = https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-10-28/2024-10-22-raspios-bookworm-arm64-lite.img.xz

clean: clean-deb clean-images clean-tools
@echo "Deleted all build targets"

Expand All @@ -22,17 +25,22 @@ get-deb: clean-deb


images/source.img:
wget -O images/source.zip https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2022-01-28/2022-01-28-raspios-bullseye-armhf-lite.zip
unzip images/source.zip -d images/
rm images/source.zip
mv images/2022-01-28-raspios-bullseye-armhf-lite.img images/source.img
@echo "Checking if $(SOURCE_FILE) exists..."
@if [ ! -f $(SOURCE_FILE) ]; then \
echo "$(SOURCE_FILE) not found. Downloading..."; \
wget -O $(SOURCE_FILE) $(SOURCE_URL); \
else \
echo "$(SOURCE_FILE) already exists. Skipping download."; \
fi
unxz -c $(SOURCE_FILE) > images/source.img
rm $(SOURCE_FILE)

pimod:
git clone --depth=1 https://github.com/Nature40/pimod.git -b v0.6.0
git clone --depth=1 https://github.com/Nature40/pimod.git -b v0.6.1

install-dependencies:
sudo apt-get update -y
sudo apt-get install -y binfmt-support fdisk file kpartx qemu qemu-user-static unzip p7zip-full wget xz-utils units
sudo apt-get install -y binfmt-support fdisk file kpartx qemu-utils qemu-user-static unzip p7zip-full wget xz-utils units
$(MAKE) pimod

images/base.img:
Expand Down
35 changes: 18 additions & 17 deletions base.Pifile
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@ EOF

echo "Done."

INSTALL 644 files/learningequality-ubuntu-kolibri-bionic.list /etc/apt/sources.list.d/
INSTALL 644 files/learningequality-ubuntu-kolibri-noble.list /etc/apt/sources.list.d/

# Copy the GPG key file into the Docker image
INSTALL 644 files/learningequality.gpg.key /tmp/learningequality.gpg.key

# Convert the GPG key to binary format
RUN bash -c 'gpg --dearmor < /tmp/learningequality.gpg.key > /tmp/learningequality.gpg'

# Install the binary GPG key to the trusted directory
RUN install -m 644 /tmp/learningequality.gpg /etc/apt/trusted.gpg.d/

# Clean up temporary files
RUN rm -f /tmp/learningequality.gpg /tmp/learningequality.gpg.key

RUN apt-key add - <<EOF
$(cat files/learningequality.gpg.key)
EOF

RUN mkdir -p "/home/${user}/.kolibri"
RUN mkdir -p /KOLIBRI_DATA/content
Expand All @@ -48,18 +57,16 @@ RUN debconf-set-selections <<EOF
$(cat files/debconf)
EOF

INSTALL files/wlan0 /etc/network/interfaces.d/wlan0
RUN systemctl restart networking

INSTALL files/dnsmasq_hotspot.conf /etc/dnsmasq.d/hotspot.conf
INSTALL files/hostapd.conf /etc/hostapd/hostapd.conf
INSTALL files/hostapd_5ghz.conf /etc/hostapd/hostapd_5ghz.conf

INSTALL 644 files/99-usb.rules /etc/udev/rules.d/99-usb.rules
INSTALL 755 files/usb-mount.sh /usr/local/bin/usb-mount.sh
INSTALL files/[email protected] /etc/systemd/system/[email protected]

RUN tee /etc/dhcpcd.conf <<EOF
interface wlan0
static ip_address=10.10.10.10/24
nohook resolv.conf, wpa_supplicant
EOF
INSTALL 755 files/[email protected] /etc/systemd/system/[email protected]

RUN tee /etc/default/hostapd <<EOF
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Expand All @@ -69,14 +76,8 @@ RUN tee /etc/default/dnsmasq <<EOF
DNSMASQ_EXCEPT=lo
EOF

RUN tee /etc/udev/rules.d/99-local.rules <<EOF
KERNEL=="sd[a-z]*[0-9]", SUBSYSTEMS=="usb", ACTION=="add", RUN+="/bin/systemctl start usb-mount@%k.service"
KERNEL=="sd[a-z]*[0-9]", SUBSYSTEMS=="usb", ACTION=="remove", RUN+="/bin/systemctl stop usb-mount@%k.service"
EOF

RUN rm /etc/nginx/sites-enabled/default

RUN systemctl enable dhcpcd
RUN systemctl enable hostapd
RUN systemctl enable dnsmasq
RUN systemctl enable nginx
Expand Down
2 changes: 2 additions & 0 deletions files/99-usb.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd[a-z][0-9]", ENV{ID_FS_TYPE}!="", ENV{SYSTEMD_WANTS}="usb-mount@%k.service"

1 change: 0 additions & 1 deletion files/learningequality-ubuntu-kolibri-bionic.list

This file was deleted.

2 changes: 2 additions & 0 deletions files/learningequality-ubuntu-kolibri-noble.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deb http://ppa.launchpad.net/learningequality/kolibri/ubuntu noble main

125 changes: 26 additions & 99 deletions files/usb-mount.sh
Original file line number Diff line number Diff line change
@@ -1,107 +1,34 @@
#!/usr/bin/env bash
# If you are executing this script in cron with a restricted environment,
# modify the shebang to specify appropriate path; /bin/bash in most distros.
# And, also if you aren't comfortable using(abuse?) env command.
#!/bin/bash

# This script is based on https://serverfault.com/a/767079 posted
# by Mike Blackwell, modified to our needs. Credits to the author.
DEVICE="/dev/$1"

# This script is called from systemd unit file to mount or unmount
# a USB drive.
MOUNT_OPTS=""
FS_UID_GID="vfat exfat ntfs fuseblk"

PATH="$PATH:/usr/bin:/usr/local/bin:/usr/sbin:/usr/local/sbin:/bin:/sbin"
log="logger -t usb-mount.sh -s "

usage()
{
${log} "Usage: $0 {add|remove} device_name (e.g. sdb1)"
# Get filesystem type
FSTYPE=$(blkid -o value -s TYPE "$DEVICE")
if [ -z "$FSTYPE" ]; then
logger "usb-mount: No filesystem type found for $DEVICE"
exit 1
}

if [[ $# -ne 2 ]]; then
usage
fi

ACTION=$1
DEVBASE=$2
DEVICE="/dev/${DEVBASE}"

# See if this drive is already mounted, and if so where
MOUNT_POINT=$(mount | grep ${DEVICE} | awk '{ print $3 }')

DEV_LABEL=""

do_mount()
{
if [[ -n ${MOUNT_POINT} ]]; then
${log} "Warning: ${DEVICE} is already mounted at ${MOUNT_POINT}"
exit 1
fi

# Get info for this drive: $ID_FS_LABEL and $ID_FS_TYPE
eval $(blkid -o udev ${DEVICE} | grep -i -e "ID_FS_LABEL" -e "ID_FS_TYPE")

# Figure out a mount point to use
LABEL=${ID_FS_LABEL}
if grep -q " /media/${LABEL} " /etc/mtab; then
# Already in use, make a unique one
LABEL+="-${DEVBASE}"
fi
DEV_LABEL="${LABEL}"

# Use the device name in case the drive doesn't have label
if [ -z ${DEV_LABEL} ]; then
DEV_LABEL="${DEVBASE}"
fi

MOUNT_POINT="/media/${DEV_LABEL}"

${log} "Mount point: ${MOUNT_POINT}"

mkdir -p ${MOUNT_POINT}

# Global mount options
OPTS="rw,relatime"

# File system type specific mount options
if [[ ${ID_FS_TYPE} == "vfat" ]]; then
OPTS+=",users,gid=100,umask=000,shortname=mixed,utf8=1,flush"
fi

if ! mount -o ${OPTS} ${DEVICE} ${MOUNT_POINT}; then
${log} "Error mounting ${DEVICE} (status = $?)"
rmdir "${MOUNT_POINT}"
exit 1
else
# Track the mounted drives
echo "${MOUNT_POINT}:${DEVBASE}" | cat >> "/var/log/usb-mount.track"
fi

${log} "Mounted ${DEVICE} at ${MOUNT_POINT}"
}

do_unmount()
{
if [[ -z ${MOUNT_POINT} ]]; then
${log} "Warning: ${DEVICE} is not mounted"
else
umount -l ${DEVICE}
${log} "Unmounted ${DEVICE} from ${MOUNT_POINT}"
/bin/rmdir "${MOUNT_POINT}"
sed -i.bak "\@${MOUNT_POINT}@d" /var/log/usb-mount.track
fi

# Get label or use device name
LABEL=$(blkid -o value -s LABEL "$DEVICE")
if [ -z "$LABEL" ]; then
LABEL=$(basename "$DEVICE")
fi

}
MOUNT_POINT="/media/usb/$LABEL"
if echo "$FS_UID_GID" | grep -qw "$FSTYPE"; then
MOUNT_OPTS="-o uid=1000,gid=1000"
fi

case "${ACTION}" in
add)
do_mount
;;
remove)
do_unmount
;;
*)
usage
;;
esac
mkdir -p "$MOUNT_POINT"
mount $MOUNT_OPTS "$DEVICE" "$MOUNT_POINT"
if [ $? -eq 0 ]; then
#chown -R 1000:1000 "$MOUNT_POINT"
logger "usb-mount: Mounted $DEVICE at $MOUNT_POINT"
else
logger "usb-mount: Failed to mount $DEVICE"
rmdir "$MOUNT_POINT"
fi
11 changes: 7 additions & 4 deletions files/[email protected]
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[Unit]
Description=Mount USB Drive on %i
Description=Mount USB Device
After=dev-%i.device

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/local/bin/usb-mount.sh add %i
ExecStop=/usr/local/bin/usb-mount.sh remove %i
ExecStart=/usr/local/bin/usb-mount.sh %I

[Install]
WantedBy=multi-user.target
4 changes: 4 additions & 0 deletions files/wlan0
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
allow-hotplug wlan0
iface wlan0 inet static
address 10.10.10.10
netmask 255.255.255.0

0 comments on commit 63a60ea

Please sign in to comment.