mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-20 23:16:17 -05:00
Using pi-gen to create wrolpi raspberry image.
This commit is contained in:
parent
12c3504291
commit
838b4dd185
8 changed files with 206 additions and 0 deletions
17
pi-gen/README.md
Normal file
17
pi-gen/README.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# 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 these configs to pi-gen (modify for your directories):
|
||||
* `cp -r /home/user/wrolpi/pi-gen/stage3/02-wrolpi /home/user/pi-gen/stage3/`
|
||||
3. Change to the pi-gen directory:
|
||||
* `cd /home/user/pi-gen`
|
||||
4. Create directory for files:
|
||||
* `mkdir stage3/02-wrolpi/files`
|
||||
5. 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/stage3/02-wrolpi/files/district-of-columbia-230111.dump.gz`
|
||||
6. Run the build:
|
||||
* `sudo /bin/bash ./build.sh -c config.txt`
|
||||
|
||||
Your final image should be in `pi-gen/work/WROLPi/export-image/`
|
||||
2
pi-gen/stage3/02-wrolpi/00-run-chroot.sh
Executable file
2
pi-gen/stage3/02-wrolpi/00-run-chroot.sh
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
# Install Node 14 repo.
|
||||
npm --version || curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
|
||||
74
pi-gen/stage3/02-wrolpi/01-packages
Normal file
74
pi-gen/stage3/02-wrolpi/01-packages
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
apache2
|
||||
apache2-dev
|
||||
apt-transport-https
|
||||
autoconf
|
||||
build-essential
|
||||
bzip2
|
||||
ca-certificates
|
||||
cargo
|
||||
chromium-browser
|
||||
chromium-chromedriver
|
||||
cpufrequtils
|
||||
curl
|
||||
ffmpeg
|
||||
fonts-noto-cjk
|
||||
fonts-noto-hinted
|
||||
fonts-noto-unhinted
|
||||
gcc
|
||||
gdal-bin
|
||||
git
|
||||
gnupg-agent
|
||||
hostapd
|
||||
libagg-dev
|
||||
libapache2-mod-tile
|
||||
libboost-all-dev
|
||||
libbz2-dev
|
||||
libcairo2-dev
|
||||
libcairomm-1.0-dev
|
||||
libcurl4-gnutls-dev
|
||||
libffi-dev
|
||||
libfreetype6-dev
|
||||
libgdal-dev
|
||||
libgeos++-dev
|
||||
libgeos-dev
|
||||
libicu-dev
|
||||
libiniparser-dev
|
||||
liblua5.1-0-dev
|
||||
liblua5.2-dev
|
||||
libmapnik-dev
|
||||
libmemcached-dev
|
||||
libpq-dev
|
||||
libproj-dev
|
||||
librados-dev
|
||||
libssl-dev
|
||||
libtiff5-dev
|
||||
libtool
|
||||
libxml2-dev
|
||||
lua5.1
|
||||
mapnik-utils
|
||||
network-manager
|
||||
nginx-doc
|
||||
nginx-full
|
||||
nodejs
|
||||
osm2pgsql
|
||||
osmium-tool
|
||||
pkg-config
|
||||
postgis
|
||||
postgresql-13
|
||||
postgresql-13-postgis-3
|
||||
postgresql-13-postgis-3-scripts
|
||||
postgresql-contrib
|
||||
protobuf-c-compiler
|
||||
python3-mapnik
|
||||
python3-pip
|
||||
python3.9-dev
|
||||
python3.9-doc
|
||||
python3.9-minimal
|
||||
python3.9-venv
|
||||
renderd
|
||||
software-properties-common
|
||||
tar
|
||||
ttf-unifont
|
||||
unzip
|
||||
vim
|
||||
wget
|
||||
4
pi-gen/stage3/02-wrolpi/02-run.sh
Executable file
4
pi-gen/stage3/02-wrolpi/02-run.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#! /bin/bash -e
|
||||
mkdir -p "${ROOTFS_DIR}/opt/wrolpi-blobs"
|
||||
|
||||
cp files/district-of-columbia-230111.dump.gz "${ROOTFS_DIR}/opt/wrolpi-blobs/gis-map.dump.gz"
|
||||
42
pi-gen/stage3/02-wrolpi/03-run-chroot.sh
Executable file
42
pi-gen/stage3/02-wrolpi/03-run-chroot.sh
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#! /usr/bin/env bash
|
||||
set -e
|
||||
set -x
|
||||
|
||||
# Install Node console commands.
|
||||
single-file --version || npm i -g serve@12.0.1 single-file-cli@1.0.15 'git+https://github.com/lrnselfreliance/readability-extractor' carto@1.2.0
|
||||
|
||||
# Put the latest WROLPi release in /opt/wrolpi.
|
||||
rm -rf /opt/wrolpi
|
||||
git clone -b release https://github.com/lrnselfreliance/wrolpi.git /opt/wrolpi
|
||||
|
||||
# Install Python requirements.
|
||||
pip3 install --upgrade pip
|
||||
pip3 install -r /opt/wrolpi/requirements.txt
|
||||
|
||||
# Install webapp.
|
||||
cd /opt/wrolpi/app
|
||||
npm install
|
||||
npm run build
|
||||
|
||||
# Configure nginx.
|
||||
cp /opt/wrolpi/nginx.conf /etc/nginx/nginx.conf
|
||||
cp /opt/wrolpi/50x.html /var/www/50x.html
|
||||
|
||||
# WROLPi needs a few privileged commands.
|
||||
cat >/etc/sudoers.d/90-wrolpi <<'EOF'
|
||||
%wrolpi ALL=(ALL) NOPASSWD:/usr/bin/nmcli,/usr/bin/cpufreq-set
|
||||
%wrolpi ALL= NOPASSWD:/usr/bin/systemctl restart renderd.service
|
||||
%wrolpi ALL= NOPASSWD:/usr/bin/systemctl stop renderd.service
|
||||
%wrolpi ALL= NOPASSWD:/usr/bin/systemctl start renderd.service
|
||||
EOF
|
||||
chmod 660 /etc/sudoers.d/90-wrolpi
|
||||
|
||||
[ -d /media/wrolpi ] || mkdir /media/wrolpi
|
||||
chown 1000:1000 /media/wrolpi
|
||||
|
||||
cp /opt/wrolpi/etc/ubuntu20.04/wrolpi-api.service /etc/systemd/system/
|
||||
cp /opt/wrolpi/etc/ubuntu20.04/wrolpi-app.service /etc/systemd/system/
|
||||
cp /opt/wrolpi/etc/ubuntu20.04/wrolpi.target /etc/systemd/system/
|
||||
|
||||
systemctl enable wrolpi-api.service
|
||||
systemctl enable wrolpi-app.service
|
||||
45
pi-gen/stage3/02-wrolpi/04-run-chroot.sh
Executable file
45
pi-gen/stage3/02-wrolpi/04-run-chroot.sh
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
#! /usr/bin/env bash
|
||||
# Install and configure Renderd for Open Street Map.
|
||||
set -e
|
||||
set -x
|
||||
|
||||
[ ! -d /var/lib/mod_tile ] && mkdir /var/lib/mod_tile
|
||||
chown 1000:1000 /var/lib/mod_tile
|
||||
|
||||
# Initialize gis database.
|
||||
if [ ! -d /opt/openstreetmap-carto ]; then
|
||||
git clone https://github.com/lrnselfreliance/openstreetmap-carto.git /opt/openstreetmap-carto
|
||||
fi
|
||||
(cd /opt/openstreetmap-carto && git fetch && git checkout master && git reset --hard origin/master && git pull --ff)
|
||||
chown -R 1000:1000 /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
|
||||
|
||||
# Configure renderd.
|
||||
cp /opt/wrolpi/etc/ubuntu20.04/renderd.conf /usr/local/etc/renderd.conf
|
||||
# Enable mod-tile.
|
||||
/usr/sbin/a2enconf mod_tile
|
||||
|
||||
# Swap renderd user to wrolpi.
|
||||
cat > /usr/lib/systemd/system/renderd.service <<'EOF'
|
||||
[Unit]
|
||||
Description=Daemon that renders map tiles using mapnik
|
||||
Documentation=man:renderd
|
||||
After=network.target auditd.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/renderd -f
|
||||
User=wrolpi
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
cp /opt/wrolpi/etc/ubuntu20.04/mod_tile.conf /etc/apache2/conf-available/mod_tile.conf
|
||||
cp /opt/wrolpi/modules/map/leaflet.js /var/www/html/leaflet.js
|
||||
cp /opt/wrolpi/modules/map/leaflet.css /var/www/html/leaflet.css
|
||||
cp /opt/wrolpi/etc/ubuntu20.04/ports.conf /etc/apache2/ports.conf
|
||||
cp /opt/wrolpi/etc/ubuntu20.04/000-default.conf /etc/apache2/sites-available/000-default.conf
|
||||
cp /opt/wrolpi/etc/ubuntu20.04/index.html /var/www/html/index.html
|
||||
22
scripts/create_db.sh
Normal file
22
scripts/create_db.sh
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Create WROLPi API database.
|
||||
sudo -u postgres psql -c '\l' | grep wrolpi || (
|
||||
sudo -u postgres createuser wrolpi
|
||||
sudo -u postgres psql -c "alter user postgres password 'wrolpi'"
|
||||
sudo -u postgres psql -c "alter user wrolpi password 'wrolpi'"
|
||||
sudo -u postgres createdb -E UTF8 -O wrolpi wrolpi
|
||||
echo "Created wrolpi database"
|
||||
)
|
||||
sudo -u wrolpi /bin/bash -c 'cd /opt/wrolpi && ./main.py db upgrade'
|
||||
|
||||
# Create gis (map) database.
|
||||
sudo -u postgres psql -c '\l' | grep gis || (
|
||||
sudo -u postgres createdb -E UTF8 -O wrolpi gis
|
||||
sudo -u postgres psql -d gis -c "CREATE EXTENSION postgis"
|
||||
sudo -u postgres psql -d gis -c "CREATE EXTENSION hstore"
|
||||
sudo -u postgres psql -d gis -c "ALTER TABLE geometry_columns OWNER TO wrolpi"
|
||||
sudo -u postgres psql -d gis -c "ALTER TABLE spatial_ref_sys OWNER TO wrolpi"
|
||||
echo "Created gis database"
|
||||
)
|
||||
zcat /opt/wrolpi-blobs/gis-map.dump.gz | sudo -u postgres pg_restore --clean --no-owner -d gis
|
||||
Loading…
Add table
Add a link
Reference in a new issue