373 lines
8.3 KiB
Markdown
373 lines
8.3 KiB
Markdown
# Installation Module
|
|
|
|
## Übersicht
|
|
|
|
Das Installation Module bietet eine vollautomatische Master-Installation für das USB-SSD Management System. Es konfiguriert alle Abhängigkeiten, erstellt System-Services und richtet die komplette Infrastruktur für den produktiven Einsatz ein.
|
|
|
|
## Hauptkomponenten
|
|
|
|
### `install.sh`
|
|
**Zweck**: Master-Installation mit vollständiger System-Konfiguration
|
|
|
|
**Installationsschritte**:
|
|
- System-Abhängigkeiten installieren
|
|
- Scripts in System-Pfade kopieren
|
|
- Systemd-Services konfigurieren
|
|
- Udev-Rules einrichten
|
|
- Benutzer-Berechtigungen setzen
|
|
- Logging-Infrastruktur aufbauen
|
|
|
|
## Installation
|
|
|
|
### Schnell-Installation
|
|
```bash
|
|
# Repository klonen
|
|
git clone https://git.gitcover.de/KMU/usb-ssd.git
|
|
cd usb-ssd
|
|
|
|
# Master-Installation ausführen
|
|
sudo ./scripts/installation/install.sh
|
|
```
|
|
|
|
### Erweiterte Installation
|
|
```bash
|
|
# Installation mit Custom-Konfiguration
|
|
sudo ./scripts/installation/install.sh --config /path/to/config.conf
|
|
|
|
# Installation ohne Systemd-Services
|
|
sudo ./scripts/installation/install.sh --no-systemd
|
|
|
|
# Installation mit Debug-Modus
|
|
sudo ./scripts/installation/install.sh --debug --verbose
|
|
```
|
|
|
|
### Interaktive Installation
|
|
```bash
|
|
# Schritt-für-Schritt Installation mit Benutzer-Eingaben
|
|
sudo ./scripts/installation/install.sh --interactive
|
|
|
|
# Nur bestimmte Komponenten installieren
|
|
sudo ./scripts/installation/install.sh --components "detection,management"
|
|
```
|
|
|
|
## Installationsoptionen
|
|
|
|
### Standard-Installation
|
|
```bash
|
|
# Vollständige Installation (empfohlen)
|
|
sudo ./install.sh
|
|
|
|
# Installiert:
|
|
# - Alle System-Abhängigkeiten
|
|
# - Scripts nach /usr/local/bin/
|
|
# - Systemd-Services
|
|
# - Udev-Rules
|
|
# - Log-Rotation
|
|
# - Bash-Completion
|
|
```
|
|
|
|
### Custom-Installation
|
|
```bash
|
|
# Spezifische Installationspfade
|
|
sudo ./install.sh --prefix /opt/ssd-tools
|
|
|
|
# Custom-Konfiguration
|
|
sudo ./install.sh --config-dir /etc/ssd-management
|
|
|
|
# Benutzer-spezifische Installation
|
|
./install.sh --user-install
|
|
```
|
|
|
|
### Komponenten-basierte Installation
|
|
```bash
|
|
# Nur Detection-Module
|
|
sudo ./install.sh --component detection
|
|
|
|
# Nur Management-Module
|
|
sudo ./install.sh --component management
|
|
|
|
# Nur Testing-Module
|
|
sudo ./install.sh --component testing
|
|
|
|
# Mehrere Komponenten
|
|
sudo ./install.sh --components "detection,management,testing"
|
|
```
|
|
|
|
## System-Abhängigkeiten
|
|
|
|
### Automatisch installierte Packages
|
|
|
|
#### Ubuntu/Debian
|
|
```bash
|
|
# Core-Packages
|
|
ntfs-3g # NTFS-Dateisystem Support
|
|
util-linux # Mount/Unmount Utilities
|
|
parted # Partitionstabellen-Management
|
|
bc # Berechnungen in Scripts
|
|
eject # Hardware-Eject Funktionalität
|
|
|
|
# Optional-Packages
|
|
smartmontools # SSD-Health Monitoring
|
|
hdparm # Hardware-Parameter Tuning
|
|
fio # Performance-Testing
|
|
samba-common # SMB-Integration
|
|
```
|
|
|
|
#### CentOS/RHEL
|
|
```bash
|
|
# Core-Packages
|
|
ntfs-3g
|
|
util-linux
|
|
parted
|
|
bc
|
|
eject
|
|
|
|
# EPEL-Repository für zusätzliche Tools
|
|
sudo yum install epel-release
|
|
```
|
|
|
|
### Manuelle Abhängigkeits-Installation
|
|
```bash
|
|
# Ubuntu/Debian
|
|
sudo apt update
|
|
sudo apt install ntfs-3g util-linux parted bc eject smartmontools hdparm fio
|
|
|
|
# CentOS/RHEL
|
|
sudo yum install ntfs-3g util-linux parted bc eject smartmontools hdparm fio
|
|
|
|
# Arch Linux
|
|
sudo pacman -S ntfs-3g util-linux parted bc eject smartmontools hdparm fio
|
|
```
|
|
|
|
## Systemd-Integration
|
|
|
|
### Installierte Services
|
|
|
|
#### `ssd-detection.service`
|
|
```ini
|
|
[Unit]
|
|
Description=USB-C SSD Detection Service
|
|
After=local-fs.target
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart=/usr/local/bin/ssd-detect.sh --monitor
|
|
Restart=on-failure
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
```
|
|
|
|
#### `ssd-automount.service`
|
|
```ini
|
|
[Unit]
|
|
Description=Automatic SSD Mounting
|
|
After=ssd-detection.service
|
|
|
|
[Service]
|
|
Type=forking
|
|
ExecStart=/usr/local/bin/ssd-mount-manager.sh --auto-mount
|
|
ExecStop=/usr/local/bin/ssd-safe-eject.sh --all
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
```
|
|
|
|
### Service-Management
|
|
```bash
|
|
# Services aktivieren
|
|
sudo systemctl enable ssd-detection.service
|
|
sudo systemctl enable ssd-automount.service
|
|
|
|
# Services starten
|
|
sudo systemctl start ssd-detection.service
|
|
sudo systemctl start ssd-automount.service
|
|
|
|
# Status prüfen
|
|
sudo systemctl status ssd-detection.service
|
|
```
|
|
|
|
## Udev-Rules
|
|
|
|
### Automatische USB-Erkennung
|
|
```bash
|
|
# /etc/udev/rules.d/99-ssd-automount.rules
|
|
SUBSYSTEM=="block", ATTRS{removable}=="1", ACTION=="add", RUN+="/usr/local/bin/ssd-detect.sh --device %k"
|
|
SUBSYSTEM=="block", ATTRS{removable}=="1", ACTION=="remove", RUN+="/usr/local/bin/ssd-safe-eject.sh --device %k"
|
|
```
|
|
|
|
### Udev-Rules aktivieren
|
|
```bash
|
|
# Rules neu laden
|
|
sudo udevadm control --reload-rules
|
|
sudo udevadm trigger
|
|
|
|
# Test der Rules
|
|
sudo udevadm test /sys/block/sdb
|
|
```
|
|
|
|
## Benutzer-Berechtigungen
|
|
|
|
### Gruppe-Konfiguration
|
|
```bash
|
|
# SSD-Management Gruppe erstellen
|
|
sudo groupadd ssd-users
|
|
|
|
# Benutzer zur Gruppe hinzufügen
|
|
sudo usermod -a -G ssd-users $USER
|
|
|
|
# Disk-Gruppe für Hardware-Zugriff
|
|
sudo usermod -a -G disk $USER
|
|
```
|
|
|
|
### Sudo-Konfiguration
|
|
```bash
|
|
# /etc/sudoers.d/ssd-management
|
|
%ssd-users ALL=(ALL) NOPASSWD: /usr/local/bin/ssd-mount-manager.sh
|
|
%ssd-users ALL=(ALL) NOPASSWD: /usr/local/bin/ssd-safe-eject.sh
|
|
%ssd-users ALL=(ALL) NOPASSWD: /usr/local/bin/ssd-detect.sh
|
|
```
|
|
|
|
## Logging-Konfiguration
|
|
|
|
### Log-Rotation
|
|
```bash
|
|
# /etc/logrotate.d/ssd-management
|
|
/var/log/ssd-*.log {
|
|
daily
|
|
rotate 30
|
|
compress
|
|
delaycompress
|
|
missingok
|
|
notifempty
|
|
create 644 root root
|
|
}
|
|
```
|
|
|
|
### Syslog-Integration
|
|
```bash
|
|
# /etc/rsyslog.d/50-ssd-management.conf
|
|
:programname, isequal, "ssd-detect" /var/log/ssd-detection.log
|
|
:programname, isequal, "ssd-mount" /var/log/ssd-management.log
|
|
:programname, isequal, "ssd-test" /var/log/ssd-testing.log
|
|
& stop
|
|
```
|
|
|
|
## Bash-Completion
|
|
|
|
### Auto-Completion aktivieren
|
|
```bash
|
|
# /etc/bash_completion.d/ssd-tools
|
|
_ssd_detect() {
|
|
local cur prev opts
|
|
COMPREPLY=()
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
opts="--verbose --ntfs-only --device --output --monitor --debug"
|
|
|
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
|
return 0
|
|
}
|
|
complete -F _ssd_detect ssd-detect.sh
|
|
```
|
|
|
|
## Deinstallation
|
|
|
|
### Vollständige Deinstallation
|
|
```bash
|
|
# Deinstallations-Script ausführen
|
|
sudo ./scripts/installation/uninstall.sh
|
|
|
|
# Manuelle Deinstallation
|
|
sudo systemctl stop ssd-detection.service ssd-automount.service
|
|
sudo systemctl disable ssd-detection.service ssd-automount.service
|
|
sudo rm /etc/systemd/system/ssd-*.service
|
|
sudo rm /usr/local/bin/ssd-*
|
|
sudo rm /etc/udev/rules.d/99-ssd-automount.rules
|
|
```
|
|
|
|
### Konfiguration beibehalten
|
|
```bash
|
|
# Nur Scripts entfernen, Konfiguration behalten
|
|
sudo ./scripts/installation/uninstall.sh --keep-config
|
|
```
|
|
|
|
## Upgrade-Prozess
|
|
|
|
### In-Place Upgrade
|
|
```bash
|
|
# Repository aktualisieren
|
|
git pull origin main
|
|
|
|
# Upgrade ausführen
|
|
sudo ./scripts/installation/install.sh --upgrade
|
|
|
|
# Services neu starten
|
|
sudo systemctl restart ssd-detection.service
|
|
```
|
|
|
|
### Backup vor Upgrade
|
|
```bash
|
|
# Konfiguration sichern
|
|
sudo cp -r /etc/ssd-management /etc/ssd-management.backup
|
|
|
|
# Scripts sichern
|
|
sudo cp /usr/local/bin/ssd-* /tmp/ssd-backup/
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Installations-Probleme
|
|
```bash
|
|
# Installation mit Debug-Output
|
|
sudo ./install.sh --debug --verbose
|
|
|
|
# Abhängigkeits-Probleme prüfen
|
|
./install.sh --check-dependencies
|
|
|
|
# Berechtigungs-Probleme
|
|
sudo ./install.sh --fix-permissions
|
|
```
|
|
|
|
### Häufige Probleme
|
|
1. **Permission denied**: Installation mit `sudo` ausführen
|
|
2. **Package not found**: Repository-Updates durchführen
|
|
3. **Service failed**: Systemd-Logs prüfen (`journalctl -u ssd-detection.service`)
|
|
|
|
### Diagnose-Tools
|
|
```bash
|
|
# System-Diagnose
|
|
./install.sh --diagnose
|
|
|
|
# Installations-Status prüfen
|
|
./install.sh --status
|
|
|
|
# Konfiguration validieren
|
|
./install.sh --validate
|
|
```
|
|
|
|
## Best Practices
|
|
|
|
### Produktionsumgebung
|
|
1. **Vollständige Installation** mit allen Komponenten
|
|
2. **Systemd-Services aktivieren** für automatisches Management
|
|
3. **Log-Rotation konfigurieren** für Langzeit-Betrieb
|
|
4. **Monitoring einrichten** für Service-Überwachung
|
|
5. **Backup-Strategie** für Konfigurationsdateien
|
|
|
|
### Entwicklungsumgebung
|
|
1. **Komponenten-basierte Installation** für spezifische Tests
|
|
2. **Debug-Modus aktivieren** für Entwicklung
|
|
3. **User-Installation** für isolierte Tests
|
|
4. **Häufige Upgrades** für aktuelle Features
|
|
|
|
## Changelog
|
|
|
|
### Version 0.1.0
|
|
- Master-Installation Script
|
|
- Systemd-Service Integration
|
|
- Udev-Rules Konfiguration
|
|
- Benutzer-Berechtigungen Setup
|
|
- Logging-Infrastruktur
|
|
- Bash-Completion Support
|