sync_rsync zur ordner sync. erweiter
This commit is contained in:
parent
3b3f9075f6
commit
3319112e44
4 changed files with 110 additions and 57 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
*.log
|
*.log
|
||||||
.env
|
.env
|
||||||
|
sync.conf
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
|
||||||
57
find.sh
57
find.sh
|
|
@ -1,69 +1,56 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Robustere Ermittlung des Skript-Verzeichnisses
|
# Pfad ermitteln
|
||||||
SCRIPT_PATH=$(readlink -f "$0")
|
SCRIPT_PATH=$(readlink -f "$0")
|
||||||
BASE_DIR=$(dirname "$SCRIPT_PATH")
|
BASE_DIR=$(dirname "$SCRIPT_PATH")
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
# 1. Tags sammeln und zählen
|
# 1. Tags sammeln (optimiert)
|
||||||
# Wir extrahieren die Tags, sortieren sie und lassen 'uniq -c' die Vorkommen zählen
|
# Wir filtern hier noch aggressiver nach sauberen Text-Tags
|
||||||
tag_counts=$(grep -rhioE "(#\w+|Tags:.*)" "$BASE_DIR" --include="README.md" 2>/dev/null | \
|
tag_counts=$(grep -rhioE "(#\w+|Tags:.*)" "$BASE_DIR" --include="README.md" 2>/dev/null | \
|
||||||
sed 's/Tags://g' | tr ',' '\n' | tr -d ' ' | sort | uniq -c | sort -rn)
|
sed 's/Tags://g' | tr ',' '\n' | tr -d '\r' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | \
|
||||||
|
grep -v '^$' | sort | uniq -c | sort -rn)
|
||||||
|
|
||||||
if [ -z "$tag_counts" ]; then
|
if [ -z "$tag_counts" ]; then
|
||||||
zenity --error --title="Fehler" --text="Keine Tags gefunden.\nSuche in: $BASE_DIR"
|
zenity --error --title="Fehler" --text="Keine Tags gefunden in:\n$BASE_DIR"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2. Formatierung für Zenity (Anzahl und Tag trennen)
|
# 2. Anzeige-Liste erstellen
|
||||||
# Wir wandeln die Ausgabe "5 #Weihnachten" in eine Liste um, die Zenity versteht
|
zenity_list=$(echo "$tag_counts" | awk '{count=$1; $1=""; print $0 " (" count ")"}' | sed 's/^[[:space:]]*//')
|
||||||
zenity_list=$(echo "$tag_counts" | awk '{print $2 " (" $1 ")"}')
|
|
||||||
|
|
||||||
# 3. Grafische Auswahl des Tags
|
# 3. Auswahl
|
||||||
selected_item=$(echo "$zenity_list" | zenity --list \
|
selected_item=$(echo "$zenity_list" | zenity --list \
|
||||||
--title="Projekt-Tag-Suche" \
|
--title="Projekt-Tag-Suche" \
|
||||||
--column="Tag (Anzahl)" \
|
--column="Tag (Anzahl)" \
|
||||||
--width=400 --height=500 \
|
--width=400 --height=500 \
|
||||||
--text="Wähle einen Tag aus:")
|
--text="Wähle einen Tag aus:")
|
||||||
|
|
||||||
if [ -z "$selected_item" ]; then
|
if [ -z "$selected_item" ]; then break; fi
|
||||||
break
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Extrahiere den reinen Tag-Namen (alles vor dem Leerzeichen/Klammer)
|
# Extrahiere den reinen Tag (nimmt alles vor der ersten Klammer)
|
||||||
selected_tag=$(echo "$selected_item" | awk '{print $1}')
|
selected_tag=$(echo "$selected_item" | sed 's/ (.*)//')
|
||||||
|
|
||||||
# 4. Projektauswahl-Schleife für den gewählten Tag
|
# 4. Suche nach den Projekten
|
||||||
while true; do
|
# Wir suchen jetzt nach dem exakten String im gesamten Verzeichnisbaum
|
||||||
results=$(grep -rl "$selected_tag" "$BASE_DIR" --include="README.md" 2>/dev/null | while read -r file; do
|
results=$(grep -rlF "$selected_tag" "$BASE_DIR" --include="README.md" 2>/dev/null | while read -r file; do
|
||||||
dirname "$(realpath "$file")"
|
dirname "$file"
|
||||||
done)[cite: 3]
|
done | sort -u)
|
||||||
|
|
||||||
if [ -z "$results" ]; then
|
if [ -z "$results" ]; then
|
||||||
zenity --info --text="Keine Projekte für '$selected_tag' gefunden."
|
zenity --info --text="Keine Projekte für den Tag '$selected_tag' gefunden.\n\nSuchpfad: $BASE_DIR"
|
||||||
break
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 5. Projektauswahl
|
||||||
selected_project=$(echo "$results" | zenity --list \
|
selected_project=$(echo "$results" | zenity --list \
|
||||||
--title="Ergebnisse für: $selected_tag" \
|
--title="Ergebnisse für: $selected_tag" \
|
||||||
--column="Projekt-Pfad" \
|
--column="Projekt-Pfad" \
|
||||||
--text="Gefundene Projekte:" \
|
|
||||||
--width=800 --height=400 \
|
--width=800 --height=400 \
|
||||||
--ok-label="README öffnen" \
|
--ok-label="README öffnen" \
|
||||||
--cancel-label="Zurück zur Tag-Suche")
|
--cancel-label="Zurück")
|
||||||
|
|
||||||
if [ -z "$selected_project" ]; then
|
if [ -n "$selected_project" ] && [ -f "$selected_project/README.md" ]; then
|
||||||
break
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 5. README öffnen[cite: 3]
|
|
||||||
if [ -f "$selected_project/README.md" ]; then
|
|
||||||
xdg-open "$selected_project/README.md" &>/dev/null &
|
xdg-open "$selected_project/README.md" &>/dev/null &
|
||||||
zenity --info --text="Öffne README von:\n$selected_project" --timeout=2
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if ! zenity --question --text="Möchtest du nach einem anderen Tag suchen?"; then
|
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
40
sync_rsync.sh
Executable file
40
sync_rsync.sh
Executable file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
|
||||||
|
CONF_FILE="$SCRIPT_DIR/sync.conf"
|
||||||
|
|
||||||
|
if [ ! -f "$CONF_FILE" ]; then
|
||||||
|
zenity --error --text="sync.conf nicht gefunden!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
source "$CONF_FILE"
|
||||||
|
|
||||||
|
# 1. Passwort abfragen
|
||||||
|
SSH_PASS=$(zenity --password --title="SSH Authentifizierung" --text="Passwort für $SSH_USER@$SSH_HOST:")
|
||||||
|
|
||||||
|
# Abbrechen wenn kein Passwort eingegeben wurde
|
||||||
|
[ -z "$SSH_PASS" ] && exit 0
|
||||||
|
|
||||||
|
LOCAL_DIR="$SCRIPT_DIR/"
|
||||||
|
|
||||||
|
# 2. Synchronisation (Download & Upload)
|
||||||
|
# Wir fügen '-o StrictHostKeyChecking=no' hinzu, damit SSH nicht bei unbekannten Hosts blockiert.
|
||||||
|
zenity --info --text="Synchronisation wird gestartet..." --timeout=2
|
||||||
|
|
||||||
|
# Download
|
||||||
|
sshpass -p "$SSH_PASS" rsync -auvz -e "ssh -p $SSH_PORT -o StrictHostKeyChecking=no" "$SSH_USER@$SSH_HOST:$REMOTE_DIR" "$LOCAL_DIR" 2>/tmp/rsync_error
|
||||||
|
|
||||||
|
# Upload
|
||||||
|
sshpass -p "$SSH_PASS" rsync -auvz -e "ssh -p $SSH_PORT -o StrictHostKeyChecking=no" "$LOCAL_DIR" "$SSH_USER@$SSH_HOST:$REMOTE_DIR" 2>>/tmp/rsync_error
|
||||||
|
|
||||||
|
# 3. Erfolgskontrolle
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
zenity --info --title="Erfolg" --text="Synchronisation erfolgreich abgeschlossen!"
|
||||||
|
else
|
||||||
|
ERROR_MSG=$(cat /tmp/rsync_error)
|
||||||
|
zenity --error --title="Fehler" --text="Synchronisation fehlgeschlagen!\n\nDetails:\n$ERROR_MSG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Temporäre Fehlerdatei löschen
|
||||||
|
rm -f /tmp/rsync_error
|
||||||
49
toolbox.sh
49
toolbox.sh
|
|
@ -1,29 +1,54 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Pfad zum Skript-Ordner ermitteln
|
||||||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
|
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
|
||||||
|
|
||||||
# Pfade zu den Modulen
|
|
||||||
SCRIPT_SETUP="$SCRIPT_DIR/setup_Projekt.sh"
|
|
||||||
SCRIPT_FIND="$SCRIPT_DIR/find.sh"
|
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
# Hauptmenü mit Zenity - Korrigierte Version
|
||||||
CHOICE=$(zenity --list \
|
CHOICE=$(zenity --list \
|
||||||
--title="Christian's Projekt-Toolbox" \
|
--title="Christian's Projekt-Toolbox" \
|
||||||
|
--text="Wählen Sie eine Aktion aus:" \
|
||||||
--column="Aktion" --column="Beschreibung" \
|
--column="Aktion" --column="Beschreibung" \
|
||||||
--width=500 --height=350 \
|
--width=600 --height=450 \
|
||||||
"1. Projekt erstellen" "Grafischer Konfigurator für neue Ordner" \
|
"1. Projekt erstellen" "Neuen Ordner mit Struktur anlegen" \
|
||||||
"2. Projekt suchen" "Durchsucht Readmes nach Tags" \
|
"2. Projekt suchen" "Tags in READMEs durchsuchen" \
|
||||||
"3. Beenden" "Schließt die Toolbox")
|
"3. Cloud Sync (rsync)" "Abgleich mit Server (Zwei-Wege-Sync)" \
|
||||||
|
"4. Beenden" "Schließt die Toolbox")
|
||||||
|
|
||||||
|
# Falls Abbrechen gedrückt wurde oder das Fenster geschlossen wurde
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Toolbox wird beendet."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Auswahl auswerten
|
||||||
case "$CHOICE" in
|
case "$CHOICE" in
|
||||||
"1. Projekt erstellen")
|
"1. Projekt erstellen")
|
||||||
bash "$SCRIPT_SETUP" # Einfacher Aufruf ohne Terminal
|
bash "$SCRIPT_DIR/setup_Projekt.sh"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"2. Projekt suchen")
|
"2. Projekt suchen")
|
||||||
bash "$SCRIPT_FIND"
|
bash "$SCRIPT_DIR/find.sh"
|
||||||
;;
|
;;
|
||||||
"3. Beenden" | "")
|
|
||||||
exit 0
|
"3. Cloud Sync (rsync)")
|
||||||
|
if [ -f "$SCRIPT_DIR/sync_rsync.sh" ]; then
|
||||||
|
bash "$SCRIPT_DIR/sync_rsync.sh"
|
||||||
|
else
|
||||||
|
zenity --error --text="Skript 'sync_rsync.sh' nicht gefunden!"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
"4. Beenden")
|
||||||
|
echo "Toolbox wird beendet."
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
# Sicherheitshalber, falls CHOICE leer ist
|
||||||
|
if [ -n "$CHOICE" ]; then
|
||||||
|
zenity --info --text="Aktion abgebrochen." --timeout=1
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
Loading…
Add table
Reference in a new issue