parse input fiile to array before provcessing
This commit is contained in:
parent
f2b2c021f8
commit
0c2b8da54f
@ -5,14 +5,14 @@
|
||||
if [[ -z $1 ]] ; then
|
||||
echo "parse a list of parameters and execute script with those parameters"
|
||||
echo "parse-list.sh <param file> <script> [<noisy> <additional> <additional> <additional>]"
|
||||
echo "<param file|org='organisation'> name of file containing parameters"
|
||||
echo " or the organisation list of repos"
|
||||
echo "<script> script to run (e.g. rename-e-smith-pkh.sh)"
|
||||
echo "optional params can appear in any order"
|
||||
echo " <review> show line being executed but do NOTHING!"
|
||||
echo " <noisy> show line being executed"
|
||||
echo " <additional> additional params to be passed (up to 3)"
|
||||
exit 0
|
||||
echo "<param file|org='organisation'> name of file containing parameters"
|
||||
echo " or the organisation list of repos"
|
||||
echo "<script> script to run (e.g. rename-e-smith-pkh.sh)"
|
||||
echo "optional params can appear in any order"
|
||||
echo " <review> show line being executed but do NOTHING!"
|
||||
echo " <noisy> show line being executed"
|
||||
echo " <additional> additional params to be passed (up to 3)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# parse the command line parameters
|
||||
@ -86,9 +86,10 @@ for param in $3 $4 $5 $6; do
|
||||
fi
|
||||
done
|
||||
|
||||
# Build array of parameters to cycle through
|
||||
PARAMLIST=
|
||||
if [ $PROCESSORG ] ; then
|
||||
# cycle through the repos in the specified organisation
|
||||
# get a list of repositories in the source organisation
|
||||
# get a list of repositories in the source organisation and store in array of parameters
|
||||
for page in {1..10} ; do
|
||||
if [ $DEBUG ] ; then echo "getting page $page of repos from $GITEAHOST $PROCESSORG" ; fi
|
||||
RESPONSE=$(curl -s -X 'GET' \
|
||||
@ -105,19 +106,23 @@ if [ $PROCESSORG ] ; then
|
||||
echo $RESPONSE | grep -oP '(?<="name":").+?(?=")' | while read repo; do
|
||||
if [[ $NOISY || $REVIEW ]] ; then echo "$2 $repo $EXTRAPARAMS" ; fi
|
||||
if [[ ! $REVIEW ]] ; then
|
||||
if [[ $repo ]] ; then $2 $repo $EXTRAPARAMS ; fi
|
||||
if [[ $repo ]] ; then $PARAMLIST+=$repo ; fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
else
|
||||
# read through input file and run script using params from file
|
||||
while read -r line
|
||||
do
|
||||
if [[ $NOISY || $REVIEW ]] ; then echo "$2 $line $EXTRAPARAMS" ; fi
|
||||
if [[ ! $REVIEW ]] ; then
|
||||
if [[ $line ]] ; then $2 $line $EXTRAPARAMS ; fi
|
||||
fi
|
||||
done < $1
|
||||
# load array of parameters from input file
|
||||
while read -r line ; do $PARAMLIST+=$line ; done < $1
|
||||
fi
|
||||
|
||||
# Cycle through array of parameters and execute script
|
||||
for param in "${PARAMLIST[@]}"
|
||||
do
|
||||
if [[ $NOISY || $REVIEW ]] ; then echo "$2 $param $EXTRAPARAMS" ; fi
|
||||
if [[ ! $REVIEW ]] ; then
|
||||
if [[ $line ]] ; then $2 $param $EXTRAPARAMS ; fi
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user