The Crankshaft Management Tool (CSMT) is a comprehensive Python-based system management utility designed for OpenAuto systems. It replaces the original bash-based crankshaft script with a modular, maintainable, and extensible Python application.
✅ Status: Complete Rewrite Finished
- ✅ Modular Python architecture implemented
- ✅ All subsystem modules completed
- ✅ Cross-platform compatibility (Windows & Linux)
- ✅ Full CLI with subcommands
- ✅ Documentation and testing complete
🔗 See also: Windows Notes for Windows-specific information.
- Installation
- Quick Start
- Command Reference
- Architecture
- Module Documentation
- Configuration
- Development
- Troubleshooting
- Python 3.7 or higher
- Required Python packages (see requirements.txt)
- Root access for system operations
- Raspberry Pi or compatible system for hardware-specific features
- Clone or copy the CSMT directory to your system
- Install dependencies:
pip3 install -r requirements.txt
- Make the script executable:
chmod +x csmt/crankshaft.py
- Optionally, create a symlink for system-wide access:
sudo ln -s /path/to/csmt/crankshaft.py /usr/local/bin/crankshaft
# Show help
./crankshaft.py --help
# Check system information
./crankshaft.py system info
# Control brightness
./crankshaft.py brightness get
./crankshaft.py brightness set 128
# Manage audio
./crankshaft.py audio volume 75
./crankshaft.py audio devices
# System operations
./crankshaft.py system reboot
./crankshaft.py system shutdown
# Bluetooth management
./crankshaft.py bluetooth scan
./crankshaft.py bluetooth devices
-
System Monitoring:
./crankshaft.py misc diagnostics ./crankshaft.py system info ./crankshaft.py filesystem usage
-
Audio Setup:
./crankshaft.py audio devices ./crankshaft.py audio volume 50 ./crankshaft.py audio test
-
Display Configuration:
./crankshaft.py display info ./crankshaft.py display resolution 1920 1080 ./crankshaft.py display rotate 90
-
Bluetooth Setup:
./crankshaft.py bluetooth enable ./crankshaft.py bluetooth scan ./crankshaft.py bluetooth pair AA:BB:CC:DD:EE:FF
--verbose, -v
: Enable verbose output--quiet, -q
: Suppress banner and non-essential output--version
: Show version information
brightness get
: Show current brightness levelbrightness set <level>
: Set brightness (0-255)brightness up [--step N]
: Increase brightnessbrightness down [--step N]
: Decrease brightnessbrightness auto <enable>
: Enable/disable auto brightness
audio devices
: List available audio devicesaudio info
: Show audio system informationaudio volume [level]
: Get/set volume (0-100)audio mute
: Mute audioaudio unmute
: Unmute audioaudio output <device>
: Set audio output deviceaudio bluetooth <enable|disable>
: Control Bluetooth audioaudio test
: Test audio output
system info
: Show system informationsystem reboot [--delay N]
: Reboot systemsystem shutdown [--delay N]
: Shutdown systemsystem service <name> <action>
: Manage servicessystem processes [--filter NAME]
: List processessystem kill <pid> [--force]
: Kill process
bluetooth enable
: Enable Bluetoothbluetooth disable
: Disable Bluetoothbluetooth info
: Show Bluetooth informationbluetooth scan [--duration N]
: Scan for devicesbluetooth devices
: List paired devicesbluetooth pair <address>
: Pair with devicebluetooth unpair <address>
: Unpair devicebluetooth connect <address>
: Connect to devicebluetooth disconnect <address>
: Disconnect from devicebluetooth trust <address>
: Trust devicebluetooth untrust <address>
: Untrust device
display info
: Show display informationdisplay resolution [width height]
: Get/set resolutiondisplay rotate [degrees]
: Get/set rotation (0,90,180,270)display overscan [options]
: Control overscandisplay test
: Test display output
filesystem usage [path]
: Show disk usagefilesystem mounts
: Show mounted filesystemsfilesystem info
: Show filesystem informationfilesystem mount <device> <mountpoint>
: Mount filesystemfilesystem unmount <mountpoint>
: Unmount filesystemfilesystem readonly [enable|disable]
: Control read-only rootfilesystem check <device> [--fix]
: Check filesystemfilesystem clean
: Clean temporary files
update check [system|openauto]
: Check for updatesupdate system
: Update system packagesupdate openauto
: Update OpenAutoupdate install <package>
: Install packageupdate remove <package>
: Remove packageupdate clean
: Clean package cacheupdate packages
: List installed packagesupdate backup [--path DIR]
: Create system backup
misc hardware
: Show hardware informationmisc network
: Show network statusmisc hostname [name]
: Get/set hostnamemisc logs [--service NAME]
: Show system logsmisc monitor [--duration N]
: Monitor system resourcesmisc diagnostics
: Run system diagnostics
csmt/
├── crankshaft.py # Main CLI entry point
├── csmt/ # Main package
│ ├── __init__.py # Package initialization
│ ├── core.py # Core manager
│ ├── modules/ # Subsystem modules
│ │ ├── __init__.py
│ │ ├── audio.py # Audio management
│ │ ├── brightness.py # Brightness control
│ │ ├── bluetooth.py # Bluetooth management
│ │ ├── display.py # Display configuration
│ │ ├── filesystem.py # Filesystem operations
│ │ ├── misc.py # Miscellaneous utilities
│ │ ├── system.py # System management
│ │ └── update.py # Update management
│ └── utils/ # Utility modules
│ ├── __init__.py
│ ├── config.py # Configuration management
│ ├── display.py # Output formatting
│ ├── exceptions.py # Custom exceptions
│ └── logger.py # Logging setup
└── docs/ # Documentation
├── README.md # This file
├── ARCHITECTURE.md # Detailed architecture
├── API.md # API documentation
└── EXAMPLES.md # Usage examples
- Modularity: Each subsystem is implemented as a separate module
- Extensibility: Easy to add new commands and features
- Error Handling: Comprehensive error handling and logging
- Configuration: Centralized configuration management
- Testing: Designed for easy unit testing
- Documentation: Well-documented code and APIs
- CLI Parser (
crankshaft.py
): Command-line interface and argument parsing - Core Manager (
core.py
): Central coordinator for all operations - Subsystem Modules (
modules/
): Individual feature implementations - Utilities (
utils/
): Common utilities and helpers
Handles audio device management, volume control, and audio configuration.
Key Features:
- Audio device detection and listing
- Volume control and muting
- Audio output device selection
- Bluetooth audio support
- Audio testing capabilities
Manages display brightness control and auto-brightness features.
Key Features:
- Current brightness detection
- Brightness level adjustment
- Auto-brightness configuration
- Brightness stepping (up/down)
Comprehensive Bluetooth device management.
Key Features:
- Bluetooth controller management
- Device scanning and discovery
- Pairing and unpairing
- Connection management
- Device trust settings
Display configuration and management.
Key Features:
- Resolution detection and setting
- Display rotation control
- Overscan configuration
- Display testing
Filesystem operations and management.
Key Features:
- Disk usage monitoring
- Mount point management
- Read-only filesystem control
- Filesystem checking and repair
- Temporary file cleanup
Core system operations and monitoring.
Key Features:
- System information reporting
- Process management
- Service control
- System reboot/shutdown
- Resource monitoring
Package and system update management.
Key Features:
- Update checking
- Package installation/removal
- System updates
- Backup creation
- Package cache management
Miscellaneous utilities and diagnostics.
Key Features:
- Hardware information
- Network status
- System diagnostics
- Log file access
- Resource monitoring
The tool manages several configuration files:
- Boot Configuration (
/boot/config.txt
): Raspberry Pi boot settings - Environment Configuration: System environment variables
- Brightness Configuration: Saved brightness levels
The ConfigManager
class provides centralized configuration handling:
- Read/write boot configuration
- Environment variable management
- Configuration validation
- Backup and restore capabilities
- Create/Extend Module: Add functionality to appropriate module in
modules/
- Update CLI: Add command parser in
crankshaft.py
- Update Core: Add command routing in
core.py
- Add Tests: Create unit tests for new functionality
- Update Documentation: Update this README and module docs
- Follow PEP 8 Python style guidelines
- Use type hints where appropriate
- Include comprehensive docstrings
- Handle errors gracefully
- Log important operations
# Run unit tests
python -m pytest tests/
# Run specific module tests
python -m pytest tests/test_audio.py
# Run with coverage
python -m pytest --cov=csmt tests/
-
Permission Denied:
- Ensure script is run with appropriate privileges
- Use
sudo
for system operations
-
Module Import Errors:
- Check Python path configuration
- Verify all dependencies are installed
-
Hardware-Specific Features:
- Some features require specific hardware (Raspberry Pi)
- Check system compatibility
Use verbose mode for detailed output:
./crankshaft.py --verbose <command>
Check logs for error details:
./crankshaft.py misc logs --service crankshaft
- Check this documentation
- Use built-in help:
./crankshaft.py --help
- Check specific command help:
./crankshaft.py <command> --help
- Review log files for error details
- v2.5.0: Initial Python rewrite
- Modular architecture
- Comprehensive command set
- Improved error handling
- Enhanced logging
GPL-3.0 License - See LICENSE file for details.