mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-25 18:40:06 -04:00
Creating script in pi-gen directory which creates the WROLPi Raspberry Pi OS images.
This commit is contained in:
parent
b775bd0b32
commit
01177a6f1e
15 changed files with 91 additions and 56 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -126,6 +126,9 @@ docker-compose.override.yml
|
|||
|
||||
# test directory is used as media directory, we don't want to commit what a user downloads.
|
||||
test
|
||||
|
||||
# Directories used to build images
|
||||
/debian-live-config/config/includes.chroot/opt/wrolpi-blobs/gis-map.dump.gz
|
||||
/debian-live-config/build.log
|
||||
/debian-live-config/*.iso
|
||||
/pi-gen/*xz
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
This directory exists to facilitate the creation of WROLPi Debian images.
|
||||
|
||||
See https://live-team.pages.debian.net/live-manual/html/live-manual/index.en.html
|
||||
|
||||
## Generate Debian 12 ISO
|
||||
|
||||
1. Convert a map PBF file to your initial map DB dump:
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ lb config \
|
|||
|
||||
rsync -a "${SCRIPT_DIR}/config" "${BUILD_DIR}/"
|
||||
|
||||
lb build 2>&1 | tee "${SCRIPT_DIR}/build.log"
|
||||
time nice -n 18 lb build 2>&1 | tee "${SCRIPT_DIR}/build.log"
|
||||
|
||||
cp "${BUILD_DIR}"/*iso "${SCRIPT_DIR}/" || (echo "Build failed. No ISOs were found!" && exit 1)
|
||||
chmod 644 "${SCRIPT_DIR}"/*iso
|
||||
|
|
|
|||
|
|
@ -52,11 +52,6 @@ cp /opt/wrolpi/etc/raspberrypios/wrolpi-kiwix.service /etc/systemd/system/
|
|||
cp /opt/wrolpi/etc/raspberrypios/wrolpi.target /etc/systemd/system/
|
||||
cp /opt/wrolpi/etc/raspberrypios/renderd.conf /etc/renderd.conf
|
||||
|
||||
systemctl enable wrolpi-api.service
|
||||
systemctl enable wrolpi-app.service
|
||||
systemctl enable wrolpi-kiwix.service
|
||||
systemctl enable renderd
|
||||
|
||||
# NetworkManager for the hotspot.
|
||||
systemctl enable NetworkManager
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ python3-dev
|
|||
python3-doc
|
||||
python3-full
|
||||
python3-mapnik
|
||||
python3-minimal
|
||||
python3-pip
|
||||
python3-venv
|
||||
renderd
|
||||
|
|
|
|||
|
|
@ -35,9 +35,13 @@
|
|||
<p>Run the provided help script which may narrow down the scope of the problem.</p>
|
||||
<p><b>bash /opt/wrolpi/help.sh</b></p>
|
||||
|
||||
<h2>Repair script</h2>
|
||||
<p>Run the provided repair script which will attempt to automatically repair the WROLPi systems.</p>
|
||||
<p><b>bash /opt/wrolpi/repair.sh</b></p>
|
||||
|
||||
<hr/>
|
||||
|
||||
<h2>Can't start the services?</h2>
|
||||
<h2>Still not working?</h2>
|
||||
<p>You can view the media directory by <a id="media_link" href="/media">navigating to /media</a></p>
|
||||
|
||||
<p>The API may be available <a id="api_link" href="#">by navigating to port 8081</a></p>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,13 @@
|
|||
# Pi-Gen
|
||||
|
||||
This directory exists to facilitate the creation of WROLPI Raspberry Pi OS images.
|
||||
|
||||
See https://github.com/RPI-Distro/pi-gen
|
||||
|
||||
## Generate 64bit Raspberry Pi WROLPi image
|
||||
|
||||
1. Checkout pi-gen (64 bit):
|
||||
* `git clone --branch arm64 https://github.com/RPI-Distro/pi-gen.git`
|
||||
2. Copy pi-gen config (modify for your directories):
|
||||
* `cp /home/user/wrolpi/pi-gen/config.txt /home/user/pi-gen/config.txt`
|
||||
3. Copy stage scripts to pi-gen:
|
||||
* `cp -r /home/user/wrolpi/pi-gen/stage2/04-wrolpi /home/user/pi-gen/stage2/`
|
||||
4. Change to the pi-gen directory:
|
||||
* `cd /home/user/pi-gen`
|
||||
5. Create directory for files:
|
||||
* `mkdir stage2/04-wrolpi/files`
|
||||
6. Convert a map PBF file to your initial map DB dump:
|
||||
* `docker run --rm -v /home/user/district-of-columbia-230111.osm.pbf:/data/region.osm.pbf lrnselfreliance/osm-map-dumper | gzip > /home/user/pi-gen/stage2/04-wrolpi/files/district-of-columbia-230111.dump.gz`
|
||||
7. Run the build (log to build.log):
|
||||
* `sudo /bin/bash ./build.sh -c config.txt 2>&1 | tee build.log`
|
||||
|
||||
Your final image should be in `pi-gen/work/WROLPi/export-image/`
|
||||
1. Convert a map PBF file to your initial map DB dump:
|
||||
* `docker run --rm -v /home/user/district-of-columbia-230111.osm.pbf:/data/region.osm.pbf lrnselfreliance/osm-map-dumper | gzip > pi-gen/stage2/04-wrolpi/files/gis-map.dump.gz`
|
||||
2. Run the build.
|
||||
* `sudo ./build.sh`
|
||||
3. The images are now in the `pi-gen` directory.
|
||||
|
|
|
|||
50
pi-gen/build.sh
Executable file
50
pi-gen/build.sh
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
#!/bin/bash
|
||||
# https://github.com/RPI-Distro/pi-gen
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
BUILD_DIR=/tmp/wrolpi-build
|
||||
|
||||
VERSION=$(cat "${SCRIPT_DIR}/../wrolpi/version.txt")
|
||||
|
||||
# Re-execute this script if it wasn't called with sudo.
|
||||
if [ $EUID != 0 ]; then
|
||||
sudo "$0" "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if [ ! -f "${SCRIPT_DIR}/stage2/04-wrolpi/files/gis-map.dump.gz" ]; then
|
||||
echo "stage2/04-wrolpi/files/gis-map.dump.gz does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
# Clear out old builds.
|
||||
[ -d "${BUILD_DIR}" ] && rm -rf "${BUILD_DIR}"
|
||||
mkdir "${BUILD_DIR}"
|
||||
|
||||
# We need the arm64 branch for modern RPi.
|
||||
git clone --branch arm64 https://github.com/RPI-Distro/pi-gen.git "${BUILD_DIR}"
|
||||
|
||||
# Copy the configuration and build files into the pi-gen directory.
|
||||
cp "${SCRIPT_DIR}/config.txt" "${BUILD_DIR}/config.txt"
|
||||
rsync -a "${SCRIPT_DIR}"/stage2/* "${BUILD_DIR}/stage2/"
|
||||
|
||||
# We only need to build the Lite and Desktop images.
|
||||
rm "${BUILD_DIR}"/stage*/EXPORT*
|
||||
echo 'IMG_SUFFIX="-lite"' > "${BUILD_DIR}/stage2/EXPORT_IMAGE"
|
||||
echo 'IMG_SUFFIX="-desktop"' > "${BUILD_DIR}/stage5/EXPORT_IMAGE"
|
||||
|
||||
# Build the images.
|
||||
(cd "${BUILD_DIR}" && time nice -n 18 "${BUILD_DIR}/build.sh" -c "${BUILD_DIR}/config.txt" | \
|
||||
tee "${SCRIPT_DIR}"/build.log)
|
||||
|
||||
grep "02-run.sh completed" "${SCRIPT_DIR}/build.log" >/dev/null 2>&1 || (echo "script 2 failed!" && exit 1)
|
||||
grep "03-run-chroot.sh completed" "${SCRIPT_DIR}/build.log" >/dev/null 2>&1 || (echo "script 3 failed!" && exit 1)
|
||||
grep "04-run-chroot.sh completed" "${SCRIPT_DIR}/build.log" >/dev/null 2>&1 || (echo "script 4 failed!" && exit 1)
|
||||
|
||||
# Move the built images out of the build directory.
|
||||
mv "${SCRIPT_DIR}/deploy/*xz" "${SCRIPT_DIR}/"
|
||||
chmod 644 "${SCRIPT_DIR}"/*xz
|
||||
chown 1000:1000 "${SCRIPT_DIR}"/*xz
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
IMG_NAME=WROLPi
|
||||
BASE_QCOW2_SIZE=12G
|
||||
RELEASE=bullseye
|
||||
RELEASE=bookworm
|
||||
LOCALE_DEFAULT=en_US.UTF-8
|
||||
TARGET_HOSTNAME=wrolpi
|
||||
KEYBOARD_KEYMAP=en_US
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
# Install Node 18 repo.
|
||||
npm --version || curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
|
||||
|
|
@ -52,18 +52,20 @@ libtool
|
|||
libxml2-dev
|
||||
lua5.1
|
||||
mapnik-utils
|
||||
netcat
|
||||
netcat-openbsd
|
||||
network-manager
|
||||
nginx-doc
|
||||
nginx-full
|
||||
nodejs
|
||||
npm
|
||||
osm2pgsql
|
||||
osmium-tool
|
||||
pkg-config
|
||||
postgis
|
||||
postgresql-13
|
||||
postgresql-13-postgis-3
|
||||
postgresql-13-postgis-3-scripts
|
||||
postgresql-15
|
||||
postgresql-15-postgis-3
|
||||
postgresql-15-postgis-3-scripts
|
||||
postgresql-doc
|
||||
protobuf-c-compiler
|
||||
pv
|
||||
python3-dev
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/bash -e
|
||||
mkdir -p "${ROOTFS_DIR}/opt/wrolpi-blobs"
|
||||
|
||||
cp files/district-of-columbia-*.dump.gz "${ROOTFS_DIR}/opt/wrolpi-blobs/gis-map.dump.gz"
|
||||
cp files/* "${ROOTFS_DIR}/opt/wrolpi-blobs/"
|
||||
|
||||
set +x
|
||||
|
||||
|
|
|
|||
|
|
@ -13,29 +13,25 @@ EOF
|
|||
|
||||
# Create WROLPi user. This user will own the media directory, API, and App.
|
||||
# The `pi` user will be the maintainer's user.
|
||||
grep wrolpi: /etc/passwd || useradd -md /home/wrolpi wrolpi -s "$(command -v bash)"
|
||||
useradd -md /home/wrolpi wrolpi -s "$(command -v bash)"
|
||||
usermod -aG pi wrolpi
|
||||
|
||||
# Change default postgresql port to 5432.
|
||||
sed -i 's/port = 5433/port = 5432/' /etc/postgresql/13/main/postgresql.conf
|
||||
sed -i 's/port = 5433/port = 5432/' /etc/postgresql/15/main/postgresql.conf
|
||||
|
||||
# Install Node console commands.
|
||||
single-file --version || npm i -g serve@12.0.1 single-file-cli@1.0.15 readability-extractor@0.0.6 carto@1.2.0
|
||||
npm i -g serve@12.0.1 single-file-cli@1.0.15 readability-extractor@0.0.6 carto@1.2.0
|
||||
|
||||
# Put the latest WROLPi master in /opt/wrolpi.
|
||||
rm -rf /opt/wrolpi
|
||||
git clone -b master https://github.com/lrnselfreliance/wrolpi.git /opt/wrolpi
|
||||
git config --global --add safe.directory /opt/wrolpi
|
||||
|
||||
# Install Python requirements.
|
||||
pip3 install --upgrade pip
|
||||
python3 -m venv /opt/wrolpi/venv
|
||||
/opt/wrolpi/venv/bin/pip3 install -r /opt/wrolpi/requirements.txt
|
||||
|
||||
# Install webapp.
|
||||
cd /opt/wrolpi/app
|
||||
npm install
|
||||
npm run build
|
||||
(cd /opt/wrolpi/app && npm install && npm run build)
|
||||
|
||||
# Add wrolpi database password to pi user
|
||||
cat >/home/pi/.pgpass <<'EOF'
|
||||
|
|
@ -48,8 +44,8 @@ chmod 0600 /home/pi/.pgpass
|
|||
chown -R wrolpi:wrolpi /opt/wrolpi
|
||||
|
||||
# Configure nginx.
|
||||
cp /opt/wrolpi/nginx.conf /etc/nginx/nginx.conf
|
||||
cp /opt/wrolpi/50x.html /var/www/50x.html
|
||||
cp /opt/wrolpi/etc/raspberrypios/nginx.conf /etc/nginx/nginx.conf
|
||||
cp /opt/wrolpi/etc/raspberrypios/50x.html /var/www/50x.html
|
||||
|
||||
# WROLPi needs a few privileged commands.
|
||||
cp /opt/wrolpi/etc/raspberrypios/90-wrolpi /etc/sudoers.d/90-wrolpi
|
||||
|
|
@ -57,18 +53,14 @@ chmod 0440 /etc/sudoers.d/90-wrolpi
|
|||
# Verify this new file is valid.
|
||||
visudo -c -f /etc/sudoers.d/90-wrolpi
|
||||
|
||||
[ -d /media/wrolpi ] || mkdir /media/wrolpi
|
||||
mkdir /media/wrolpi
|
||||
chown wrolpi:wrolpi /media/wrolpi
|
||||
|
||||
cp /opt/wrolpi/etc/raspberrypios/wrolpi-api.service /etc/systemd/system/
|
||||
cp /opt/wrolpi/etc/raspberrypios/wrolpi-app.service /etc/systemd/system/
|
||||
cp /opt/wrolpi/etc/debian12/wrolpi-app.service /etc/systemd/system/
|
||||
cp /opt/wrolpi/etc/raspberrypios/wrolpi-kiwix.service /etc/systemd/system/
|
||||
cp /opt/wrolpi/etc/raspberrypios/wrolpi.target /etc/systemd/system/
|
||||
|
||||
systemctl enable wrolpi-api.service
|
||||
systemctl enable wrolpi-app.service
|
||||
systemctl enable wrolpi-kiwix.service
|
||||
|
||||
# NetworkManager for the hotspot.
|
||||
systemctl enable NetworkManager
|
||||
|
||||
|
|
|
|||
|
|
@ -4,16 +4,11 @@ set -e
|
|||
set -x
|
||||
|
||||
# Create mapnik config.
|
||||
if [ ! -d /opt/openstreetmap-carto ]; then
|
||||
git clone https://github.com/lrnselfreliance/openstreetmap-carto.git /opt/openstreetmap-carto
|
||||
fi
|
||||
git clone https://github.com/lrnselfreliance/openstreetmap-carto.git /opt/openstreetmap-carto
|
||||
git config --global --add safe.directory /opt/openstreetmap-carto
|
||||
(cd /opt/openstreetmap-carto && git fetch && git checkout master && git reset --hard origin/master && git pull --ff)
|
||||
chown -R wrolpi:wrolpi /opt/openstreetmap-carto
|
||||
cd /opt/openstreetmap-carto
|
||||
if [[ ! -f /opt/openstreetmap-carto/mapnik.xml || ! -s /opt/openstreetmap-carto/mapnik.xml ]]; then
|
||||
/usr/bin/carto project.mml >/opt/openstreetmap-carto/mapnik.xml
|
||||
fi
|
||||
(cd /opt/openstreetmap-carto && carto project.mml >/opt/openstreetmap-carto/mapnik.xml)
|
||||
|
||||
# WROLPi user can access WROLPi and Map database.
|
||||
mkdir -p /home/pi/Desktop
|
||||
|
|
@ -48,7 +43,7 @@ chmod 644 /var/www/html/*
|
|||
# Allow wrolpi user to delete map tiles.
|
||||
usermod -aG _renderd wrolpi
|
||||
|
||||
[ -d /var/cache/renderd/tiles ] || mkdir /var/cache/renderd/tiles
|
||||
mkdir /var/cache/renderd/tiles
|
||||
chown -R _renderd:_renderd /var/cache/renderd/tiles
|
||||
|
||||
# Create the media directory for the wrolpi user.
|
||||
|
|
|
|||
1
pi-gen/stage2/04-wrolpi/files/.gitignore
vendored
Normal file
1
pi-gen/stage2/04-wrolpi/files/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
*.dump.gz
|
||||
Loading…
Add table
Add a link
Reference in a new issue