diff --git a/.github/workflows/build_rpi.yml b/.github/workflows/build_rpi.yml new file mode 100644 index 0000000..d230592 --- /dev/null +++ b/.github/workflows/build_rpi.yml @@ -0,0 +1,67 @@ +name: Dispatched Build and publish RaspAP images + +permissions: + contents: write + +on: + release: + types: [published] + workflow_dispatch: + pull_request: + +jobs: + build-raspap-image: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - arch: "32-bit" + pi_gen_version: "master" + - arch: "64-bit" + pi_gen_version: "arm64" + fail-fast: false + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # - name: Add RaspAP Stage + # run: | + # mkdir -p stage-raspap/package-raspap && + # { + # cat > stage-raspap/package-raspap/00-run-chroot.sh <<-EOF + # #!/bin/bash + # apt-get update -y && apt-get install -y curl dhcpcd5 iptables procps + # curl -sL https://install.raspap.com | bash -s -- --yes --openvpn 1 --restapi 1 --adblock 1 --wireguard 1 --tcp-bbr 1 --check 0 + + # # Set Wi-Fi country to prevent RF kill + # raspi-config nonint do_wifi_country "US" + # EOF + # } && + # chmod +x stage-raspap/package-raspap/00-run-chroot.sh && + # { + # cat > stage-raspap/prerun.sh <<-EOF + # #!/bin/bash -e + # if [ ! -d "\${ROOTFS_DIR}" ]; then + # copy_previous + # fi + # EOF + # } && + # chmod +x stage-raspap/prerun.sh + + - name: Build RaspAP Image + id: build + uses: usimd/pi-gen-action@v1 + with: + image-name: "raspap-bookworm-${{ matrix.arch == '32-bit' && 'armhf' || 'arm64' }}-lite-${{ github.event.inputs.tag || github.ref_name }}" + enable-ssh: 1 + stage-list: stage0 stage1 stage2 + # stage-list: stage0 stage1 stage2 ./stage-raspap + verbose-output: true + pi-gen-version: ${{ matrix.pi_gen_version }} + pi-gen-repository: RaspAP/pi-gen + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: rpi-deploy-${{ matrix.arch }}.img.zip + path: ${{ steps.build.outputs.image-path }} diff --git a/stage-custom/package-setup/00-run-chroot.sh b/stage-custom/package-setup/00-run-chroot.sh new file mode 100644 index 0000000..5b9f9c9 --- /dev/null +++ b/stage-custom/package-setup/00-run-chroot.sh @@ -0,0 +1,60 @@ +#!/bin/bash +set -e + +mkdir -p /proc /dev /sys /run /tmp + +# Install required packages +apt-get update +apt-get install -y python3 + +# Configure Wi-Fi +mkdir -p /etc/wpa_supplicant + +cat << EOF > /etc/wpa_supplicant/wpa_supplicant.conf +country=US +ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev +update_config=1 + +network={ + ssid="Your_SSID" + psk="Your_Password" +} +EOF + +chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf + +# Set up a simple HTTP server +cat << SERVER_EOF > /usr/local/bin/simple-http-server.py +#!/usr/bin/env python3 +from http.server import BaseHTTPRequestHandler, HTTPServer + +class SimpleHandler(BaseHTTPRequestHandler): + def do_GET(self): + self.send_response(200) + self.send_header('Content-type', 'text/plain') + self.end_headers() + self.wfile.write(b'Hello from Raspberry Pi!') + +if __name__ == '__main__': + server = HTTPServer(('0.0.0.0', 8080), SimpleHandler) + print('Starting server at http://0.0.0.0:8080') + server.serve_forever() +SERVER_EOF +chmod +x /usr/local/bin/simple-http-server.py + +# Create and enable a systemd service for the HTTP server +cat << SERVICE_EOF > /etc/systemd/system/simple-http-server.service +[Unit] +Description=Simple HTTP Server +After=network.target + +[Service] +ExecStart=/usr/local/bin/simple-http-server.py +Restart=always +User=root + +[Install] +WantedBy=multi-user.target +SERVICE_EOF + +systemctl enable simple-http-server.service diff --git a/stage-custom/prerun.sh b/stage-custom/prerun.sh new file mode 100644 index 0000000..beb195d --- /dev/null +++ b/stage-custom/prerun.sh @@ -0,0 +1,4 @@ +#!/bin/bash -e +if [ ! -d "${ROOTFS_DIR}" ]; then + copy_previous +fi