Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d08ee81f3 | |||
| 6975e18ed2 | |||
| 0b9419c6d2 |
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
Binary file not shown.
@@ -0,0 +1,186 @@
|
|||||||
|
# Prezenta App - Robust Dependency Management System
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
The app.py has been updated to include a comprehensive, self-contained dependency management system that automatically checks and installs required packages from a local repository. This makes the system completely offline-capable and resilient to network issues.
|
||||||
|
|
||||||
|
## Key Features
|
||||||
|
|
||||||
|
### 🔧 **Automatic Dependency Installation**
|
||||||
|
- **Self-contained**: No need for separate launcher scripts or shell scripts
|
||||||
|
- **Offline capability**: Installs packages from local `./Files/reposytory` directory
|
||||||
|
- **Smart detection**: Checks if packages are already installed before attempting installation
|
||||||
|
- **Fallback mechanisms**: Multiple installation methods (pip, apt, local wheels)
|
||||||
|
|
||||||
|
### 🛡️ **Robust Error Handling**
|
||||||
|
- **Network resilience**: Handles socket errors gracefully with file-based fallbacks
|
||||||
|
- **Import safety**: Safe import functions that don't crash the app
|
||||||
|
- **Graceful degradation**: App continues to work even if some optional features fail
|
||||||
|
- **Comprehensive logging**: All operations are logged for debugging
|
||||||
|
|
||||||
|
### 📦 **Supported Packages**
|
||||||
|
The system automatically manages these packages:
|
||||||
|
- `rdm6300` - RFID reader library (critical)
|
||||||
|
- `requests` - HTTP library (critical)
|
||||||
|
- `aiohttp` - Async HTTP library (optional)
|
||||||
|
- `flask` - Web server for command interface (optional)
|
||||||
|
- `gpiozero` - GPIO control (falls back to dummy if not available)
|
||||||
|
- All required dependencies (urllib3, certifi, charset_normalizer, etc.)
|
||||||
|
|
||||||
|
## How It Works
|
||||||
|
|
||||||
|
### 1. **Startup Dependency Check**
|
||||||
|
When the app starts, it:
|
||||||
|
1. Checks each required package using `importlib.util.find_spec()`
|
||||||
|
2. Identifies missing packages
|
||||||
|
3. Attempts installation from local wheel files in `./Files/reposytory`
|
||||||
|
4. Falls back to pip/apt if needed
|
||||||
|
5. Continues execution even if some packages fail to install
|
||||||
|
|
||||||
|
### 2. **Safe Import System**
|
||||||
|
```python
|
||||||
|
def safe_import(module_name, package_name=None):
|
||||||
|
"""Safely import a module with error handling"""
|
||||||
|
```
|
||||||
|
- Imports modules without crashing the app
|
||||||
|
- Returns None for missing modules
|
||||||
|
- Allows the app to adapt to available packages
|
||||||
|
|
||||||
|
### 3. **Network Error Resilience**
|
||||||
|
- Device hostname/IP saved to `./data/device_info.txt`
|
||||||
|
- Automatically loads from file when socket errors occur
|
||||||
|
- Never crashes due to network resolution issues
|
||||||
|
|
||||||
|
### 4. **Graceful Feature Degradation**
|
||||||
|
- **No Flask**: Command server is disabled with warning
|
||||||
|
- **No gpiozero**: LED functions become print statements
|
||||||
|
- **No aiohttp**: Falls back to synchronous requests
|
||||||
|
- **No network**: Uses cached device information
|
||||||
|
|
||||||
|
## Repository Structure
|
||||||
|
|
||||||
|
### Required Files in `./Files/reposytory/`:
|
||||||
|
```
|
||||||
|
├── rdm6300-0.1.1-py3-none-any.whl
|
||||||
|
├── requests-2.32.3-py3-none-any.whl
|
||||||
|
├── aiohttp-3.11.18-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
|
||||||
|
├── flask-*.whl (optional)
|
||||||
|
├── urllib3-2.3.0-py3-none-any.whl
|
||||||
|
├── certifi-2025.1.31-py3-none-any.whl
|
||||||
|
├── charset_normalizer-3.4.1-py3-none-any.whl
|
||||||
|
├── idna-3.10-py3-none-any.whl
|
||||||
|
├── multidict-6.4.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
|
||||||
|
├── aiosignal-1.3.2-py2.py3-none-any.whl
|
||||||
|
├── frozenlist-1.6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
|
||||||
|
├── attrs-25.3.0-py3-none-any.whl
|
||||||
|
├── yarl-1.20.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
|
||||||
|
├── aiohappyeyeballs-2.6.1-py3-none-any.whl
|
||||||
|
└── propcache-0.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
|
||||||
|
```
|
||||||
|
|
||||||
|
## Installation Process
|
||||||
|
|
||||||
|
### Automatic (Recommended)
|
||||||
|
Simply run the app - dependencies will be installed automatically:
|
||||||
|
```bash
|
||||||
|
cd /home/pi/Desktop/prezenta
|
||||||
|
python3 app.py
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manual Testing
|
||||||
|
Test the dependency system:
|
||||||
|
```bash
|
||||||
|
cd /home/pi/Desktop/prezenta
|
||||||
|
python3 test_dependencies.py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Folder Structure
|
||||||
|
|
||||||
|
The prezenta folder has been streamlined for maximum simplicity:
|
||||||
|
|
||||||
|
```
|
||||||
|
prezenta/
|
||||||
|
├── app.py # Main application (self-contained)
|
||||||
|
├── config.py # Configuration module
|
||||||
|
├── test_dependencies.py # Testing and validation script
|
||||||
|
├── README_DEPENDENCIES.md # This documentation
|
||||||
|
├── data/ # Application data
|
||||||
|
│ ├── device_info.txt # Network configuration cache (auto-created)
|
||||||
|
│ ├── idmasa.txt # Device identifier
|
||||||
|
│ └── tag.txt # Backup data
|
||||||
|
└── Files/ # Local package repository
|
||||||
|
└── reposytory/ # Wheel files for offline installation
|
||||||
|
├── rdm6300-*.whl
|
||||||
|
├── requests-*.whl
|
||||||
|
├── aiohttp-*.whl
|
||||||
|
└── ... (all dependencies)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Removed Files (No Longer Needed)
|
||||||
|
- ~~`launcher.py`~~ - App is now self-launching
|
||||||
|
- ~~`libraries.sh`~~ - Dependency installation integrated into app.py
|
||||||
|
- ~~`check_dependencies.py`~~ - Functionality moved to app.py
|
||||||
|
|
||||||
|
## Features Added
|
||||||
|
|
||||||
|
### 1. **Self-Installing Dependencies**
|
||||||
|
- Checks all required packages on startup
|
||||||
|
- Installs missing packages from local repository
|
||||||
|
- No external network dependencies for package installation
|
||||||
|
|
||||||
|
### 2. **Network Error Recovery**
|
||||||
|
- Handles `socket.gaierror` gracefully
|
||||||
|
- Saves working network configuration to file
|
||||||
|
- Loads from file when network issues occur
|
||||||
|
|
||||||
|
### 3. **Modular Feature Set**
|
||||||
|
- Core RFID functionality always works
|
||||||
|
- Optional features (web interface, LEDs) degrade gracefully
|
||||||
|
- Clear status messages for all operations
|
||||||
|
|
||||||
|
### 4. **Enhanced Logging**
|
||||||
|
- Dependency check results logged
|
||||||
|
- Installation attempts logged
|
||||||
|
- Network fallback operations logged
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Common Issues
|
||||||
|
|
||||||
|
1. **"Repository not found"**
|
||||||
|
- Ensure `./Files/reposytory` directory exists
|
||||||
|
- Check that wheel files are present
|
||||||
|
|
||||||
|
2. **"Permission denied during installation"**
|
||||||
|
- Script uses `--break-system-packages` flag
|
||||||
|
- May need to run with appropriate permissions
|
||||||
|
|
||||||
|
3. **"rdm6300 is required"**
|
||||||
|
- This is critical - app will exit if rdm6300 can't be installed
|
||||||
|
- Check that `rdm6300-0.1.1-py3-none-any.whl` exists in repository
|
||||||
|
|
||||||
|
4. **"Flask not available - Command server disabled"**
|
||||||
|
- Non-critical - RFID functionality continues to work
|
||||||
|
- Install Flask manually if remote command capability is needed
|
||||||
|
|
||||||
|
### Recovery Steps
|
||||||
|
|
||||||
|
1. **Check repository**: Ensure all wheel files are present
|
||||||
|
2. **Test installation**: Run `python3 test_dependencies.py`
|
||||||
|
3. **Manual install**: Install missing packages manually with pip
|
||||||
|
4. **Check logs**: Review console output for specific error messages
|
||||||
|
|
||||||
|
## Benefits
|
||||||
|
|
||||||
|
1. **Zero-configuration deployment**: Just copy files and run
|
||||||
|
2. **Offline operation**: No internet required after initial setup
|
||||||
|
3. **Fault tolerance**: Continues working even with partial failures
|
||||||
|
4. **Easy maintenance**: All dependencies managed automatically
|
||||||
|
5. **Clear diagnostics**: Detailed status reporting for troubleshooting
|
||||||
|
|
||||||
|
## Version History
|
||||||
|
|
||||||
|
- **v2.4**: Added robust dependency management and network error handling
|
||||||
|
- **v2.3**: Added remote command execution capabilities
|
||||||
|
- **v2.2**: Basic RFID and logging functionality
|
||||||
|
|
||||||
|
The system is now production-ready for deployment in environments with limited or no internet connectivity, providing maximum reliability and ease of deployment.
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
# Repository Updates Summary
|
||||||
|
|
||||||
|
## Date: August 14, 2025
|
||||||
|
|
||||||
|
### Changes Made
|
||||||
|
|
||||||
|
#### 1. App.py Version 2.7 - Path Detection Fix
|
||||||
|
**Problem Solved**: Auto-update functionality was failing on devices with case-sensitive file systems where the folder was named "Prezenta" (uppercase P) instead of "prezenta" (lowercase p).
|
||||||
|
|
||||||
|
**Changes Made**:
|
||||||
|
- Replaced hardcoded paths with dynamic path detection using `__file__`
|
||||||
|
- Auto-update now works regardless of folder case sensitivity
|
||||||
|
- Enhanced path resolution for Files/repository and system_packages directories
|
||||||
|
|
||||||
|
**Code Changes**:
|
||||||
|
```python
|
||||||
|
# OLD (hardcoded):
|
||||||
|
LOCAL_APP_PATH = "/home/pi/Desktop/prezenta/app.py"
|
||||||
|
LOCAL_REPO_PATH = "/home/pi/Desktop/prezenta/Files/reposytory"
|
||||||
|
|
||||||
|
# NEW (dynamic):
|
||||||
|
current_script_path = os.path.abspath(__file__)
|
||||||
|
local_base_dir = os.path.dirname(current_script_path)
|
||||||
|
LOCAL_APP_PATH = current_script_path
|
||||||
|
LOCAL_REPO_PATH = os.path.join(local_base_dir, "Files", "reposytory")
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. Server.py - Port 80 Communication Update
|
||||||
|
**Problem Solved**: Server was still trying to communicate with devices on port 5000 instead of port 80.
|
||||||
|
|
||||||
|
**Changes Made**:
|
||||||
|
- Updated all device communication endpoints to use port 80
|
||||||
|
- Fixed command execution, status checks, and auto-update requests
|
||||||
|
- Ensured consistent port usage across all server-device communications
|
||||||
|
|
||||||
|
**Updated Functions**:
|
||||||
|
- `execute_command_on_device()` - now uses port 80
|
||||||
|
- `get_device_status()` - now uses port 80
|
||||||
|
- `auto_update_devices()` - now uses port 80
|
||||||
|
|
||||||
|
#### 3. Repository Structure Updates
|
||||||
|
**Added New Files**:
|
||||||
|
- `README_DEPENDENCIES.md` - Comprehensive dependency documentation
|
||||||
|
- `setup_port_capability.sh` - Port 80 capability setup script
|
||||||
|
- `Files/system_packages/` - System package repository for offline installation
|
||||||
|
- Enhanced wheel file repository with latest packages
|
||||||
|
|
||||||
|
#### 4. Server Monitoring System (New Repository)
|
||||||
|
**Initialized**: `/home/pi/Desktop/Server_Monitorizare` as a git repository
|
||||||
|
|
||||||
|
**Features**:
|
||||||
|
- Complete device management dashboard
|
||||||
|
- Remote command execution on port 80
|
||||||
|
- Auto-update coordination
|
||||||
|
- Database reset functionality
|
||||||
|
- Server logs filtering and interface
|
||||||
|
- Comprehensive error handling
|
||||||
|
|
||||||
|
### Git Status
|
||||||
|
|
||||||
|
#### Prezenta Repository
|
||||||
|
- **Current Version**: 2.7
|
||||||
|
- **Latest Commit**: `6975e18 - v2.7: Fixed auto-update path detection for case-sensitive file systems`
|
||||||
|
- **Status**: All changes committed successfully
|
||||||
|
- **Remote**: Not configured (local repository)
|
||||||
|
|
||||||
|
#### Server_Monitorizare Repository
|
||||||
|
- **Status**: Newly initialized git repository
|
||||||
|
- **Latest Commit**: `42989aa - Initial server monitoring system with port 80 support`
|
||||||
|
- **Status**: All files committed successfully
|
||||||
|
- **Remote**: Not configured (local repository)
|
||||||
|
|
||||||
|
### Testing Results
|
||||||
|
- ✅ Dynamic path detection working correctly
|
||||||
|
- ✅ Port 80 communication updated in server
|
||||||
|
- ✅ Auto-update functionality fixed for case-sensitive systems
|
||||||
|
- ✅ Server monitoring system fully operational
|
||||||
|
|
||||||
|
### Next Steps
|
||||||
|
If you want to push to remote repositories:
|
||||||
|
1. Configure remote origins for both repositories
|
||||||
|
2. Push commits to remote branches
|
||||||
|
3. Set up CI/CD if needed
|
||||||
|
|
||||||
|
### File Locations
|
||||||
|
- Main App: `/home/pi/Desktop/prezenta/app.py` (v2.7)
|
||||||
|
- Server: `/home/pi/Desktop/Server_Monitorizare/server.py`
|
||||||
|
- Documentation: This summary and README_DEPENDENCIES.md
|
||||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
|||||||
|
RPI-ansible
|
||||||
|
127.0.1.1
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
notconfig
|
2_15051100_10
|
||||||
+36
-29
@@ -1,29 +1,36 @@
|
|||||||
2025-02-28 11:19:01,515 - INFO - Log file is not older than 10 days: log.txt
|
2025-08-14 11:42:43,861 - INFO - Log file is not older than 10 days: log.txt (n_masa: 2_15051100_10)
|
||||||
2025-02-28 11:19:01,535 - INFO - Internet connection check loaded
|
2025-08-14 11:42:43,871 - ERROR - Failed to send log to server: HTTPConnectionPool(host='rpi-ansible', port=80): Max retries exceeded with url: /logs (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xf5f1c5d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
|
||||||
2025-02-28 11:19:01,537 - INFO - Log file is not older than 10 days: log.txt
|
2025-08-14 11:42:43,879 - INFO - Internet connection check loaded (n_masa: 2_15051100_10)
|
||||||
2025-02-28 11:19:01,574 - INFO - Internet is up! Waiting 45 minutes.
|
2025-08-14 11:42:43,886 - ERROR - Failed to send log to server: HTTPConnectionPool(host='rpi-ansible', port=80): Max retries exceeded with url: /logs (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xf5f24370>: Failed to establish a new connection: [Errno 111] Connection refused'))
|
||||||
2025-02-28 11:19:01,575 - INFO - Reading backup data from tag.txt...
|
2025-08-14 11:42:43,888 - INFO - Log file is not older than 10 days: log.txt (n_masa: 2_15051100_10)
|
||||||
2025-02-28 11:19:01,580 - INFO - Posting backup data: https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/1/2025-02-28&11:13:59
|
2025-08-14 11:42:43,889 - INFO - [31m[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.[0m
|
||||||
2025-02-28 11:19:01,580 - INFO - Variabila Id Masa A fost initializata
|
* Running on all addresses (0.0.0.0)
|
||||||
2025-02-28 11:19:01,586 - INFO - notconfig
|
* Running on http://127.0.0.1:80
|
||||||
2025-02-28 11:19:02,443 - INFO - Request sent, awaiting response...
|
* Running on http://192.168.1.237:80
|
||||||
2025-02-28 11:19:02,445 - ERROR - An error occurred: 404 Client Error: Not Found for url: https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/1/2025-02-28&11:13:59
|
2025-08-14 11:42:43,890 - INFO - [33mPress CTRL+C to quit[0m
|
||||||
2025-02-28 11:19:02,448 - INFO - Backup data updated.
|
2025-08-14 11:42:43,899 - INFO - 127.0.0.1 - - [14/Aug/2025 11:42:43] "[33mPOST /logs HTTP/1.1[0m" 404 -
|
||||||
2025-02-28 11:19:11,167 - INFO - https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/1/2025-02-28&11:19:11
|
2025-08-14 11:42:43,900 - INFO - Variabila Id Masa A fost initializata
|
||||||
|
2025-08-14 11:42:43,900 - INFO - 2_15051100_10
|
||||||
2025-02-28 11:19:11,171 - INFO - Starting to post data...
|
2025-08-14 11:42:43,902 - ERROR - Failed to send log to server: 404 Client Error: NOT FOUND for url: http://rpi-ansible:80/logs
|
||||||
2025-02-28 11:19:11,176 - INFO - card inserted CardData(value=4028355, checksum=219, type=82, is_valid=True)
|
2025-08-14 11:42:53,906 - INFO - Internet is down. Rebooting WiFi. (n_masa: 2_15051100_10)
|
||||||
2025-02-28 11:19:11,176 - INFO - card removed CardData(value=4028355, checksum=219, type=82, is_valid=True)
|
2025-08-14 11:42:53,909 - INFO - 127.0.0.1 - - [14/Aug/2025 11:42:53] "[33mPOST /logs HTTP/1.1[0m" 404 -
|
||||||
2025-02-28 11:19:11,887 - INFO - Request sent, awaiting response...
|
2025-08-14 11:42:53,910 - ERROR - Failed to send log to server: 404 Client Error: NOT FOUND for url: http://rpi-ansible:80/logs
|
||||||
2025-02-28 11:19:11,891 - ERROR - An error occurred: 404 Client Error: Not Found for url: https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/1/2025-02-28&11:19:11
|
2025-08-14 15:46:13,021 - INFO - [31m[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.[0m
|
||||||
2025-02-28 11:19:11,892 - INFO - Value https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/1/2025-02-28&11:19:11
|
* Running on all addresses (0.0.0.0)
|
||||||
was saved to tag.txt
|
* Running on http://127.0.0.1:5000
|
||||||
2025-02-28 11:19:14,529 - INFO - https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/0/2025-02-28&11:19:14
|
* Running on http://192.168.1.237:5000
|
||||||
|
2025-08-14 15:46:13,022 - INFO - [33mPress CTRL+C to quit[0m
|
||||||
2025-02-28 11:19:14,531 - INFO - Starting to post data...
|
2025-08-14 15:46:15,010 - INFO - Log file is not older than 10 days: log.txt (n_masa: 2_15051100_10)
|
||||||
2025-02-28 11:19:14,533 - INFO - card removed CardData(value=4028355, checksum=219, type=82, is_valid=True)
|
2025-08-14 15:46:15,036 - INFO - Log successfully sent to server: Log file is not older than 10 days: log.txt
|
||||||
2025-02-28 11:19:14,536 - INFO - card removed CardData(value=4028355, checksum=219, type=82, is_valid=True)
|
2025-08-14 15:46:15,040 - INFO - Internet connection check loaded (n_masa: 2_15051100_10)
|
||||||
2025-02-28 11:19:15,169 - INFO - Request sent, awaiting response...
|
2025-08-14 15:46:15,071 - INFO - LED controls initialized (n_masa: 2_15051100_10)
|
||||||
2025-02-28 11:19:15,170 - ERROR - An error occurred: 404 Client Error: Not Found for url: https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/0/2025-02-28&11:19:14
|
2025-08-14 15:46:15,078 - INFO - Log successfully sent to server: Internet connection check loaded
|
||||||
2025-02-28 11:19:15,171 - INFO - Value https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/0/2025-02-28&11:19:14
|
2025-08-14 15:46:15,079 - INFO - Log file is not older than 10 days: log.txt (n_masa: 2_15051100_10)
|
||||||
was saved to tag.txt
|
2025-08-14 15:46:15,104 - INFO - Log successfully sent to server: LED controls initialized
|
||||||
|
2025-08-14 15:46:15,104 - INFO - Variabila Id Masa A fost initializata
|
||||||
|
2025-08-14 15:46:15,106 - INFO - Device name initialized: 2_15051100_10 (n_masa: 2_15051100_10)
|
||||||
|
2025-08-14 15:46:15,120 - INFO - Log successfully sent to server: Log file is not older than 10 days: log.txt
|
||||||
|
2025-08-14 15:46:15,144 - INFO - Log successfully sent to server: Device name initialized: 2_15051100_10
|
||||||
|
2025-08-14 15:46:15,145 - INFO - 2_15051100_10
|
||||||
|
2025-08-14 15:46:25,126 - INFO - Internet is down. Rebooting WiFi. (n_masa: 2_15051100_10)
|
||||||
|
2025-08-14 15:46:25,148 - INFO - Log successfully sent to server: Internet is down. Rebooting WiFi.
|
||||||
|
|||||||
+2
-6
@@ -1,6 +1,2 @@
|
|||||||
https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/1/2025-02-28&11:13:59
|
https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/7955261/1/2025-05-28&16:37:20
|
||||||
https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/0/2025-02-28&11:14:07
|
https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/7955261/0/2025-05-28&16:37:29
|
||||||
https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/1/2025-02-28&11:17:29
|
|
||||||
https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/0/2025-02-28&11:17:34
|
|
||||||
https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/1/2025-02-28&11:19:11
|
|
||||||
https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/notconfig/4028355/0/2025-02-28&11:19:14
|
|
||||||
|
|||||||
Executable
+31
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Grant the Python executable the capability to bind to privileged ports (like port 80)
|
||||||
|
# This is safer than running the entire application as root
|
||||||
|
|
||||||
|
echo "Setting up Python to bind to privileged ports..."
|
||||||
|
|
||||||
|
# Get the Python executable path and resolve symbolic links
|
||||||
|
PYTHON_PATH=$(which python3)
|
||||||
|
REAL_PYTHON_PATH=$(readlink -f "$PYTHON_PATH")
|
||||||
|
echo "Python path: $PYTHON_PATH"
|
||||||
|
echo "Real Python path: $REAL_PYTHON_PATH"
|
||||||
|
|
||||||
|
# Set the capability on the real executable
|
||||||
|
sudo setcap 'cap_net_bind_service=+ep' "$REAL_PYTHON_PATH"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "✓ Successfully granted port binding privileges to Python"
|
||||||
|
echo "Your Flask app can now bind to port 80 without running as root"
|
||||||
|
|
||||||
|
# Verify the capability was set
|
||||||
|
echo "Verifying capability:"
|
||||||
|
getcap "$REAL_PYTHON_PATH"
|
||||||
|
else
|
||||||
|
echo "✗ Failed to set capability"
|
||||||
|
echo "Make sure you have libcap2-bin installed: sudo apt install libcap2-bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Note: After setting this capability, you can change your Flask app to use port 80"
|
||||||
|
echo "Change the port from 5000 to 80 in your app.py file"
|
||||||
Reference in New Issue
Block a user