wrolpi/debian-live-config/config/hooks/normal/9999-wrolpi.hook.chroot
Roland 24a0646f99
Some checks failed
CodeQL / Analyze (push) Has been cancelled
Updating MOTD to suggest ip addresses on login.
2025-08-18 11:33:44 -06:00

81 lines
2.5 KiB
Bash

#!/usr/bin/bash
# This script is used to generate a Debian Live ISO image.
set -e
set -x
cat >>/etc/profile <<'EOF'
alias ll='ls -lh'
alias la='ll -a'
EOF
git --version
git clone -b master https://github.com/lrnselfreliance/wrolpi.git /opt/wrolpi
# Install webapp.
cd /opt/wrolpi/app
npm --version
node --version
npm install
npm run build
# Install Node console commands.
npm i -g serve@12.0.1 single-file-cli@2.0.73 readability-extractor@0.0.6 carto@1.2.0
# Install Python requirements. Try multiple times because pypi may stop responding.
python3 --version
python3 -m venv /opt/wrolpi/venv
/opt/wrolpi/venv/bin/pip3 install -r /opt/wrolpi/requirements.txt ||
/opt/wrolpi/venv/bin/pip3 install -r /opt/wrolpi/requirements.txt ||
/opt/wrolpi/venv/bin/pip3 install -r /opt/wrolpi/requirements.txt
# Configure nginx.
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
chmod 0440 /etc/sudoers.d/90-wrolpi
# Verify this new file is valid.
visudo -c -f /etc/sudoers.d/90-wrolpi
# Create postgres cluster for map.
pg_createcluster 15 map --port=5433 -e utf8
git clone https://github.com/lrnselfreliance/openstreetmap-carto.git /opt/openstreetmap-carto
git config --global --add safe.directory /opt/openstreetmap-carto
sed -i '/dbname: "gis"/a \ port: 5433' /opt/openstreetmap-carto/project.mml
(cd /opt/openstreetmap-carto && carto project.mml >/opt/openstreetmap-carto/mapnik.xml)
# Change default postgresql port to 5432.
sed -i 's/port = 5433/port = 5432/' /etc/postgresql/15/main/postgresql.conf
mkdir /media/wrolpi
# Install WROLPi Help.
/opt/wrolpi/scripts/install_help_service.sh
cp /opt/wrolpi/etc/raspberrypios/wrolpi-*.service /etc/systemd/system/
cp /opt/wrolpi/etc/raspberrypios/wrolpi.target /etc/systemd/system/
cp /opt/wrolpi/etc/raspberrypios/renderd.conf /etc/renderd.conf
# Copy MOTD scripts, delete original.
cp /opt/wrolpi/etc/raspberrypios/motd/20-wrolpi.motd /etc/update-motd.d/20-wrolpi
cp /opt/wrolpi/etc/raspberrypios/motd/30-wrolpi-first.motd /etc/update-motd.d/30-wrolpi
chmod +x /etc/update-motd.d/*
truncate -s 0 /etc/motd
# NetworkManager for the hotspot.
systemctl enable NetworkManager
# Enable iperf3 for speed testing.
systemctl enable iperf3
set +x
echo
echo "======================================================================"
echo "9999-wrolpi.hook.chroot completed"
echo "======================================================================"
echo