add load_global_config
This commit is contained in:
@@ -26,6 +26,17 @@ ensure_prereqs() {
|
||||
done
|
||||
}
|
||||
|
||||
load_global_config() {
|
||||
if [[ -f "$GLOBAL_CONFIG" ]]; then
|
||||
EDITOR_CMD=$(jq -r '.editor // "nano"' "$GLOBAL_CONFIG")
|
||||
else
|
||||
EDITOR_CMD="nano"
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_dirs
|
||||
load_global_config
|
||||
|
||||
# -------------------------
|
||||
# Konfigurations-Menü
|
||||
# -------------------------
|
||||
@@ -306,6 +317,82 @@ edit_project_files() {
|
||||
fi
|
||||
}
|
||||
|
||||
edit_project_registries() {
|
||||
local config_file=$1
|
||||
# vorhandene registries aus Config
|
||||
local current=$(grep "^registry=" "$config_file" | cut -d= -f2 | tr ',' ' ')
|
||||
|
||||
# alle bekannten Registries aus Registry-Verwaltung
|
||||
local all_registries=$(ls "$REGISTRY_CONFIG_DIR" 2>/dev/null)
|
||||
|
||||
menu_list=()
|
||||
for r in $all_registries; do
|
||||
if [[ " $current " =~ " $r " ]]; then
|
||||
menu_list+=("$r" "$r" ON)
|
||||
else
|
||||
menu_list+=("$r" "$r" OFF)
|
||||
fi
|
||||
done
|
||||
|
||||
selected=$(whiptail --title "Registries auswählen" --checklist "Mehrere auswählen" 20 70 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||
# whiptail gibt " " separierte Liste zurück, entfernen von Anführungszeichen
|
||||
selected=$(echo $selected | tr -d '"')
|
||||
sed -i "s|^registry=.*|registry=$selected|" "$config_file"
|
||||
}
|
||||
|
||||
edit_project_architectures() {
|
||||
local config_file=$1
|
||||
local current=$(grep "^architectures=" "$config_file" | cut -d= -f2 | tr ',' ' ')
|
||||
local all_archs=("amd64" "arm64" "armhf" "x86")
|
||||
menu_list=()
|
||||
for a in "${all_archs[@]}"; do
|
||||
if [[ " $current " =~ " $a " ]]; then
|
||||
menu_list+=("$a" "$a" ON)
|
||||
else
|
||||
menu_list+=("$a" "$a" OFF)
|
||||
fi
|
||||
done
|
||||
selected=$(whiptail --title "Architekturen auswählen" --checklist "Mehrere auswählen" 20 70 10 "${menu_list[@]}" 3>&1 1>&2 2>&3) || return
|
||||
selected=$(echo $selected | tr -d '"')
|
||||
sed -i "s|^architectures=.*|architectures=$selected|" "$config_file"
|
||||
}
|
||||
|
||||
edit_project_push() {
|
||||
local config_file=$1
|
||||
local current=$(grep "^push=" "$config_file" | cut -d= -f2)
|
||||
local value="OFF"
|
||||
[ "$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 == *push* ]] && val="yes" || val="no"
|
||||
sed -i "s|^push=.*|push=$val|" "$config_file"
|
||||
}
|
||||
|
||||
edit_project_latest() {
|
||||
local config_file=$1
|
||||
local current=$(grep "^latest=" "$config_file" | cut -d= -f2)
|
||||
local value="OFF"
|
||||
[ "$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 == *latest* ]] && val="yes" || val="no"
|
||||
sed -i "s|^latest=.*|latest=$val|" "$config_file"
|
||||
}
|
||||
|
||||
edit_project_auto_subversion() {
|
||||
local config_file=$1
|
||||
local current=$(grep "^auto_subversion=" "$config_file" | cut -d= -f2)
|
||||
local value="OFF"
|
||||
[ "$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 == *auto* ]] && val="yes" || val="no"
|
||||
# falls auto_subversion key nicht existiert, hinzufügen
|
||||
if grep -q "^auto_subversion=" "$config_file"; then
|
||||
sed -i "s|^auto_subversion=.*|auto_subversion=$val|" "$config_file"
|
||||
else
|
||||
echo "auto_subversion=$val" >> "$config_file"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# -------------------------
|
||||
# Hauptmenü
|
||||
# -------------------------
|
||||
|
||||
Reference in New Issue
Block a user