rebuild image-builder.sh
This commit is contained in:
361
scripts/image-builder.sh
Executable file → Normal file
361
scripts/image-builder.sh
Executable file → Normal file
@@ -25,7 +25,7 @@ ensure_prereqs() {
|
|||||||
local bins=("git" "jq" "whiptail")
|
local bins=("git" "jq" "whiptail")
|
||||||
for b in "${bins[@]}"; do
|
for b in "${bins[@]}"; do
|
||||||
if ! command -v "$b" >/dev/null 2>&1; then
|
if ! command -v "$b" >/dev/null 2>&1; then
|
||||||
echo "[WARN] Benötigtes Programm fehlt: $b"
|
echo "[WARN] Benoetigtes Programm fehlt: $b"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -42,19 +42,19 @@ ensure_dirs
|
|||||||
load_global_config
|
load_global_config
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# Konfigurations-Menü
|
# Konfigurations-Menue
|
||||||
# -------------------------
|
# -------------------------
|
||||||
config_menu() {
|
config_menu() {
|
||||||
while true; do
|
while true; do
|
||||||
local builder_icon
|
local builder_icon
|
||||||
builder_icon=$(get_builder_status_icon)
|
builder_icon=$(get_builder_status_icon)
|
||||||
|
|
||||||
choice=$(whiptail --title "Konfiguration" --menu "Bitte wählen:" 20 70 10 \
|
choice=$(whiptail --title "Konfiguration" --menu "Bitte waehlen:" 20 70 10 \
|
||||||
1 "Abhängigkeiten installieren (docker, git, jq, whiptail)" \
|
1 "Abhaengigkeiten installieren (docker, git, jq, whiptail)" \
|
||||||
2 "Buildx-Builder einrichten | Status: $builder_icon" \
|
2 "Buildx-Builder einrichten | Status: $builder_icon" \
|
||||||
3 "Globalen Editor setzen" \
|
3 "Globalen Editor setzen" \
|
||||||
4 "Standard-Registry setzen" \
|
4 "Standard-Registry setzen" \
|
||||||
0 "Zurück" \
|
0 "Zurueck" \
|
||||||
3>&1 1>&2 2>&3) || return
|
3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
case $choice in
|
case $choice in
|
||||||
@@ -84,7 +84,7 @@ get_builder_status_icon() {
|
|||||||
get_builder_status() {
|
get_builder_status() {
|
||||||
if docker buildx ls 2>/dev/null | grep -q "multiarch-builder"; then
|
if docker buildx ls 2>/dev/null | grep -q "multiarch-builder"; then
|
||||||
if docker buildx ls | grep "multiarch-builder" | grep -q "running"; then
|
if docker buildx ls | grep "multiarch-builder" | grep -q "running"; then
|
||||||
echo "[läuft]"
|
echo "[laeuft]"
|
||||||
else
|
else
|
||||||
echo "[vorhanden, aber gestoppt]"
|
echo "[vorhanden, aber gestoppt]"
|
||||||
fi
|
fi
|
||||||
@@ -93,22 +93,22 @@ get_builder_status() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Abhängigkeiten installieren
|
# Abhaengigkeiten installieren
|
||||||
install_dependencies() {
|
install_dependencies() {
|
||||||
whiptail --msgbox "Installation von Abhängigkeiten (Beispiel für Debian/Ubuntu). Bitte root-Rechte eingeben." 10 70
|
whiptail --msgbox "Installation von Abhaengigkeiten (Beispiel fuer Debian/Ubuntu). Bitte root-Rechte eingeben." 10 70
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y docker.io git jq whiptail micro
|
sudo apt install -y docker.io git jq whiptail micro
|
||||||
}
|
}
|
||||||
|
|
||||||
# BuildX-Builder einrichten
|
# BuildX-Builder einrichten
|
||||||
install_docker_and_buildx() {
|
install_docker_and_buildx() {
|
||||||
# Prüfen ob Docker installiert ist
|
# Pruefen ob Docker installiert ist
|
||||||
if ! command -v docker >/dev/null 2>&1; then
|
if ! command -v docker >/dev/null 2>&1; then
|
||||||
whiptail --msgbox "Docker ist nicht installiert! Bitte zuerst über 'Abhängigkeiten installieren' einrichten." 10 70
|
whiptail --msgbox "Docker ist nicht installiert! Bitte zuerst ueber 'Abhaengigkeiten installieren' einrichten." 10 70
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prüfen ob Buildx verfügbar ist
|
# Pruefen ob Buildx verfuegbar ist
|
||||||
if ! docker buildx version >/dev/null 2>&1; then
|
if ! docker buildx version >/dev/null 2>&1; then
|
||||||
whiptail --msgbox "Docker Buildx-Plugin fehlt! Installiere Buildx..." 10 70
|
whiptail --msgbox "Docker Buildx-Plugin fehlt! Installiere Buildx..." 10 70
|
||||||
mkdir -p ~/.docker/cli-plugins
|
mkdir -p ~/.docker/cli-plugins
|
||||||
@@ -117,7 +117,7 @@ install_docker_and_buildx() {
|
|||||||
chmod +x ~/.docker/cli-plugins/docker-buildx
|
chmod +x ~/.docker/cli-plugins/docker-buildx
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prüfen, ob multiarch-builder existiert
|
# Pruefen, ob multiarch-builder existiert
|
||||||
if ! docker buildx ls | grep -q "multiarch-builder"; then
|
if ! docker buildx ls | grep -q "multiarch-builder"; then
|
||||||
whiptail --msgbox "Richte Buildx-Builder 'multiarch-builder' ein..." 10 70
|
whiptail --msgbox "Richte Buildx-Builder 'multiarch-builder' ein..." 10 70
|
||||||
docker run --rm --privileged tonistiigi/binfmt --install all
|
docker run --rm --privileged tonistiigi/binfmt --install all
|
||||||
@@ -125,7 +125,7 @@ install_docker_and_buildx() {
|
|||||||
docker buildx inspect --bootstrap >/dev/null 2>&1
|
docker buildx inspect --bootstrap >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Finalprüfung: existiert Builder jetzt wirklich?
|
# Finalpruefung: existiert Builder jetzt wirklich?
|
||||||
if docker buildx ls | grep -q "multiarch-builder"; then
|
if docker buildx ls | grep -q "multiarch-builder"; then
|
||||||
whiptail --msgbox "Buildx-Builder 'multiarch-builder' erfolgreich eingerichtet." 10 70
|
whiptail --msgbox "Buildx-Builder 'multiarch-builder' erfolgreich eingerichtet." 10 70
|
||||||
else
|
else
|
||||||
@@ -142,7 +142,7 @@ set_editor() {
|
|||||||
local options=()
|
local options=()
|
||||||
declare -A editor_status
|
declare -A editor_status
|
||||||
|
|
||||||
# Prüfe, ob Editor installiert ist
|
# Pruefe, ob Editor installiert ist
|
||||||
for cmd in "${!editor_pkg[@]}"; do
|
for cmd in "${!editor_pkg[@]}"; do
|
||||||
if command -v "$cmd" >/dev/null 2>&1; then
|
if command -v "$cmd" >/dev/null 2>&1; then
|
||||||
editor_status[$cmd]="(installiert)"
|
editor_status[$cmd]="(installiert)"
|
||||||
@@ -153,7 +153,7 @@ set_editor() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
choice=$(whiptail --title "Editor wählen" --menu "Bitte Editor auswählen:" 20 70 10 "${options[@]}" 3>&1 1>&2 2>&3) || return
|
choice=$(whiptail --title "Editor waehlen" --menu "Bitte Editor auswaehlen:" 20 70 10 "${options[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
if command -v "$choice" >/dev/null 2>&1; then
|
if command -v "$choice" >/dev/null 2>&1; then
|
||||||
jq --arg ed "$choice" '.editor = $ed' "$GLOBAL_CONFIG" >"$GLOBAL_CONFIG.tmp" && mv "$GLOBAL_CONFIG.tmp" "$GLOBAL_CONFIG"
|
jq --arg ed "$choice" '.editor = $ed' "$GLOBAL_CONFIG" >"$GLOBAL_CONFIG.tmp" && mv "$GLOBAL_CONFIG.tmp" "$GLOBAL_CONFIG"
|
||||||
@@ -161,14 +161,14 @@ set_editor() {
|
|||||||
return
|
return
|
||||||
else
|
else
|
||||||
install_choice=$(whiptail --title "Editor nicht installiert" \
|
install_choice=$(whiptail --title "Editor nicht installiert" \
|
||||||
--yesno "Der Editor '$choice' ist nicht installiert. Möchten Sie ihn jetzt installieren?" 10 60 3>&1 1>&2 2>&3)
|
--yesno "Der Editor '$choice' ist nicht installiert. Moechten Sie ihn jetzt installieren?" 10 60 3>&1 1>&2 2>&3)
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
whiptail --msgbox "Installation von ${editor_pkg[$choice]}..." 8 50
|
whiptail --msgbox "Installation von ${editor_pkg[$choice]}..." 8 50
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y "${editor_pkg[$choice]}"
|
sudo apt install -y "${editor_pkg[$choice]}"
|
||||||
|
|
||||||
if command -v "$choice" >/dev/null 2>&1; then
|
if command -v "$choice" >/dev/null 2>&1; then
|
||||||
# Speziell für nano: Syntax-Highlighting installieren
|
# Speziell fuer nano: Syntax-Highlighting installieren
|
||||||
if [[ "$choice" == "nano" ]]; then
|
if [[ "$choice" == "nano" ]]; then
|
||||||
NANO_DIR="$HOME/.nano"
|
NANO_DIR="$HOME/.nano"
|
||||||
NANORC="$HOME/.nanorc"
|
NANORC="$HOME/.nanorc"
|
||||||
@@ -198,12 +198,12 @@ set_editor() {
|
|||||||
|
|
||||||
# Standard-Registry setzen
|
# Standard-Registry setzen
|
||||||
set_default_registry() {
|
set_default_registry() {
|
||||||
# Alle verfügbaren Registries auslesen
|
# Alle verfuegbaren Registries auslesen
|
||||||
local registries
|
local registries
|
||||||
registries=$(ls "$REGISTRY_CONFIG_DIR" 2>/dev/null)
|
registries=$(ls "$REGISTRY_CONFIG_DIR" 2>/dev/null)
|
||||||
[ -z "$registries" ] && { whiptail --msgbox "Keine Registries verfügbar. Bitte zuerst eine Registry erstellen." 10 60; return; }
|
[ -z "$registries" ] && { whiptail --msgbox "Keine Registries verfuegbar. Bitte zuerst eine Registry erstellen." 10 60; return; }
|
||||||
|
|
||||||
# Menü-Liste vorbereiten
|
# Menue-Liste vorbereiten
|
||||||
local menu_list=()
|
local menu_list=()
|
||||||
for r in $registries; do
|
for r in $registries; do
|
||||||
menu_list+=("$r" "$r")
|
menu_list+=("$r" "$r")
|
||||||
@@ -215,8 +215,8 @@ set_default_registry() {
|
|||||||
|
|
||||||
# Auswahl per Whiptail
|
# Auswahl per Whiptail
|
||||||
local choice
|
local choice
|
||||||
choice=$(whiptail --title "Standard-Registry wählen" \
|
choice=$(whiptail --title "Standard-Registry waehlen" \
|
||||||
--menu "Bitte Standard-Registry auswählen:" 20 70 10 \
|
--menu "Bitte Standard-Registry auswaehlen:" 20 70 10 \
|
||||||
"${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
"${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
# Speichern in global/config.json
|
# Speichern in global/config.json
|
||||||
@@ -237,14 +237,14 @@ get_default_registry() {
|
|||||||
# Projektverwaltung
|
# Projektverwaltung
|
||||||
# ===============================
|
# ===============================
|
||||||
|
|
||||||
# Hauptmenü Projektverwaltung
|
# Hauptmenue Projektverwaltung
|
||||||
project_menu() {
|
project_menu() {
|
||||||
while true; do
|
while true; do
|
||||||
choice=$(whiptail --title "Projektverwaltung" --menu "Bitte wählen:" 20 70 10 \
|
choice=$(whiptail --title "Projektverwaltung" --menu "Bitte waehlen:" 20 70 10 \
|
||||||
1 "Projekt erstellen" \
|
1 "Projekt erstellen" \
|
||||||
2 "Projekt löschen" \
|
2 "Projekt loeschen" \
|
||||||
3 "Projekt bearbeiten" \
|
3 "Projekt bearbeiten" \
|
||||||
0 "Zurück" \
|
0 "Zurueck" \
|
||||||
3>&1 1>&2 2>&3) || return
|
3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
case $choice in
|
case $choice in
|
||||||
@@ -268,7 +268,7 @@ create_project() {
|
|||||||
|
|
||||||
# Default Config-File
|
# Default Config-File
|
||||||
cat > "$PROJECT_CONFIG_DIR/$project_name/config-file" <<EOF
|
cat > "$PROJECT_CONFIG_DIR/$project_name/config-file" <<EOF
|
||||||
# Projektkonfiguration für $project_name
|
# Projektkonfiguration fuer $project_name
|
||||||
registry=$default_registry
|
registry=$default_registry
|
||||||
image_name=$project_name
|
image_name=$project_name
|
||||||
architectures=amd64
|
architectures=amd64
|
||||||
@@ -294,7 +294,7 @@ EOF
|
|||||||
whiptail --msgbox "Projekt $project_name wurde erstellt." 10 60
|
whiptail --msgbox "Projekt $project_name wurde erstellt." 10 60
|
||||||
}
|
}
|
||||||
|
|
||||||
# Projekt löschen
|
# Projekt loeschen
|
||||||
delete_project() {
|
delete_project() {
|
||||||
projects=$(ls "$PROJECT_CONFIG_DIR" 2>/dev/null)
|
projects=$(ls "$PROJECT_CONFIG_DIR" 2>/dev/null)
|
||||||
[ -z "$projects" ] && { whiptail --msgbox "Keine Projekte vorhanden." 10 60; return; }
|
[ -z "$projects" ] && { whiptail --msgbox "Keine Projekte vorhanden." 10 60; return; }
|
||||||
@@ -304,11 +304,11 @@ delete_project() {
|
|||||||
menu_list+=("$p" "")
|
menu_list+=("$p" "")
|
||||||
done
|
done
|
||||||
|
|
||||||
project=$(whiptail --menu "Projekt zum Löschen auswählen:" 20 60 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
project=$(whiptail --menu "Projekt zum Loeschen auswaehlen:" 20 60 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
if whiptail --yesno "Projekt $project wirklich löschen?" 10 60; then
|
if whiptail --yesno "Projekt $project wirklich loeschen?" 10 60; then
|
||||||
rm -rf "$PROJECT_CONFIG_DIR/$project" "$PROJECTS_DIR/$project"
|
rm -rf "$PROJECT_CONFIG_DIR/$project" "$PROJECTS_DIR/$project"
|
||||||
whiptail --msgbox "Projekt $project wurde gelöscht." 10 60
|
whiptail --msgbox "Projekt $project wurde geloescht." 10 60
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,13 +317,13 @@ edit_project() {
|
|||||||
projects=$(ls "$PROJECT_CONFIG_DIR" 2>/dev/null)
|
projects=$(ls "$PROJECT_CONFIG_DIR" 2>/dev/null)
|
||||||
[ -z "$projects" ] && { whiptail --msgbox "Keine Projekte vorhanden." 10 60; return; }
|
[ -z "$projects" ] && { whiptail --msgbox "Keine Projekte vorhanden." 10 60; return; }
|
||||||
|
|
||||||
# Projekte für Menü vorbereiten (1 Spalte)
|
# Projekte fuer Menue vorbereiten (1 Spalte)
|
||||||
menu_list=()
|
menu_list=()
|
||||||
for p in $projects; do
|
for p in $projects; do
|
||||||
menu_list+=("$p" "")
|
menu_list+=("$p" "")
|
||||||
done
|
done
|
||||||
|
|
||||||
project=$(whiptail --menu "Projekt auswählen:" 20 60 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
project=$(whiptail --menu "Projekt auswaehlen:" 20 60 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
local config_file="$PROJECT_CONFIG_DIR/$project/config-file"
|
local config_file="$PROJECT_CONFIG_DIR/$project/config-file"
|
||||||
local project_dir="$PROJECTS_DIR/$project"
|
local project_dir="$PROJECTS_DIR/$project"
|
||||||
|
|
||||||
@@ -331,11 +331,11 @@ edit_project() {
|
|||||||
repo_url=$(grep "^git_repo=" "$config_file" | cut -d= -f2)
|
repo_url=$(grep "^git_repo=" "$config_file" | cut -d= -f2)
|
||||||
|
|
||||||
menu_items=(
|
menu_items=(
|
||||||
1 "Registries auswählen"
|
1 "Registries auswaehlen"
|
||||||
2 "Architekturen auswählen"
|
2 "Architekturen auswaehlen"
|
||||||
3 "Push aktivieren/deaktivieren"
|
3 "Push aktivieren/deaktivieren"
|
||||||
4 "Latest-Tag setzen/entfernen"
|
4 "Latest-Tag setzen/entfernen"
|
||||||
5 "Version/Subversion ändern"
|
5 "Version/Subversion aendern"
|
||||||
6 "Automatische Subversion"
|
6 "Automatische Subversion"
|
||||||
7 "Projektdateien bearbeiten"
|
7 "Projektdateien bearbeiten"
|
||||||
9 "Image bauen"
|
9 "Image bauen"
|
||||||
@@ -343,10 +343,10 @@ edit_project() {
|
|||||||
|
|
||||||
[ -n "$repo_url" ] && menu_items+=("8" "Git Pull")
|
[ -n "$repo_url" ] && menu_items+=("8" "Git Pull")
|
||||||
|
|
||||||
menu_items+=("0" "Zurück")
|
menu_items+=("0" "Zurueck")
|
||||||
|
|
||||||
choice=$(whiptail --title "Projekt bearbeiten: $project" \
|
choice=$(whiptail --title "Projekt bearbeiten: $project" \
|
||||||
--menu "Bitte wählen:" 20 70 12 \
|
--menu "Bitte waehlen:" 20 70 12 \
|
||||||
"${menu_items[@]}" \
|
"${menu_items[@]}" \
|
||||||
3>&1 1>&2 2>&3) || return
|
3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
@@ -366,7 +366,7 @@ edit_project() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Registry für Projekt auswählen
|
# Registry fuer Projekt auswaehlen
|
||||||
edit_project_registries() {
|
edit_project_registries() {
|
||||||
local config_file=$1
|
local config_file=$1
|
||||||
|
|
||||||
@@ -376,13 +376,13 @@ edit_project_registries() {
|
|||||||
# alle registries aus Registry-Verwaltung
|
# alle registries aus Registry-Verwaltung
|
||||||
local all_registries
|
local all_registries
|
||||||
all_registries=$(ls "$REGISTRY_CONFIG_DIR" 2>/dev/null)
|
all_registries=$(ls "$REGISTRY_CONFIG_DIR" 2>/dev/null)
|
||||||
[ -z "$all_registries" ] && { whiptail --msgbox "Keine Registries verfügbar. Bitte zuerst eine Registry erstellen." 10 60; return; }
|
[ -z "$all_registries" ] && { whiptail --msgbox "Keine Registries verfuegbar. Bitte zuerst eine Registry erstellen." 10 60; return; }
|
||||||
|
|
||||||
# Default-Registry aus globaler Config
|
# Default-Registry aus globaler Config
|
||||||
local default_registry
|
local default_registry
|
||||||
default_registry=$(get_default_registry)
|
default_registry=$(get_default_registry)
|
||||||
|
|
||||||
# menu_list für whiptail vorbereiten
|
# menu_list fuer whiptail vorbereiten
|
||||||
local menu_list=()
|
local menu_list=()
|
||||||
for r in $all_registries; do
|
for r in $all_registries; do
|
||||||
if [[ " $current " =~ " $r " ]]; then
|
if [[ " $current " =~ " $r " ]]; then
|
||||||
@@ -397,22 +397,22 @@ edit_project_registries() {
|
|||||||
|
|
||||||
# whiptail checklist
|
# whiptail checklist
|
||||||
local selected
|
local selected
|
||||||
selected=$(whiptail --title "Registries auswählen" --checklist "Mehrere auswählen (SPACE zum markieren)" 20 70 10 \
|
selected=$(whiptail --title "Registries auswaehlen" --checklist "Mehrere auswaehlen (SPACE zum markieren)" 20 70 10 \
|
||||||
"${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
"${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
# Whiptail gibt die Auswahl in Anführungszeichen zurück, diese entfernen und Komma getrennt speichern
|
# Whiptail gibt die Auswahl in Anfuehrungszeichen zurueck, diese entfernen und Komma getrennt speichern
|
||||||
selected=$(echo $selected | tr -d '"' | tr ' ' ',')
|
selected=$(echo $selected | tr -d '"' | tr ' ' ',')
|
||||||
|
|
||||||
# In Projekt-Config speichern
|
# In Projekt-Config speichern
|
||||||
sed -i "s|^registry=.*|registry=$selected|" "$config_file"
|
sed -i "s|^registry=.*|registry=$selected|" "$config_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Schlüssel im Config-File ändern
|
# Schluessel im Config-File aendern
|
||||||
change_project_setting() {
|
change_project_setting() {
|
||||||
local config_file=$1
|
local config_file=$1
|
||||||
local key=$2
|
local key=$2
|
||||||
local current=$(grep "^$key=" "$config_file" | cut -d= -f2)
|
local current=$(grep "^$key=" "$config_file" | cut -d= -f2)
|
||||||
new_value=$(whiptail --inputbox "$key ändern (aktuell: $current)" 10 60 "$current" 3>&1 1>&2 2>&3) || return
|
new_value=$(whiptail --inputbox "$key aendern (aktuell: $current)" 10 60 "$current" 3>&1 1>&2 2>&3) || return
|
||||||
sed -i "s|^$key=.*|$key=$new_value|" "$config_file"
|
sed -i "s|^$key=.*|$key=$new_value|" "$config_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,7 +430,7 @@ edit_project_files() {
|
|||||||
local project=$1
|
local project=$1
|
||||||
local project_dir="$PROJECTS_DIR/$project"
|
local project_dir="$PROJECTS_DIR/$project"
|
||||||
|
|
||||||
# Prüfen ob Projektordner existiert
|
# Pruefen ob Projektordner existiert
|
||||||
if [[ ! -d "$project_dir" ]]; then
|
if [[ ! -d "$project_dir" ]]; then
|
||||||
whiptail --msgbox "Projektordner nicht gefunden." 10 60
|
whiptail --msgbox "Projektordner nicht gefunden." 10 60
|
||||||
return
|
return
|
||||||
@@ -442,17 +442,17 @@ edit_project_files() {
|
|||||||
|
|
||||||
# dialog-Dateiauswahl
|
# dialog-Dateiauswahl
|
||||||
local file
|
local file
|
||||||
file=$(dialog --title "Datei auswählen" --fselect "$project_dir/" 20 70 3>&1 1>&2 2>&3) || return
|
file=$(dialog --title "Datei auswaehlen" --fselect "$project_dir/" 20 70 3>&1 1>&2 2>&3) || return
|
||||||
[[ -z "$file" ]] && return
|
[[ -z "$file" ]] && return
|
||||||
|
|
||||||
# Datei im Editor öffnen
|
# Datei im Editor oeffnen
|
||||||
"$editor_cmd" "$file"
|
"$editor_cmd" "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_project_architectures() {
|
edit_project_architectures() {
|
||||||
local config_file=$1
|
local config_file=$1
|
||||||
local current=$(grep "^architectures=" "$config_file" | cut -d= -f2 | tr ',' ' ')
|
local current=$(grep "^architectures=" "$config_file" | cut -d= -f2 | tr ',' ' ')
|
||||||
local all_archs=("amd64" "arm64" "armhf" "x86")
|
local all_archs=("amd64" "386" "arm64/v8" "arm/v7" "arm/v6" "arm/v5")
|
||||||
menu_list=()
|
menu_list=()
|
||||||
for a in "${all_archs[@]}"; do
|
for a in "${all_archs[@]}"; do
|
||||||
if [[ " $current " =~ " $a " ]]; then
|
if [[ " $current " =~ " $a " ]]; then
|
||||||
@@ -461,7 +461,7 @@ edit_project_architectures() {
|
|||||||
menu_list+=("$a" "$a" OFF)
|
menu_list+=("$a" "$a" OFF)
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
selected=$(whiptail --title "Architekturen auswählen" --checklist "Mehrere auswählen" 20 70 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
selected=$(whiptail --title "Architekturen auswaehlen" --checklist "Mehrere auswaehlen" 20 70 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
selected=$(echo $selected | tr -d '"')
|
selected=$(echo $selected | tr -d '"')
|
||||||
sed -i "s|^architectures=.*|architectures=$selected|" "$config_file"
|
sed -i "s|^architectures=.*|architectures=$selected|" "$config_file"
|
||||||
}
|
}
|
||||||
@@ -471,7 +471,7 @@ edit_project_push() {
|
|||||||
local current=$(grep "^push=" "$config_file" | cut -d= -f2)
|
local current=$(grep "^push=" "$config_file" | cut -d= -f2)
|
||||||
local value="OFF"
|
local value="OFF"
|
||||||
[ "$current" == "yes" ] && value="ON"
|
[ "$current" == "yes" ] && value="ON"
|
||||||
selected=$(whiptail --title "Push aktivieren?" --checklist "Push auswählen" 10 50 1 push "Push aktivieren" $value 3>&1 1>&2 2>&3) || return
|
selected=$(whiptail --title "Push aktivieren?" --checklist "Push auswaehlen" 10 50 1 push "Push aktivieren" $value 3>&1 1>&2 2>&3) || return
|
||||||
[[ $selected == *push* ]] && val="yes" || val="no"
|
[[ $selected == *push* ]] && val="yes" || val="no"
|
||||||
sed -i "s|^push=.*|push=$val|" "$config_file"
|
sed -i "s|^push=.*|push=$val|" "$config_file"
|
||||||
}
|
}
|
||||||
@@ -481,7 +481,7 @@ edit_project_latest() {
|
|||||||
local current=$(grep "^latest=" "$config_file" | cut -d= -f2)
|
local current=$(grep "^latest=" "$config_file" | cut -d= -f2)
|
||||||
local value="OFF"
|
local value="OFF"
|
||||||
[ "$current" == "yes" ] && value="ON"
|
[ "$current" == "yes" ] && value="ON"
|
||||||
selected=$(whiptail --title "Latest-Tag setzen?" --checklist "Latest auswählen" 10 50 1 latest "Latest setzen" $value 3>&1 1>&2 2>&3) || return
|
selected=$(whiptail --title "Latest-Tag setzen?" --checklist "Latest auswaehlen" 10 50 1 latest "Latest setzen" $value 3>&1 1>&2 2>&3) || return
|
||||||
[[ $selected == *latest* ]] && val="yes" || val="no"
|
[[ $selected == *latest* ]] && val="yes" || val="no"
|
||||||
sed -i "s|^latest=.*|latest=$val|" "$config_file"
|
sed -i "s|^latest=.*|latest=$val|" "$config_file"
|
||||||
}
|
}
|
||||||
@@ -491,9 +491,9 @@ edit_project_auto_subversion() {
|
|||||||
local current=$(grep "^auto_subversion=" "$config_file" | cut -d= -f2)
|
local current=$(grep "^auto_subversion=" "$config_file" | cut -d= -f2)
|
||||||
local value="OFF"
|
local value="OFF"
|
||||||
[ "$current" == "yes" ] && value="ON"
|
[ "$current" == "yes" ] && value="ON"
|
||||||
selected=$(whiptail --title "Subversion automatisch erhöhen?" --checklist "Auto Subversion auswählen" 10 50 1 auto "Automatisch erhöhen" $value 3>&1 1>&2 2>&3) || return
|
selected=$(whiptail --title "Subversion automatisch erhoehen?" --checklist "Auto Subversion auswaehlen" 10 50 1 auto "Automatisch erhoehen" $value 3>&1 1>&2 2>&3) || return
|
||||||
[[ $selected == *auto* ]] && val="yes" || val="no"
|
[[ $selected == *auto* ]] && val="yes" || val="no"
|
||||||
# falls auto_subversion key nicht existiert, hinzufügen
|
# falls auto_subversion key nicht existiert, hinzufuegen
|
||||||
if grep -q "^auto_subversion=" "$config_file"; then
|
if grep -q "^auto_subversion=" "$config_file"; then
|
||||||
sed -i "s|^auto_subversion=.*|auto_subversion=$val|" "$config_file"
|
sed -i "s|^auto_subversion=.*|auto_subversion=$val|" "$config_file"
|
||||||
else
|
else
|
||||||
@@ -501,14 +501,14 @@ edit_project_auto_subversion() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Hauptmenü - Registryverwaltung
|
# Hauptmenue - Registryverwaltung
|
||||||
registry_menu() {
|
registry_menu() {
|
||||||
while true; do
|
while true; do
|
||||||
choice=$(whiptail --title "Registry-Verwaltung" --menu "Bitte wählen:" 20 70 10 \
|
choice=$(whiptail --title "Registry-Verwaltung" --menu "Bitte waehlen:" 20 70 10 \
|
||||||
1 "Registry erstellen" \
|
1 "Registry erstellen" \
|
||||||
2 "Registry löschen" \
|
2 "Registry loeschen" \
|
||||||
3 "Registry bearbeiten" \
|
3 "Registry bearbeiten" \
|
||||||
0 "Zurück" \
|
0 "Zurueck" \
|
||||||
3>&1 1>&2 2>&3) || return
|
3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
case $choice in
|
case $choice in
|
||||||
@@ -541,7 +541,7 @@ EOF
|
|||||||
whiptail --msgbox "Registry '$name' wurde erstellt." 10 60
|
whiptail --msgbox "Registry '$name' wurde erstellt." 10 60
|
||||||
}
|
}
|
||||||
|
|
||||||
# Registry löschen
|
# Registry loeschen
|
||||||
delete_registry() {
|
delete_registry() {
|
||||||
local registries
|
local registries
|
||||||
registries=$(ls "$REGISTRY_CONFIG_DIR" 2>/dev/null)
|
registries=$(ls "$REGISTRY_CONFIG_DIR" 2>/dev/null)
|
||||||
@@ -553,11 +553,11 @@ delete_registry() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
local reg
|
local reg
|
||||||
reg=$(whiptail --menu "Registry zum Löschen auswählen:" 20 60 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
reg=$(whiptail --menu "Registry zum Loeschen auswaehlen:" 20 60 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
if whiptail --yesno "Registry $reg wirklich löschen?" 10 60; then
|
if whiptail --yesno "Registry $reg wirklich loeschen?" 10 60; then
|
||||||
rm -rf "$REGISTRY_CONFIG_DIR/$reg"
|
rm -rf "$REGISTRY_CONFIG_DIR/$reg"
|
||||||
whiptail --msgbox "Registry $reg wurde gelöscht." 10 60
|
whiptail --msgbox "Registry $reg wurde geloescht." 10 60
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -573,7 +573,7 @@ edit_registry() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
local reg
|
local reg
|
||||||
reg=$(whiptail --menu "Registry zum Bearbeiten auswählen:" 20 60 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
reg=$(whiptail --menu "Registry zum Bearbeiten auswaehlen:" 20 60 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
local config_file="$REGISTRY_CONFIG_DIR/$reg/config-file"
|
local config_file="$REGISTRY_CONFIG_DIR/$reg/config-file"
|
||||||
local url username password
|
local url username password
|
||||||
@@ -582,7 +582,7 @@ edit_registry() {
|
|||||||
username=$(grep "^username=" "$config_file" | cut -d= -f2)
|
username=$(grep "^username=" "$config_file" | cut -d= -f2)
|
||||||
password=$(grep "^password=" "$config_file" | cut -d= -f2)
|
password=$(grep "^password=" "$config_file" | cut -d= -f2)
|
||||||
|
|
||||||
# Eingaben ändern
|
# Eingaben aendern
|
||||||
url=$(whiptail --inputbox "URL:" 10 60 "$url" 3>&1 1>&2 2>&3) || return
|
url=$(whiptail --inputbox "URL:" 10 60 "$url" 3>&1 1>&2 2>&3) || return
|
||||||
username=$(whiptail --inputbox "Benutzername:" 10 60 "$username" 3>&1 1>&2 2>&3) || return
|
username=$(whiptail --inputbox "Benutzername:" 10 60 "$username" 3>&1 1>&2 2>&3) || return
|
||||||
password=$(whiptail --passwordbox "Passwort:" 10 60 "$password" 3>&1 1>&2 2>&3) || return
|
password=$(whiptail --passwordbox "Passwort:" 10 60 "$password" 3>&1 1>&2 2>&3) || return
|
||||||
@@ -615,62 +615,93 @@ build_image() {
|
|||||||
local config_file="$PROJECT_CONFIG_DIR/$project/config-file"
|
local config_file="$PROJECT_CONFIG_DIR/$project/config-file"
|
||||||
load_project_config "$config_file"
|
load_project_config "$config_file"
|
||||||
|
|
||||||
# Build-Parameter aus Config
|
local timestamp logfile
|
||||||
local regs=()
|
timestamp=$(date +"%Y%m%d_%H%M%S")
|
||||||
IFS=',' read -r -a regs <<< "$registry" # Registries als Array
|
logfile="$LOGS_DIR/${project}_${timestamp}.log"
|
||||||
local tags=()
|
|
||||||
for r in "${regs[@]}"; do
|
{
|
||||||
[[ -n "$r" ]] && tags+=("-t $r/$image_name:$version")
|
echo "==== Build gestartet: $(date) ===="
|
||||||
|
echo "Projekt: $project"
|
||||||
|
echo "Registry: $registry"
|
||||||
|
echo "Image: $image_name"
|
||||||
|
echo "Architekturen: $architectures"
|
||||||
|
echo "Push: $push"
|
||||||
|
echo "Version: $version"
|
||||||
|
echo "Latest-Tag: $latest"
|
||||||
|
echo "===================================="
|
||||||
|
} | tee "$logfile"
|
||||||
|
|
||||||
|
# Architekturen in Buildx-Format
|
||||||
|
local platforms
|
||||||
|
platforms=$(echo "$architectures" | xargs -n1 | sed 's|^|linux/|' | paste -sd, -)
|
||||||
|
|
||||||
|
# Registry-URLs und Login
|
||||||
|
declare -A registry_url
|
||||||
|
IFS=',' read -ra registry_list <<< "$registry"
|
||||||
|
|
||||||
|
for r in "${registry_list[@]}"; do
|
||||||
|
r=$(echo "$r" | xargs) # führende/folgende Leerzeichen entfernen
|
||||||
|
config_path="$REGISTRY_CONFIG_DIR/$r/config-file"
|
||||||
|
if [[ ! -f "$config_path" ]]; then
|
||||||
|
echo "FEHLER: Registry-Konfigurationsdatei nicht gefunden: $config_path" | tee -a "$logfile"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
url=$(grep "^url=" "$config_path" | cut -d= -f2)
|
||||||
|
username=$(grep "^username=" "$config_path" | cut -d= -f2)
|
||||||
|
password=$(grep "^password=" "$config_path" | cut -d= -f2)
|
||||||
|
|
||||||
|
registry_url["$r"]="$url"
|
||||||
|
|
||||||
|
if [[ "$push" == "yes" ]]; then
|
||||||
|
echo "Logging in to $url..."
|
||||||
|
echo "$password" | docker login "$url" -u "$username" --password-stdin 2>&1 | tee -a "$logfile"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
local archs
|
# Tags aufbauen
|
||||||
archs=$(echo "$architectures" | sed 's/ /,/g')
|
tags=()
|
||||||
|
for r in "${registry_list[@]}"; do
|
||||||
|
r=$(echo "$r" | xargs)
|
||||||
|
url="${registry_url[$r]}"
|
||||||
|
if [[ -z "$url" ]]; then
|
||||||
|
echo "WARNUNG: Registry $r konnte nicht gefunden werden, Tag wird uebersprungen." | tee -a "$logfile"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
tags+=("-t" "${url}/${image_name}:${version}")
|
||||||
|
[[ "$latest" == "yes" ]] && tags+=("-t" "${url}/${image_name}:latest")
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
# Push-Flag
|
||||||
local push_flag=""
|
local push_flag=""
|
||||||
[[ "$push" == "yes" ]] && push_flag="--push"
|
[[ "$push" == "yes" ]] && push_flag="--push"
|
||||||
|
|
||||||
local logfile="$LOGS_DIR/${project}_$(date +"%Y%m%d_%H%M%S").log"
|
# Build ausfuehren und Exit-Code speichern
|
||||||
|
if docker buildx build --platform "$platforms" "${tags[@]}" "$PROJECTS_DIR/$project" $push_flag 2>&1 | tee -a "$logfile"; then
|
||||||
echo "==== Build gestartet: $(date) ====" > "$logfile"
|
build_status="erfolgreich"
|
||||||
echo "Projekt: $project" >> "$logfile"
|
|
||||||
echo "Registries: ${registry}" >> "$logfile"
|
|
||||||
echo "Image: $image_name" >> "$logfile"
|
|
||||||
echo "Architekturen: $architectures" >> "$logfile"
|
|
||||||
echo "Push: $push" >> "$logfile"
|
|
||||||
echo "Version: $version" >> "$logfile"
|
|
||||||
echo "Latest: $latest" >> "$logfile"
|
|
||||||
echo "====================================" >> "$logfile"
|
|
||||||
|
|
||||||
# Build starten
|
|
||||||
local build_cmd
|
|
||||||
build_cmd="docker buildx build --platform linux/$archs ${tags[*]} ./projects/$project $push_flag"
|
|
||||||
echo "$build_cmd" >> "$logfile"
|
|
||||||
|
|
||||||
if $build_cmd >> "$logfile" 2>&1; then
|
|
||||||
echo "==== Build beendet: $(date) ====" >> "$logfile"
|
|
||||||
|
|
||||||
# Latest-Tag setzen
|
|
||||||
if [[ "$latest" == "yes" ]]; then
|
|
||||||
for r in "${regs[@]}"; do
|
|
||||||
[[ -n "$r" ]] && docker tag "$r/$image_name:$version" "$r/$image_name:latest" >> "$logfile" 2>&1
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Subversion erhöhen
|
|
||||||
if grep -q "^auto_subversion=yes" "$config_file"; then
|
|
||||||
local main_ver sub_ver
|
|
||||||
main_ver=$(echo "$version" | cut -d. -f1)
|
|
||||||
sub_ver=$(echo "$version" | cut -d. -f2)
|
|
||||||
sub_ver=$((sub_ver+1))
|
|
||||||
version="$main_ver.$sub_ver"
|
|
||||||
sed -i "s|^version=.*|version=$version|" "$config_file"
|
|
||||||
echo "Subversion automatisch auf $version erhöht." >> "$logfile"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "==== Build fehlgeschlagen: $(date) ====" >> "$logfile"
|
build_status="FEHLGESCHLAGEN"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
whiptail --msgbox "Build beendet. Log-Datei: $logfile" 15 70
|
echo "==== Build beendet: $(date) - Status: $build_status ====" | tee -a "$logfile"
|
||||||
|
|
||||||
|
# Auto-Subversion
|
||||||
|
if [[ "$auto_subversion" == "yes" ]]; then
|
||||||
|
local major minor
|
||||||
|
major=$(echo "$version" | cut -d. -f1)
|
||||||
|
minor=$(echo "$version" | cut -d. -f2)
|
||||||
|
minor=$((minor + 1))
|
||||||
|
sed -i "s/^version=.*/version=${major}.${minor}/" "$config_file"
|
||||||
|
echo "Subversion automatisch auf ${major}.${minor} erhoeht." | tee -a "$logfile"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Abfrage: Log anzeigen?
|
||||||
|
if whiptail --yesno "Build $build_status. Log jetzt anzeigen?" 10 60; then
|
||||||
|
local editor_cmd
|
||||||
|
editor_cmd=$(get_editor_cmd)
|
||||||
|
$editor_cmd "$logfile"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -678,7 +709,7 @@ build_image() {
|
|||||||
view_logs() {
|
view_logs() {
|
||||||
#ensure_logs_dir
|
#ensure_logs_dir
|
||||||
|
|
||||||
local project_filter="${1:-}" # wenn Projekt übergeben, nur dessen Logs anzeigen
|
local project_filter="${1:-}" # wenn Projekt uebergeben, nur dessen Logs anzeigen
|
||||||
if [ -n "$project_filter" ]; then
|
if [ -n "$project_filter" ]; then
|
||||||
logs=$(ls -1t "$LOGS_DIR/${project_filter}"_*.log 2>/dev/null | sed "s|$LOGS_DIR/||")
|
logs=$(ls -1t "$LOGS_DIR/${project_filter}"_*.log 2>/dev/null | sed "s|$LOGS_DIR/||")
|
||||||
else
|
else
|
||||||
@@ -692,27 +723,22 @@ view_logs() {
|
|||||||
menu_list+=("$l" "")
|
menu_list+=("$l" "")
|
||||||
done
|
done
|
||||||
|
|
||||||
log_file=$(whiptail --menu "Log auswählen:" 20 70 12 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
log_file=$(whiptail --menu "Log auswaehlen:" 20 70 12 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
# Editor aus globaler Config lesen
|
# Editor aus globaler Config lesen
|
||||||
local editor=$(jq -r '.editor' "$GLOBAL_CONFIG")
|
local editor=$(jq -r '.editor' "$GLOBAL_CONFIG")
|
||||||
${editor:-nano} "$LOGS_DIR/$log_file"
|
${editor:-nano} "$LOGS_DIR/$log_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Projektübersicht anzeigen
|
# Projektuebersicht anzeigen
|
||||||
# Projektübersicht mit Aktionen
|
|
||||||
project_overview() {
|
project_overview() {
|
||||||
local project=$1
|
local project=$1
|
||||||
local config_file="$PROJECT_CONFIG_DIR/$project/config-file"
|
local config_file="$PROJECT_CONFIG_DIR/$project/config-file"
|
||||||
load_project_config "$config_file"
|
load_project_config "$config_file"
|
||||||
|
|
||||||
# Registries als Array
|
|
||||||
IFS=' ' read -r -a regs <<< "$registry"
|
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
local choice
|
choice=$(whiptail --title "Projektuebersicht: $project" --menu "Parameter:" 20 70 10 \
|
||||||
choice=$(whiptail --title "Projektübersicht: $project" --menu "Parameter:" 20 70 12 \
|
"1" "Registry: $registry" \
|
||||||
"1" "Registries: ${registry}" \
|
|
||||||
"2" "Image-Name: $image_name" \
|
"2" "Image-Name: $image_name" \
|
||||||
"3" "Architekturen: $architectures" \
|
"3" "Architekturen: $architectures" \
|
||||||
"4" "Push: $push" \
|
"4" "Push: $push" \
|
||||||
@@ -721,53 +747,99 @@ project_overview() {
|
|||||||
"7" "Git-Repo: $git_repo" \
|
"7" "Git-Repo: $git_repo" \
|
||||||
"B" "Bauen" \
|
"B" "Bauen" \
|
||||||
"E" "Bearbeiten" \
|
"E" "Bearbeiten" \
|
||||||
"P" "Projektauswahl wechseln" \
|
"P" "Projektauswahl" \
|
||||||
"L" "Logs ansehen" \
|
"L" "Logs ansehen" \
|
||||||
"Z" "Zurück" \
|
"Z" "Zurueck" \
|
||||||
3>&1 1>&2 2>&3) || return
|
3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
case $choice in
|
case $choice in
|
||||||
B) build_image "$project" ;;
|
B) build_image "$project" ;;
|
||||||
E) edit_project "$project" ;; # Bearbeitungsmenü für das Projekt
|
E) edit_project "$project" ;; # Reuse aus Projektverwaltung
|
||||||
P) return ;; # zurück zur Projektauswahl
|
P) select_project_for_build ;;
|
||||||
L) view_logs ;;
|
L) view_logs "$project" ;;
|
||||||
Z) return ;;
|
Z) return ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Projektauswahl für Image-Bauen
|
# Projektauswahl fuer Image-Bauen
|
||||||
select_project_for_build() {
|
select_project_for_build() {
|
||||||
local projects
|
local projects=($(ls "$PROJECT_CONFIG_DIR"))
|
||||||
projects=$(ls "$PROJECT_CONFIG_DIR" 2>/dev/null)
|
[ ${#projects[@]} -eq 0 ] && { whiptail --msgbox "Keine Projekte vorhanden." 10 60; return; }
|
||||||
[ -z "$projects" ] && { whiptail --msgbox "Keine Projekte vorhanden." 10 60; return; }
|
|
||||||
|
|
||||||
# Projekte für Menü vorbereiten (1-Spalte)
|
menu_list=()
|
||||||
local menu_list=()
|
for p in "${projects[@]}"; do
|
||||||
for p in $projects; do
|
menu_list+=("$p" "Projekt")
|
||||||
menu_list+=("$p" "")
|
|
||||||
done
|
done
|
||||||
|
|
||||||
while true; do
|
project=$(whiptail --title "Projekt auswaehlen" --menu "Bitte Projekt auswaehlen:" 20 60 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
local project
|
|
||||||
project=$(whiptail --title "Projekt auswählen" --menu "Projekt für Build auswählen:" 20 60 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
|
||||||
|
|
||||||
# Projektübersicht anzeigen
|
|
||||||
project_overview "$project"
|
project_overview "$project"
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Menüpunkt im Hauptmenü
|
# Menuepunkt im Hauptmenue
|
||||||
image_build_menu() {
|
image_build_menu() {
|
||||||
select_project_for_build
|
select_project_for_build
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ===============================
|
||||||
|
# Image-Verwaltung
|
||||||
|
# ===============================
|
||||||
|
image_management_menu() {
|
||||||
|
while true; do
|
||||||
|
# Projekte für Auswahl vorbereiten
|
||||||
|
local projects=($(ls "$PROJECT_CONFIG_DIR"))
|
||||||
|
[ ${#projects[@]} -eq 0 ] && { whiptail --msgbox "Keine Projekte vorhanden." 10 60; return; }
|
||||||
|
|
||||||
|
local menu_list=()
|
||||||
|
for p in "${projects[@]}"; do
|
||||||
|
menu_list+=("$p" "Projekt")
|
||||||
|
done
|
||||||
|
menu_list+=("0" "Zurueck")
|
||||||
|
|
||||||
|
project=$(whiptail --title "Image-Verwaltung" --menu "Projekt auswählen:" 20 70 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
|
[[ "$project" == "0" ]] && return
|
||||||
|
|
||||||
|
manage_project_images "$project"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Verwaltung der Images eines Projekts
|
||||||
|
manage_project_images() {
|
||||||
|
local project=$1
|
||||||
|
local config_file="$PROJECT_CONFIG_DIR/$project/config-file"
|
||||||
|
load_project_config "$config_file"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
# Alle lokal vorhandenen Images für das Projekt auflisten
|
||||||
|
local images
|
||||||
|
images=$(docker images --format "{{.Repository}}:{{.Tag}}" | grep "${image_name}" || true)
|
||||||
|
[ -z "$images" ] && { whiptail --msgbox "Keine lokalen Images für $project gefunden." 10 60; return; }
|
||||||
|
|
||||||
|
local menu_list=()
|
||||||
|
for img in $images; do
|
||||||
|
menu_list+=("$img" "löschen")
|
||||||
|
done
|
||||||
|
menu_list+=("0" "Zurueck")
|
||||||
|
|
||||||
|
local choice
|
||||||
|
choice=$(whiptail --title "Projekt-Images: $project" --menu "Image auswählen:" 20 70 12 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
|
[[ "$choice" == "0" ]] && return
|
||||||
|
|
||||||
|
if whiptail --yesno "Image $choice wirklich löschen?" 10 60; then
|
||||||
|
docker rmi -f "$choice"
|
||||||
|
whiptail --msgbox "Image $choice gelöscht." 8 50
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# Hauptmenü
|
# Hauptmenue
|
||||||
# -------------------------
|
# -------------------------
|
||||||
main_menu() {
|
main_menu() {
|
||||||
while true; do
|
while true; do
|
||||||
choice=$(whiptail --title "Image Builder" --menu "Bitte wählen:" 20 70 10 \
|
choice=$(whiptail --title "Image Builder" --menu "Bitte waehlen:" 20 70 10 \
|
||||||
1 "Konfiguration" \
|
1 "Konfiguration" \
|
||||||
2 "Projektverwaltung" \
|
2 "Projektverwaltung" \
|
||||||
3 "Registryverwaltung" \
|
3 "Registryverwaltung" \
|
||||||
@@ -782,7 +854,7 @@ main_menu() {
|
|||||||
2) project_menu;;
|
2) project_menu;;
|
||||||
3) registry_menu ;;
|
3) registry_menu ;;
|
||||||
4) image_build_menu;;
|
4) image_build_menu;;
|
||||||
5) whiptail --msgbox "Image-Verwaltung (noch nicht implementiert)" 10 70;;
|
5) image_management_menu;;
|
||||||
6) view_logs ;; # <-- hier globale Logs
|
6) view_logs ;; # <-- hier globale Logs
|
||||||
0) exit 0;;
|
0) exit 0;;
|
||||||
esac
|
esac
|
||||||
@@ -795,3 +867,4 @@ main_menu() {
|
|||||||
ensure_dirs
|
ensure_dirs
|
||||||
ensure_prereqs
|
ensure_prereqs
|
||||||
main_menu
|
main_menu
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user