From c844391a4cddf152dedc6dda5cfeb666d81f039d Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Tue, 11 Nov 2025 12:52:12 +0000 Subject: [PATCH] Update installer and service for venv --- install-service.sh | 19 +++++++++++-------- meshcore-bot.service | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/install-service.sh b/install-service.sh index 3d889a7..3472283 100755 --- a/install-service.sh +++ b/install-service.sh @@ -91,14 +91,17 @@ echo -e "${YELLOW}Step 6: Enabling service${NC}" systemctl enable "$SERVICE_NAME" echo -e "${GREEN}Enabled $SERVICE_NAME service${NC}" -echo -e "${YELLOW}Step 7: Installing Python dependencies${NC}" -# Install Python dependencies -if command -v pip3 &> /dev/null; then - pip3 install -r "$INSTALL_DIR/requirements.txt" - echo -e "${GREEN}Installed Python dependencies${NC}" -else - echo -e "${YELLOW}pip3 not found, please install dependencies manually${NC}" -fi +echo -e "${YELLOW}Step 7: Installing Python dependencies in virtual environment${NC}" +# Create virtual environment +python3 -m venv "$INSTALL_DIR/venv" +echo -e "${GREEN}Created virtual environment${NC}" + +# Install dependencies in venv +"$INSTALL_DIR/venv/bin/pip" install -r "$INSTALL_DIR/requirements.txt" +echo -e "${GREEN}Installed Python dependencies${NC}" + +# Update ownership of venv +chown -R "$SERVICE_USER:$SERVICE_GROUP" "$INSTALL_DIR/venv" echo "" echo -e "${GREEN}Installation completed successfully!${NC}" diff --git a/meshcore-bot.service b/meshcore-bot.service index a1b69d2..9182a8c 100644 --- a/meshcore-bot.service +++ b/meshcore-bot.service @@ -9,7 +9,7 @@ Type=simple User=meshcore Group=meshcore WorkingDirectory=/opt/meshcore-bot -ExecStart=/usr/bin/python3 /opt/meshcore-bot/meshcore_bot.py +ExecStart=/opt/meshcore-bot/venv/bin/python /opt/meshcore-bot/meshcore_bot.py ExecReload=/bin/kill -HUP $MAINPID Restart=always RestartSec=10