Interaktives install.sh Script hinzugefügt

- Modulares Installationsscript für alle Kategorien
- Interaktive Auswahl mit farbigem Output
- Automatische Backups und Symlink-Management
- LUSER-Setup für go-Tool integriert
- Erweiterbar für neue Tools und Kategorien
- Repository-URL auf ljp aktualisiert

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
h0tznpl0tz
2025-09-10 13:09:37 +02:00
co-authored by Claude
parent d0634bb442
commit ad037e105a
2 changed files with 291 additions and 2 deletions
+34 -2
View File
@@ -12,6 +12,7 @@ Hier sammeln wir kleine Helfer für Log-Analysen, Automatisierungen und typische
- [Connect Tools](#connect-tools)
- [Legacy Snippets](#legacy-snippets)
- [WH20 Snippets](#wh20-snippets)
- [Installation](#installation)
- [How-To: Neues Skript anlegen](#how-to-neues-skript-anlegen)
- [Lizenz / Sichtbarkeit](#lizenz--sichtbarkeit)
@@ -67,6 +68,34 @@ Weitere Snippets für Legacy kommen hier dazu.
---
## Installation
Nach dem Klonen des Repositories steht ein interaktives Installationsscript zur Verfügung:
```bash
# Repository klonen
git clone http://vps.dominikus.one:3000/ljp/esn-support-bash-snippets.git
cd esn-support-bash-snippets
# Installationsscript ausführen
./install.sh
```
**Features des Installers:**
- **Interaktive Auswahl**: Kategorien und einzelne Tools wählbar
- **Automatische Backups**: Vorhandene Dateien werden gesichert
- **Symlink-Management**: Tools werden in ~/bin verlinkt
- **LUSER-Setup**: Automatische Konfiguration für go-Tool
- **Modular erweiterbar**: Neue Tools einfach hinzufügbar
**Verfügbare Kategorien:**
- **Bash-Profile**: .bashrc Optimierungen und modulare Konfiguration
- **Connect Tools**: SSH-Shortcuts (go-Tool) mit Kerberos-Setup
- **Legacy Tools**: checkms, quicknav für Legacy-Infrastruktur
- **WH20 Tools**: Platzhalter für zukünftige WH20-Tools
---
## How-To: Neues Skript anlegen
Um ein neues Bash-Skript in dieses Repository aufzunehmen, bitte folgende Schritte:
@@ -114,11 +143,14 @@ Um ein neues Bash-Skript in dieses Repository aufzunehmen, bitte folgende Schrit
- [`legacy/README.md`](./legacy/README.md)
- [`wh20/README.md`](./wh20/README.md)
5. **Commit & Push**
5. **Install-Script erweitern**
Neue Tools zum `install.sh` hinzufügen für automatische Installation
6. **Commit & Push**
Änderungen ins Repo übernehmen:
```bash
git add .
git commit -m "Add <scriptname> to <legacy|wh20>"
git commit -m "Add <scriptname> to <category>"
git push
```
Executable
+257
View File
@@ -0,0 +1,257 @@
#!/usr/bin/env bash
# install.sh - Installationsscript für easyname Support Bash-Snippets
# Modular erweiterbar für neue Tools und Kategorien
set -euo pipefail
# Farben für Output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
NC='\033[0m' # No Color
# Script-Verzeichnis ermitteln
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Logging-Funktionen
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Hilfsfunktionen
backup_file() {
local file="$1"
if [[ -f "$file" ]]; then
local backup="${file}.backup.$(date +%Y%m%d_%H%M%S)"
cp "$file" "$backup"
log_info "Backup erstellt: $backup"
fi
}
create_symlink() {
local src="$1"
local dest="$2"
local name="$3"
if [[ -L "$dest" ]]; then
log_warning "$name bereits als Symlink vorhanden, überspringe"
return 0
fi
if [[ -f "$dest" ]]; then
backup_file "$dest"
fi
ln -sf "$src" "$dest"
log_success "$name symlink erstellt: $dest -> $src"
}
make_executable() {
local file="$1"
chmod +x "$file"
log_info "$file ausführbar gemacht"
}
# Installation: Bash-Profile
install_bashprofiles() {
log_info "=== Bash-Profile Installation ==="
echo -e "\n${PURPLE}Verfügbare Profile:${NC}"
echo "1) h0tznpl0tz (pl) - Optimiertes Basis-Profil"
echo "0) Überspringen"
read -p "Profil auswählen [0-1]: " profile_choice
case "$profile_choice" in
1)
log_info "Installiere h0tznpl0tz Bash-Profil..."
backup_file "$HOME/.bashrc"
cp "$SCRIPT_DIR/bashprofiles/pl/.bashrc" "$HOME/.bashrc"
# Modulare Dateien erstellen falls nicht vorhanden
[[ ! -f "$HOME/.bash_aliases" ]] && touch "$HOME/.bash_aliases"
[[ ! -f "$HOME/.bash_env" ]] && touch "$HOME/.bash_env"
[[ ! -f "$HOME/.bash_paths" ]] && touch "$HOME/.bash_paths"
log_success "Bash-Profil installiert"
log_info "Hinweis: Setze LUSER in ~/.bash_env für go-Tool"
;;
0)
log_info "Bash-Profile übersprungen"
;;
*)
log_error "Ungültige Auswahl"
;;
esac
}
# Installation: Connect Tools
install_connect() {
log_info "=== Connect Tools Installation ==="
echo -e "\n${PURPLE}Verfügbare Tools:${NC}"
echo "1) go - SSH-Shortcuts für easyname Server"
echo "0) Überspringen"
read -p "Tools auswählen [0-1]: " connect_choice
case "$connect_choice" in
1)
log_info "Installiere go SSH-Shortcut Tool..."
# Prüfe LUSER Variable
if [[ -z "${LUSER:-}" ]]; then
log_warning "LUSER Umgebungsvariable nicht gesetzt"
read -p "LUSER eingeben (für Kerberos): " user_input
if [[ -n "$user_input" ]]; then
echo "export LUSER=\"$user_input\"" >> "$HOME/.bash_env"
export LUSER="$user_input"
log_success "LUSER in ~/.bash_env gesetzt"
fi
fi
# Script installieren
local go_script="$SCRIPT_DIR/connect/go/go.sh"
make_executable "$go_script"
# Symlink in ~/bin oder PATH erstellen
if [[ -d "$HOME/bin" ]]; then
create_symlink "$go_script" "$HOME/bin/go" "go-Tool"
else
log_info "~/bin existiert nicht. Erstelle Verzeichnis..."
mkdir -p "$HOME/bin"
create_symlink "$go_script" "$HOME/bin/go" "go-Tool"
log_info "Füge ~/bin zu PATH hinzu (in ~/.bash_paths)"
echo 'export PATH="$HOME/bin:$PATH"' >> "$HOME/.bash_paths"
fi
log_success "go-Tool installiert"
;;
0)
log_info "Connect Tools übersprungen"
;;
*)
log_error "Ungültige Auswahl"
;;
esac
}
# Installation: Legacy Tools
install_legacy() {
log_info "=== Legacy Tools Installation ==="
echo -e "\n${PURPLE}Verfügbare Tools:${NC}"
echo "1) checkms - MS-Fehlercode Analyse"
echo "2) quicknav - Bash-Funktion für schnelle Navigation"
echo "3) Alle Legacy Tools"
echo "0) Überspringen"
read -p "Tools auswählen [0-3]: " legacy_choice
case "$legacy_choice" in
1|3)
log_info "Installiere checkms..."
local checkms_script="$SCRIPT_DIR/legacy/checkms/checkms.sh"
make_executable "$checkms_script"
if [[ -d "$HOME/bin" ]]; then
create_symlink "$checkms_script" "$HOME/bin/checkms" "checkms"
else
mkdir -p "$HOME/bin"
create_symlink "$checkms_script" "$HOME/bin/checkms" "checkms"
fi
log_success "checkms installiert"
;;&
2|3)
log_info "Installiere quicknav..."
local quicknav_func="$SCRIPT_DIR/legacy/quicknav/quicknav.sh"
log_warning "quicknav ist eine Bash-Funktion und muss manuell in .bashrc eingebunden werden"
log_info "Füge folgende Zeile zu ~/.bashrc hinzu:"
echo -e "${YELLOW}source \"$quicknav_func\"${NC}"
;;&
0)
log_info "Legacy Tools übersprungen"
;;
*)
log_error "Ungültige Auswahl"
;;
esac
}
# Installation: WH20 Tools (Platzhalter für zukünftige Tools)
install_wh20() {
log_info "=== WH20 Tools Installation ==="
log_info "Noch keine WH20 Tools verfügbar"
}
# Hauptmenü
show_menu() {
echo -e "\n${GREEN}=== easyname Support Bash-Snippets Installer ===${NC}"
echo -e "${BLUE}Verfügbare Installationskategorien:${NC}\n"
echo "1) Bash-Profile - Optimierte .bashrc Konfigurationen"
echo "2) Connect Tools - SSH-Shortcuts und Verbindungstools"
echo "3) Legacy Tools - Tools für Legacy-Infrastruktur"
echo "4) WH20 Tools - Tools für WH20-Infrastruktur"
echo "5) Alles installieren"
echo "0) Beenden"
echo ""
}
# Hauptinstallation
main() {
log_info "Installation gestartet in: $SCRIPT_DIR"
# Prüfe Abhängigkeiten
if ! command -v git >/dev/null 2>&1; then
log_error "git ist erforderlich aber nicht installiert"
exit 1
fi
while true; do
show_menu
read -p "Auswahl treffen [0-5]: " choice
case "$choice" in
1) install_bashprofiles ;;
2) install_connect ;;
3) install_legacy ;;
4) install_wh20 ;;
5)
install_bashprofiles
install_connect
install_legacy
install_wh20
;;
0)
log_success "Installation beendet"
echo -e "\n${YELLOW}Hinweis: Starte eine neue Shell oder führe 'source ~/.bashrc' aus${NC}"
exit 0
;;
*)
log_error "Ungültige Auswahl"
;;
esac
echo -e "\n${BLUE}Drücke Enter für Hauptmenü...${NC}"
read -r
done
}
# Script starten
main "$@"