feat: pivot systemd to standalone bare-metal mode v1.3.2
This commit is contained in:
@@ -1,40 +1,43 @@
|
||||
#!/bin/bash
|
||||
# install_service.sh - Installs the inventory system as a systemd service
|
||||
# install_service.sh - Installs the inventory system as a standalone systemd service
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "🚫 This script must be run as root (use sudo)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "⚙️ Installing TFM aInventory as a Systemd service..."
|
||||
echo "⚙️ Installing TFM aInventory as a Standalone Linux service..."
|
||||
|
||||
# Detect working directory
|
||||
WORKING_DIR="$(pwd)"
|
||||
|
||||
# Detect Docker binary
|
||||
DOCKER_BIN=$(which docker)
|
||||
if [ -z "$DOCKER_BIN" ]; then
|
||||
echo "❌ Docker not found! Please install Docker first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Determine if we use 'docker compose' or legacy 'docker-compose'
|
||||
if docker compose version >/dev/null 2>&1; then
|
||||
DOCKER_CMD="$DOCKER_BIN"
|
||||
COMP_VER="v2 (plugin)"
|
||||
else
|
||||
DOCKER_BIN=$(which docker-compose)
|
||||
if [ -z "$DOCKER_BIN" ]; then
|
||||
echo "❌ neither 'docker compose' nor 'docker-compose' found!"
|
||||
# 1. Dependency Checks
|
||||
echo "🔍 Checking dependencies..."
|
||||
for cmd in python3 node npm; do
|
||||
if ! command -v $cmd &> /dev/null; then
|
||||
echo "❌ $cmd not found! Please install it before proceeding."
|
||||
exit 1
|
||||
fi
|
||||
DOCKER_CMD="$DOCKER_BIN"
|
||||
COMP_VER="v1 (legacy)"
|
||||
done
|
||||
|
||||
# 2. Setup Backend Environment
|
||||
echo "🐍 Setting up Python Virtual Environment..."
|
||||
if [ ! -d ".venv" ]; then
|
||||
python3 -m venv .venv
|
||||
fi
|
||||
source .venv/bin/activate
|
||||
pip install -q --upgrade pip
|
||||
pip install -q -r backend/requirements.txt
|
||||
|
||||
echo "✅ Found $COMP_VER at $DOCKER_CMD"
|
||||
# 3. Setup Frontend Environment
|
||||
echo "📦 Installing Node dependencies (this may take a minute)..."
|
||||
cd frontend
|
||||
npm install --quiet
|
||||
echo "🏗️ Building Frontend for Production (Next.js build)..."
|
||||
npm run build
|
||||
cd ..
|
||||
|
||||
# Create the final service file from template
|
||||
# 4. Create the final service file from template
|
||||
TEMPLATE="inventory.service.template"
|
||||
TARGET="/etc/systemd/system/inventory.service"
|
||||
|
||||
@@ -43,16 +46,20 @@ if [ ! -f "$TEMPLATE" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sed "s|__WORKING_DIR__|$WORKING_DIR|g; s|__DOCKER_BIN__|$DOCKER_CMD|g" "$TEMPLATE" > "$TARGET"
|
||||
sed "s|__WORKING_DIR__|$WORKING_DIR|g" "$TEMPLATE" > "$TARGET"
|
||||
|
||||
echo "📝 Service file created at $TARGET"
|
||||
|
||||
# Reload and enable
|
||||
# 5. Reload and enable
|
||||
systemctl daemon-reload
|
||||
systemctl enable inventory.service
|
||||
|
||||
# 6. Ensure scripts are executable
|
||||
chmod +x run_standalone.sh
|
||||
chmod +x start_server.sh
|
||||
|
||||
echo ""
|
||||
echo "🚀 TFM aInventory service installed and enabled!"
|
||||
echo "🚀 TFM aInventory Standalone service installed and enabled!"
|
||||
echo " Commands:"
|
||||
echo " 👉 sudo systemctl start inventory"
|
||||
echo " 👉 sudo systemctl status inventory"
|
||||
|
||||
Reference in New Issue
Block a user