Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04-arm
steps:
- name: Install Dependencies
run: |
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.6'

services:
# custompios_prep:
# image: guysoft/custompios:devel
Expand Down
7 changes: 5 additions & 2 deletions src/config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export DIST_NAME=MonsterPi
export DIST_VERSION=1.0.0-rc3
export DIST_VERSION=1.0.0
export MODULES="base(network, disable-services(monsterpi), password-for-sudo)"

export BASE_DISTRO=raspios64
Expand All @@ -17,4 +17,7 @@ export RPI_IMAGER_ICON="https://github.com/fdm-monster/fdm-monster/blob/ba18cb70
export BASE_IMAGE_ENLARGEROOT=1500
export BASE_IMAGE_RESIZEROOT=250
export BASE_USER=pi
export BASE_USER_PASSWORD=raspberry
export BASE_USER_PASSWORD=raspberry

# Disable compression - we handle it manually like CI/CD does
export BASE_RELEASE_COMPRESS=no
4 changes: 2 additions & 2 deletions src/modules/monsterpi/filesystem/home/root/bin/gencert
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ certfile=/etc/ssl/snakeoil.pem

if [ ! -f $keyfile ] || [ ! -s $keyfile ] || [ ! -f $pemfile ] || [ ! -s $pemfile ] || [ ! -f $certfile ] || [ ! -s $certfile ]; then
echo "Generating SSL certificate"
sudo make-ssl-cert generate-default-snakeoil --force-overwrite
sudo cat $keyfile $pemfile > $certfile
make-ssl-cert generate-default-snakeoil --force-overwrite
cat $keyfile $pemfile > $certfile
fi
50 changes: 18 additions & 32 deletions src/modules/monsterpi/start_chroot_script
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ fdmm_npm_package="@fdm-monster/server"
fdmm_version="${MONSTERPI_FDMMONSTER_VERSION}"
fdmm_nodejs_version="${MONSTERPI_NODEJS_VERSION:-24.12.0}"
fdmm_server_port="4000"
fdmm_home="/home/${BASE_USER}"
fdmm_install_dir="${fdmm_home}/.fdm-monster"
fdmm_data_dir="${fdmm_home}/.fdm-monster-data"
installer_url="https://raw.githubusercontent.com/fdm-monster/fdm-monster-scripts/main/install/linux/install.sh"
installer_path="/tmp/fdm-monster-install.sh"

Expand All @@ -38,48 +41,30 @@ else
apt-get -y install jq git screen libffi-dev libssl-dev libatlas3-base ca-certificates curl
fi

# Validate FDM Monster NPM Package Version
echo "Validating FDM Monster version ${fdmm_version}..."
npm_package_url="https://registry.npmjs.org/${fdmm_npm_package}/${fdmm_version}"
if ! curl --fail --silent --head "${npm_package_url}" > /dev/null 2>&1; then
echo "ERROR: NPM package ${fdmm_npm_package}@${fdmm_version} does not exist!"
echo "Please check the version in config file and try again."
exit 1
fi
echo "NPM package ${fdmm_npm_package}@${fdmm_version} validated successfully."

# Install FDM Monster using official CLI
# Download the official FDM Monster install script LIVE from GitHub
echo "Downloading FDM Monster installer from GitHub..."
curl -fsSL "${installer_url}" -o "${installer_path}"
chmod +x "${installer_path}"

# Set environment variables for FDM Monster CLI configuration
# Set up FDM Monster installation environment
export FDMM_NODE_VERSION="${fdmm_nodejs_version}"
export FDMM_NPM_PACKAGE="${fdmm_npm_package}"
export FDMM_NPM_PACKAGE_VERSION="${fdmm_version}"
export FDMM_HOME="/home/${BASE_USER}"
export FDMM_INSTALL_DIR="/home/${BASE_USER}/.fdm-monster"
export FDMM_DATA_DIR="/home/${BASE_USER}/.fdm-monster-data"
export FDMM_HOME="${fdmm_home}"
export FDMM_INSTALL_DIR="${fdmm_install_dir}"
export FDMM_DATA_DIR="${fdmm_data_dir}"
export FDMM_SERVER_PORT="${fdmm_server_port}"
export FDMM_OVERRIDE_ROOT="true"
export YARN_NODE_LINKER=node-modules

# Pre-create install directory and configure Yarn to use node-modules linker
echo "Pre-configuring Yarn for installation..."
mkdir -p "${FDMM_INSTALL_DIR}"
cat > "${FDMM_INSTALL_DIR}/.yarnrc.yml" <<EOF
nodeLinker: node-modules
EOF
# Install FDM Monster using local installer script (provides nice CLI)
# Split into two phases for chroot environment:
# 1. User-level: nodejs, yarn, fdm-monster package, CLI wrapper (run as pi user)
# 2. Root-level: systemd service setup (run with appropriate privileges)

# Run the installer with BASE_USER's HOME context
echo "Installing FDM Monster using official CLI..."
bash "${installer_path}" install
echo "Installing FDM Monster ${fdmm_version} - User-level components..."
sudo -u "${BASE_USER}" bash "${installer_path}" install-user

# Fix ownership of all created files to BASE_USER
chown -R "${BASE_USER}:${BASE_USER}" "/home/${BASE_USER}/.fdm-monster" "/home/${BASE_USER}/.fdm-monster-data"
echo "Installing FDM Monster ${fdmm_version} - Root-level components..."
bash "${installer_path}" install-root

# Clean up the installer
# Clean up the installer script
rm -f "${installer_path}"

# Setup HAProxy and SSL
Expand All @@ -88,6 +73,7 @@ then
echo "Setting up HAProxy for HTTP and HTTPS..."
apt -y install ssl-cert haproxy
rm /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/certs/ssl-cert-snakeoil.pem
chmod +x /root/bin/gencert
fi

# Configure Boot Messages
Expand Down Expand Up @@ -122,7 +108,7 @@ echo 'exit 0' >> /etc/rc.local

# Configure User Environment
# Inject FDM Monster installation directory into welcome script
sed -i "s|__FDMM_INSTALL_DIR__|${FDMM_INSTALL_DIR}|g" /home/"${BASE_USER}"/scripts/welcome
sed -i "s|__FDMM_INSTALL_DIR__|${fdmm_install_dir}|g" /home/"${BASE_USER}"/scripts/welcome

# Add welcome message to user's bashrc
echo "source /home/${BASE_USER}/scripts/welcome" >> /home/"${BASE_USER}"/.bashrc
Expand Down
Loading