add functions for registry
This commit is contained in:
@@ -5,6 +5,9 @@ IFS=$'\n\t'
|
|||||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
CONFIG_DIR="$ROOT_DIR/config"
|
CONFIG_DIR="$ROOT_DIR/config"
|
||||||
GLOBAL_CONFIG="$CONFIG_DIR/global/config.json"
|
GLOBAL_CONFIG="$CONFIG_DIR/global/config.json"
|
||||||
|
PROJECTS_DIR="./projects"
|
||||||
|
PROJECT_CONFIG_DIR="./config/projects"
|
||||||
|
REGISTRY_CONFIG_DIR="$CONFIG_DIR/registries"
|
||||||
|
|
||||||
ensure_dirs() {
|
ensure_dirs() {
|
||||||
mkdir -p "$CONFIG_DIR/global" "$CONFIG_DIR/projects" "$CONFIG_DIR/registries" "$ROOT_DIR/projects"
|
mkdir -p "$CONFIG_DIR/global" "$CONFIG_DIR/projects" "$CONFIG_DIR/registries" "$ROOT_DIR/projects"
|
||||||
@@ -190,9 +193,6 @@ set_editor() {
|
|||||||
# Projektverwaltung
|
# Projektverwaltung
|
||||||
# ===============================
|
# ===============================
|
||||||
|
|
||||||
PROJECTS_DIR="./projects"
|
|
||||||
PROJECT_CONFIG_DIR="./config/projects"
|
|
||||||
|
|
||||||
# Hauptmenü Projektverwaltung
|
# Hauptmenü Projektverwaltung
|
||||||
project_menu() {
|
project_menu() {
|
||||||
while true; do
|
while true; do
|
||||||
@@ -324,7 +324,6 @@ change_project_setting() {
|
|||||||
sed -i "s|^$key=.*|$key=$new_value|" "$config_file"
|
sed -i "s|^$key=.*|$key=$new_value|" "$config_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Aktuellen Editor aus global/config.json holen
|
|
||||||
# Aktuellen Editor aus global/config.json holen
|
# Aktuellen Editor aus global/config.json holen
|
||||||
get_editor_cmd() {
|
get_editor_cmd() {
|
||||||
if [[ -f "$GLOBAL_CONFIG" ]]; then
|
if [[ -f "$GLOBAL_CONFIG" ]]; then
|
||||||
@@ -335,7 +334,6 @@ get_editor_cmd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Projektdateien bearbeiten (Dateiauswahl + Editor)
|
# Projektdateien bearbeiten (Dateiauswahl + Editor)
|
||||||
# Projektdateien bearbeiten mit dialog-Dateimanager
|
|
||||||
edit_project_files() {
|
edit_project_files() {
|
||||||
local project=$1
|
local project=$1
|
||||||
local project_dir="$PROJECTS_DIR/$project"
|
local project_dir="$PROJECTS_DIR/$project"
|
||||||
@@ -359,7 +357,6 @@ edit_project_files() {
|
|||||||
"$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 ',' ' ')
|
||||||
@@ -412,6 +409,101 @@ edit_project_auto_subversion() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Hauptmenü - Registryverwaltung
|
||||||
|
registry_menu() {
|
||||||
|
while true; do
|
||||||
|
choice=$(whiptail --title "Registry-Verwaltung" --menu "Bitte wählen:" 20 70 10 \
|
||||||
|
1 "Registry erstellen" \
|
||||||
|
2 "Registry löschen" \
|
||||||
|
3 "Registry bearbeiten" \
|
||||||
|
0 "Zurück" \
|
||||||
|
3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
|
case $choice in
|
||||||
|
1) create_registry ;;
|
||||||
|
2) delete_registry ;;
|
||||||
|
3) edit_registry ;;
|
||||||
|
0) return ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Registry anlegen
|
||||||
|
create_registry() {
|
||||||
|
local name url username password
|
||||||
|
|
||||||
|
name=$(whiptail --inputbox "Name der Registry (z.B. docker.io):" 10 60 3>&1 1>&2 2>&3) || return
|
||||||
|
[ -z "$name" ] && return
|
||||||
|
|
||||||
|
url=$(whiptail --inputbox "URL der Registry:" 10 60 3>&1 1>&2 2>&3) || return
|
||||||
|
username=$(whiptail --inputbox "Benutzername:" 10 60 3>&1 1>&2 2>&3) || return
|
||||||
|
password=$(whiptail --passwordbox "Passwort:" 10 60 3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
|
mkdir -p "$REGISTRY_CONFIG_DIR/$name"
|
||||||
|
cat > "$REGISTRY_CONFIG_DIR/$name/config-file" <<EOF
|
||||||
|
url=$url
|
||||||
|
username=$username
|
||||||
|
password=$password
|
||||||
|
EOF
|
||||||
|
|
||||||
|
whiptail --msgbox "Registry '$name' wurde erstellt." 10 60
|
||||||
|
}
|
||||||
|
|
||||||
|
# Registry löschen
|
||||||
|
delete_registry() {
|
||||||
|
local registries
|
||||||
|
registries=$(ls "$REGISTRY_CONFIG_DIR" 2>/dev/null)
|
||||||
|
[ -z "$registries" ] && { whiptail --msgbox "Keine Registries vorhanden." 10 60; return; }
|
||||||
|
|
||||||
|
menu_list=()
|
||||||
|
for r in $registries; do
|
||||||
|
menu_list+=("$r" "")
|
||||||
|
done
|
||||||
|
|
||||||
|
local reg
|
||||||
|
reg=$(whiptail --menu "Registry zum Löschen auswählen:" 20 60 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
|
if whiptail --yesno "Registry $reg wirklich löschen?" 10 60; then
|
||||||
|
rm -rf "$REGISTRY_CONFIG_DIR/$reg"
|
||||||
|
whiptail --msgbox "Registry $reg wurde gelöscht." 10 60
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Registry bearbeiten
|
||||||
|
edit_registry() {
|
||||||
|
local registries
|
||||||
|
registries=$(ls "$REGISTRY_CONFIG_DIR" 2>/dev/null)
|
||||||
|
[ -z "$registries" ] && { whiptail --msgbox "Keine Registries vorhanden." 10 60; return; }
|
||||||
|
|
||||||
|
menu_list=()
|
||||||
|
for r in $registries; do
|
||||||
|
menu_list+=("$r" "")
|
||||||
|
done
|
||||||
|
|
||||||
|
local reg
|
||||||
|
reg=$(whiptail --menu "Registry zum Bearbeiten auswählen:" 20 60 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
|
local config_file="$REGISTRY_CONFIG_DIR/$reg/config-file"
|
||||||
|
local url username password
|
||||||
|
|
||||||
|
url=$(grep "^url=" "$config_file" | cut -d= -f2)
|
||||||
|
username=$(grep "^username=" "$config_file" | cut -d= -f2)
|
||||||
|
password=$(grep "^password=" "$config_file" | cut -d= -f2)
|
||||||
|
|
||||||
|
# Eingaben ändern
|
||||||
|
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
|
||||||
|
password=$(whiptail --passwordbox "Passwort:" 10 60 "$password" 3>&1 1>&2 2>&3) || return
|
||||||
|
|
||||||
|
cat > "$config_file" <<EOF
|
||||||
|
url=$url
|
||||||
|
username=$username
|
||||||
|
password=$password
|
||||||
|
EOF
|
||||||
|
|
||||||
|
whiptail --msgbox "Registry '$reg' wurde aktualisiert." 10 60
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# Hauptmenü
|
# Hauptmenü
|
||||||
@@ -421,7 +513,7 @@ main_menu() {
|
|||||||
choice=$(whiptail --title "Image Builder" --menu "Bitte wählen:" 20 70 10 \
|
choice=$(whiptail --title "Image Builder" --menu "Bitte wählen:" 20 70 10 \
|
||||||
1 "Konfiguration" \
|
1 "Konfiguration" \
|
||||||
2 "Projektverwaltung" \
|
2 "Projektverwaltung" \
|
||||||
3 "Repository-Verwaltung" \
|
3 "Registryverwaltung" \
|
||||||
4 "Image-Bauen" \
|
4 "Image-Bauen" \
|
||||||
5 "Image-Verwaltung" \
|
5 "Image-Verwaltung" \
|
||||||
0 "Beenden" \
|
0 "Beenden" \
|
||||||
@@ -430,7 +522,7 @@ main_menu() {
|
|||||||
case $choice in
|
case $choice in
|
||||||
1) config_menu;;
|
1) config_menu;;
|
||||||
2) project_menu;;
|
2) project_menu;;
|
||||||
3) whiptail --msgbox "Repository-Verwaltung (noch nicht implementiert)" 10 70;;
|
3) registry_menu ;;
|
||||||
4) whiptail --msgbox "Image-Bauen (noch nicht implementiert)" 10 70;;
|
4) whiptail --msgbox "Image-Bauen (noch nicht implementiert)" 10 70;;
|
||||||
5) whiptail --msgbox "Image-Verwaltung (noch nicht implementiert)" 10 70;;
|
5) whiptail --msgbox "Image-Verwaltung (noch nicht implementiert)" 10 70;;
|
||||||
0) exit 0;;
|
0) exit 0;;
|
||||||
|
|||||||
Reference in New Issue
Block a user