add force and debug options
This commit is contained in:
parent
8ab6930155
commit
db6884d245
@ -3,19 +3,21 @@
|
||||
# $1 = Module name e.g. e-smith-dnscache
|
||||
# $2 = Organisation (smeserver or user - defaults to smeserver)
|
||||
# $3 = "local" will use parameters set for local repository else it will use remote
|
||||
# $4 = "force" will automagically delete an existing repo, otherwise it will prompt
|
||||
# $5 = "debug" run in debug mode
|
||||
# This works whether the repo and local files exist of not (it deletes them if necessary)
|
||||
# However if the remote repo exists, it preserves the README.md file so that edits are not lost
|
||||
# Also note: I have had difficulty deleting all the link files in the source tree!
|
||||
#
|
||||
|
||||
if [[ -z $1 ]] ; then
|
||||
echo "************rename-e-smith-pkg.sh <modulename> [<organization> <local>]"
|
||||
echo "************rename-e-smith-pkg.sh <modulename> [<organization> <local> <force> <debug>]"
|
||||
exit 0
|
||||
fi
|
||||
clear
|
||||
echo "**************************************************************************************************"
|
||||
echo "* *"
|
||||
echo "* SMEServer - rename-e-smith-pkg.sh $1 $2 $3 `date` *"
|
||||
echo "* SMEServer - rename-e-smith-pkg.sh $1 $2 $3 $4 $5 `date` *"
|
||||
echo "* *"
|
||||
echo "**************************************************************************************************"
|
||||
|
||||
@ -74,15 +76,21 @@ SOURCEHOST=${remote_GITEAHOST}
|
||||
SOURCEACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||||
SOURCEORG="smeserver"
|
||||
TARGETORG=${remote_USER}
|
||||
for param in $2 $3 ; do
|
||||
DELETEIT=
|
||||
for param in $2 $3 $4 $5; do
|
||||
if [ $param ] ; then
|
||||
if [[ $param == "local" ]] ; then
|
||||
SOURCEHOST=${local_GITEAHOST}
|
||||
case $param in
|
||||
local )
|
||||
SOURCEHOST=${local_GITEAHOST}
|
||||
SOURCEACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
||||
TARGETORG=${local_USER}
|
||||
else
|
||||
SOURCEORGORG=$param
|
||||
fi
|
||||
TARGETORG=${local_USER} ;;
|
||||
force )
|
||||
DELETIT=true ;;
|
||||
debug )
|
||||
DEBUG=true ;;
|
||||
* )
|
||||
SOURCEORGORG=$param ;;
|
||||
esac
|
||||
else
|
||||
break
|
||||
fi
|
||||
@ -105,23 +113,25 @@ fi
|
||||
if [ $DEBUG ] ; then echo "Check if $TARGETORG/$TARGETPKG is there!" ; fi
|
||||
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$SOURCEHOST/api/v1/repos/$TARGETORG/$TARGETPKG")
|
||||
if [ "$RESPONSE" == "200" ]; then
|
||||
echo "Repository for $TARGETORG/$TARGETPKG exists!"
|
||||
while true; do
|
||||
echo "Repository for $TARGETORG/$TARGETPKG exists!"
|
||||
while true; do
|
||||
read -p "Do you wish to delete it and continue?(y/n) " yn
|
||||
case $yn in
|
||||
[Yy]* )
|
||||
RESPONSE=$(curl "$checkSSL" "$SILENT" -X 'DELETE' \
|
||||
"$SOURCEHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
|
||||
-H 'accept: application/json' \
|
||||
-H "Authorization: token $SOURCEACCESSTOKEN" )
|
||||
break;;
|
||||
DELETEIT=true
|
||||
break ;;
|
||||
[Nn]* )
|
||||
echo "************Abandoning Fork of $SOURCEORG/$SOURCEPKG on $SOURCEHOST ($RESPONSE)"
|
||||
exit 1;;
|
||||
exit 1 ;;
|
||||
* ) echo "Please answer yes or no.";;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $DELETEIT ] ; then
|
||||
RESPONSE=$(curl "$checkSSL" "$SILENT" -X 'DELETE' \
|
||||
"$SOURCEHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
|
||||
-H 'accept: application/json' \
|
||||
-H "Authorization: token $SOURCEACCESSTOKEN" )
|
||||
fi
|
||||
else
|
||||
if [ $DEBUG ] ; then echo "Repository for $TARGETORG/$TARGETPKG does not exist on $SOURCEHOST" ; fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user