From 3d2de6f4dd20a32b411cd19d7c5726b3d952aae8 Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Sat, 25 Sep 2021 16:56:16 +0200 Subject: [PATCH] . --- salt/pillars/rmt.sls | 11 ++++++++ update.sh | 65 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/salt/pillars/rmt.sls b/salt/pillars/rmt.sls index 5b0be44..653e6da 100644 --- a/salt/pillars/rmt.sls +++ b/salt/pillars/rmt.sls @@ -8,3 +8,14 @@ rmt: - rmt-server-mirror.timer - rmt-server-sync.timer - rmt-server-systems-scc-sync.timer + + products: + - + name: SUSE Linux Enterprise Server 15 SP3 x86_64 + id: 2140 + - + name: SUSE Linux Enterprise High Performance Computing 15 SP3 x86_64 + id: 2133 + - + name: Containers Module 15 SP3 x86_64 + id: 2157 diff --git a/update.sh b/update.sh index 86d127a..6572db3 100755 --- a/update.sh +++ b/update.sh @@ -8,10 +8,13 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" function printHelp(){ cat << EOF Usage ${0##*/} [options..] --h,-?, --help Show help and exit --N, --network configure network settings --s, --salt run a masterless salt-call --y, --yes answer 'yes' on all questions +-h,-?, --help Show help and exit +-N, --network configure network settings +-s, --salt run a masterless salt-call +-y, --yes answer 'yes' on all questions +--rmt-sync Sync database with SUSE Customer Center +--rmt-enable-products Enable all preconfigured repositories +--rmt-mirror Mirror repositories EOF } @@ -135,6 +138,41 @@ function configure_network(){ } +function rmt_sync(){ + new_log "Sync RMT Database with SUSE Customer Center" + if asktobreak; then + return + fi + sudo rmt-cli sync + +} + +function rmt_enable_products(){ + new_log "Enable the following products in RMT?" + eval $(parse_yaml salt/pillars/rmt.sls "SALT_") + if [[ -f salt/pillars/local.sls ]];then + eval $(parse_yaml salt/pillars/local.sls "SALT_") + fi + for name in "${SALT_rmt_products__name[@]}"; do + echo " * $name" + done + if asktobreak; then + return + fi + sudo rmt-cli products enable "${SALT_rmt_products__id[*]}" + + +} + +function rmt_mirror(){ + new_log "Mirror all repositories" + if asktobreak; then + return + fi + sudo rmt-cli mirror all + +} + ######################### # # Main Script @@ -146,6 +184,9 @@ ALL=true SALT=false NETWORK=false ANSWER_YES=false +RMT_SYNC=false +RMT_MIRROR=false +RMT_ENABLE_PRODUCTS=false while :; do case ${1-noop} in @@ -164,6 +205,18 @@ while :; do -y|--yes) ANSWER_YES=true ;; + --rmt-sync) + RMT_SYNC=true + ALL=false + ;; + --rmt-mirror) + RMT_MIRROR=true + ALL=false + ;; + --rmt-enable-products) + RMT_ENABLE_PRODUCTS=true + ALL=false + ;; --) #End of all options shift break @@ -184,6 +237,10 @@ done [[ $ALL == true ]] || [[ $NETWORK == true ]] && configure_network [[ $ALL == true ]] || [[ $SALT == true ]] && do_salt_call +[[ $ALL == true ]] || [[ $RMT_SYNC == true ]] && rmt_sync +[[ $ALL == true ]] || [[ $RMT_ENABLE_PRODUCTS == true ]] && rmt_enable_products +[[ $ALL == true ]] || [[ $RMT_MIRROR == true ]] && rmt_mirror + printf "\n DONE!!!!!!!\n"