From 9f5c133fdbc58291ead48208b9f525b877473561 Mon Sep 17 00:00:00 2001 From: Thomas Oulevey Date: Sep 09 2015 07:50:13 +0000 Subject: create_sig.sh : add bstinson patch for looping on permissions mash_run.sh : add -d / -f arguments --- diff --git a/cron.d/mash_run.sh b/cron.d/mash_run.sh index 211759a..70efd65 100755 --- a/cron.d/mash_run.sh +++ b/cron.d/mash_run.sh @@ -6,6 +6,8 @@ usage: $0 [-t ] This script generate mash repo from all SIG tags. OPTIONS: + -d mash repo destination : default to $MASH_DEST + -f koji instance fqdn : default to $KOJI_FQDN -t tag(s) : storage7-release, storage7-testing etc... EOF } @@ -15,24 +17,27 @@ EOF KOJI="/usr/bin/koji" # mash binary MASH="/usr/bin/mash" +# default fqdn +KOJI_FQDN="cbs.centos.org" # mash config containing mash.conf MASH_CONF="/etc/mash" # repos destination MASH_DEST="/mnt/kojishare/repos" -# repoviewurl in mash config -MASH_VIEWURL="http://cbs.centos.org/repos" #cache MASH_CACHE="/var/cache/cbs-mash" # log directory LOG_DIR="/var/log/mash" # End Global +optiond=false +optionf=false optiont=false optionv=false -while getopts ":hvt:" OPTION + +while getopts ":hvd:f:t:" OPTION do case ${OPTION} in - h) + h) usage exit 0 ;; @@ -40,24 +45,41 @@ do optiont=true TAGS="${OPTARG}" ;; + d) + optiond=true + MASH_DEST="${OPTARG}" + ;; + f) + optionf=true + KOJI_FQDN="${OPTARG}" + ;; v) - optionv=true - ;; - ?) + optionv=true + ;; + ?) exit 0 ;; - :) + :) echo "Option -${OPTARG} requires an argument." exit 1 ;; - esac + esac done shift $((${OPTIND} - 1)) +# Repoviewurl in mash config +MASH_VIEWURL="http://$KOJI_FQDN/repos" + # Check if user is allowed to send command to koji and has 'admin' permission -PERM=`${KOJI} list-permissions --mine` -if [ "${PERM}" != "admin" ] +PERMS=`${KOJI} list-permissions --mine` + +for P in $PERMS +do + [[ $P == 'admin' ]] && ADMIN=true; break +done + +if [ "$ADMIN" != true ] then echo "[ERROR] Koji misconfigure/missing admin privilege for creating SIG tags" exit 1 diff --git a/scripts/create_sig.sh b/scripts/create_sig.sh index 53db8df..3c57357 100755 --- a/scripts/create_sig.sh +++ b/scripts/create_sig.sh @@ -93,8 +93,15 @@ fi # Check if user is allowed to send command to koji and has 'admin' permission KOJI=`which koji` -PERM=`$KOJI list-permissions --mine` -if [ "$PERM" != "admin" ] +PERMS=`$KOJI list-permissions --mine` +ADMIN=false + +for P in $PERMS +do + [[ $P == 'admin' ]] && ADMIN=true; break +done + +if [ "$ADMIN" != true ] then echo "[ERROR] Koji misconfigure/missing admin privilege for creating SIG tags" exit 1