mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-05 06:09:57 -05:00
122 lines
4.4 KiB
Bash
122 lines
4.4 KiB
Bash
#!/usr/bin/bash
|
|
# This script is used to generate a Debian Live ISO image.
|
|
|
|
set -e
|
|
set -x
|
|
|
|
# Generate and set default locale to avoid perl warnings.
|
|
# Users can change this later via: sudo dpkg-reconfigure locales
|
|
sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
|
|
locale-gen
|
|
echo 'LANG=en_US.UTF-8' > /etc/default/locale
|
|
export LANG=en_US.UTF-8
|
|
|
|
cat >>/etc/profile <<'EOF'
|
|
alias ll='ls -lh'
|
|
alias la='ll -a'
|
|
EOF
|
|
|
|
git --version
|
|
|
|
WROLPI_BRANCH="release"
|
|
[ -f /opt/wrolpi-branch ] && WROLPI_BRANCH=$(cat /opt/wrolpi-branch)
|
|
git clone -b "${WROLPI_BRANCH}" https://github.com/lrnselfreliance/wrolpi.git /opt/wrolpi
|
|
rm -f /opt/wrolpi-branch
|
|
|
|
# Install webapp.
|
|
cd /opt/wrolpi/app
|
|
npm --version
|
|
node --version
|
|
npm install
|
|
|
|
# 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 Deno runtime.
|
|
DENO_VERSION="v2.2.4"
|
|
curl -fsSL "https://github.com/denoland/deno/releases/download/${DENO_VERSION}/deno-x86_64-unknown-linux-gnu.zip" -o /tmp/deno.zip
|
|
unzip /tmp/deno.zip -d /usr/local/bin/
|
|
chmod +x /usr/local/bin/deno
|
|
rm /tmp/deno.zip
|
|
deno --version
|
|
|
|
# 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
|
|
|
|
# Install Controller with separate venv.
|
|
echo "Pre-installing WROLPi Controller..."
|
|
python3 -m venv /opt/wrolpi/controller/venv
|
|
/opt/wrolpi/controller/venv/bin/pip install --upgrade pip
|
|
/opt/wrolpi/controller/venv/bin/pip install -r /opt/wrolpi/controller/requirements.txt ||
|
|
/opt/wrolpi/controller/venv/bin/pip install -r /opt/wrolpi/controller/requirements.txt ||
|
|
/opt/wrolpi/controller/venv/bin/pip install -r /opt/wrolpi/controller/requirements.txt
|
|
echo "Controller pre-installed"
|
|
|
|
# Configure nginx.
|
|
cp /opt/wrolpi/etc/raspberrypios/nginx.conf /etc/nginx/nginx.conf
|
|
cp /opt/wrolpi/etc/raspberrypios/50x.html /var/www/50x.html
|
|
# Copy wrolpi.conf which defines the location blocks for reverse proxy.
|
|
[ -f /etc/nginx/conf.d/default.conf ] && rm /etc/nginx/conf.d/default.conf
|
|
cp /opt/wrolpi/etc/raspberrypios/wrolpi.conf /etc/nginx/conf.d/wrolpi.conf
|
|
# Remove default site (WROLPi nginx.conf doesn't use sites-enabled).
|
|
rm -f /etc/nginx/sites-enabled/default
|
|
|
|
# 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
|
|
# Enable first startup script to generate certificates and start nginx.
|
|
systemctl enable wrolpi-first-startup.service
|
|
# Enable Controller service to start on boot.
|
|
systemctl enable wrolpi-controller.service
|
|
|
|
# Protect blob files from accidental modification or deletion.
|
|
# These files are critical for initializing WROLPi.
|
|
chown -R root:root /opt/wrolpi-blobs
|
|
chmod 444 /opt/wrolpi-blobs/*
|
|
chattr +i /opt/wrolpi-blobs/*
|
|
|
|
set +x
|
|
|
|
echo
|
|
echo "======================================================================"
|
|
echo "9999-wrolpi.hook.chroot completed"
|
|
echo "======================================================================"
|
|
echo
|