fix: enhance systemd service setup for containerized environments and add cross-compile support
This commit is contained in:
@ -197,8 +197,10 @@ else
|
||||
echo "Pre-built frontend detected. Skipping frontend build."
|
||||
fi
|
||||
|
||||
# 4.3 Setup Systemd
|
||||
cat <<EOF > /etc/systemd/system/mpvj-backend.service
|
||||
# 4.3 Setup system service (only if systemd is running)
|
||||
# Note: in containerized environments (no systemd PID 1), systemctl will fail.
|
||||
if [ "$(cat /proc/1/comm 2>/dev/null)" = "systemd" ] && command -v systemctl > /dev/null 2>&1; then
|
||||
cat <<EOF > /etc/systemd/system/mpvj-backend.service
|
||||
[Unit]
|
||||
Description=MPVJ Backend
|
||||
After=network.target
|
||||
@ -211,8 +213,12 @@ Restart=on-failure
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl daemon-reload
|
||||
systemctl enable mpvj-backend.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable mpvj-backend.service
|
||||
else
|
||||
echo "WARNING: systemd not detected (PID 1 is not systemd). Skipping systemd service setup."
|
||||
echo "You can run the backend manually: node $REAL_HOME/mpvj/backend/index.js"
|
||||
fi
|
||||
|
||||
# 4.4 .env
|
||||
cat <<EOF > "$REAL_HOME/mpvj/backend/.env"
|
||||
@ -328,7 +334,15 @@ sudo -u "$REAL_USER" make clean
|
||||
|
||||
echo "Starting compilation (Nuclear Stability Mode: -O0 + C++11 + VRP disabled)..."
|
||||
GLOBAL_FLAGS="-Wno-error -Wno-reorder -Wno-sign-compare -Wno-delete-non-virtual-dtor -std=c++11 -O0 -fno-tree-vrp"
|
||||
sudo -u "$REAL_USER" make -j1 \
|
||||
|
||||
# Cross-compile support: if host is not aarch64 and cross toolchain is present, use it
|
||||
MAKE_ENV=""
|
||||
if [ "$(uname -m)" != "aarch64" ] && command -v aarch64-linux-gnu-g++ > /dev/null 2>&1; then
|
||||
echo "Detected x86_64 host with aarch64 toolchain; building aarch64 binaries."
|
||||
MAKE_ENV="CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ AR=aarch64-linux-gnu-ar LD=aarch64-linux-gnu-ld"
|
||||
fi
|
||||
|
||||
sudo -u "$REAL_USER" env $MAKE_ENV make -j1 \
|
||||
PLATFORM_CFLAGS="$GLOBAL_FLAGS -I$REAL_HOME/openFrameworks/addons/ofxPiMapper/src" \
|
||||
USER_CFLAGS="$GLOBAL_FLAGS" \
|
||||
USER_CPPFLAGS="-std=c++11" \
|
||||
@ -342,5 +356,11 @@ echo "Cleaning up..."
|
||||
swapoff /swapfile_mpvj 2>/dev/null || true
|
||||
rm /swapfile_mpvj 2>/dev/null || true
|
||||
|
||||
whiptail --title "Success" --msgbox "INSTALL COMPLETE!\n\nRebooting into AP Mode.\nSSID: $WIFI_SSID\nIP: 192.168.4.1" 12 45 < /dev/tty
|
||||
reboot
|
||||
if [ "$(cat /proc/1/comm 2>/dev/null)" = "systemd" ]; then
|
||||
whiptail --title "Success" --msgbox "INSTALL COMPLETE!\n\nRebooting into AP Mode.\nSSID: $WIFI_SSID\nIP: 192.168.4.1" 12 45 < /dev/tty
|
||||
reboot
|
||||
else
|
||||
echo "INSTALL COMPLETE. Running inside a non-systemd environment (e.g., container)."
|
||||
echo "Start the backend with: node $REAL_HOME/mpvj/backend/index.js"
|
||||
echo "(No reboot performed.)"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user