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
|
# $1 = Module name e.g. e-smith-dnscache
|
||||||
# $2 = Organisation (smeserver or user - defaults to smeserver)
|
# $2 = Organisation (smeserver or user - defaults to smeserver)
|
||||||
# $3 = "local" will use parameters set for local repository else it will use remote
|
# $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)
|
# 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
|
# 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!
|
# Also note: I have had difficulty deleting all the link files in the source tree!
|
||||||
#
|
#
|
||||||
|
|
||||||
if [[ -z $1 ]] ; then
|
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
|
exit 0
|
||||||
fi
|
fi
|
||||||
clear
|
clear
|
||||||
echo "**************************************************************************************************"
|
echo "**************************************************************************************************"
|
||||||
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 "* *"
|
||||||
echo "**************************************************************************************************"
|
echo "**************************************************************************************************"
|
||||||
|
|
||||||
@ -74,15 +76,21 @@ SOURCEHOST=${remote_GITEAHOST}
|
|||||||
SOURCEACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
SOURCEACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||||||
SOURCEORG="smeserver"
|
SOURCEORG="smeserver"
|
||||||
TARGETORG=${remote_USER}
|
TARGETORG=${remote_USER}
|
||||||
for param in $2 $3 ; do
|
DELETEIT=
|
||||||
|
for param in $2 $3 $4 $5; do
|
||||||
if [ $param ] ; then
|
if [ $param ] ; then
|
||||||
if [[ $param == "local" ]] ; then
|
case $param in
|
||||||
SOURCEHOST=${local_GITEAHOST}
|
local )
|
||||||
|
SOURCEHOST=${local_GITEAHOST}
|
||||||
SOURCEACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
SOURCEACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
||||||
TARGETORG=${local_USER}
|
TARGETORG=${local_USER} ;;
|
||||||
else
|
force )
|
||||||
SOURCEORGORG=$param
|
DELETIT=true ;;
|
||||||
fi
|
debug )
|
||||||
|
DEBUG=true ;;
|
||||||
|
* )
|
||||||
|
SOURCEORGORG=$param ;;
|
||||||
|
esac
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -105,23 +113,25 @@ fi
|
|||||||
if [ $DEBUG ] ; then echo "Check if $TARGETORG/$TARGETPKG is there!" ; 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")
|
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$SOURCEHOST/api/v1/repos/$TARGETORG/$TARGETPKG")
|
||||||
if [ "$RESPONSE" == "200" ]; then
|
if [ "$RESPONSE" == "200" ]; then
|
||||||
echo "Repository for $TARGETORG/$TARGETPKG exists!"
|
echo "Repository for $TARGETORG/$TARGETPKG exists!"
|
||||||
while true; do
|
while true; do
|
||||||
read -p "Do you wish to delete it and continue?(y/n) " yn
|
read -p "Do you wish to delete it and continue?(y/n) " yn
|
||||||
case $yn in
|
case $yn in
|
||||||
[Yy]* )
|
[Yy]* )
|
||||||
RESPONSE=$(curl "$checkSSL" "$SILENT" -X 'DELETE' \
|
DELETEIT=true
|
||||||
"$SOURCEHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
|
break ;;
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H "Authorization: token $SOURCEACCESSTOKEN" )
|
|
||||||
break;;
|
|
||||||
[Nn]* )
|
[Nn]* )
|
||||||
echo "************Abandoning Fork of $SOURCEORG/$SOURCEPKG on $SOURCEHOST ($RESPONSE)"
|
echo "************Abandoning Fork of $SOURCEORG/$SOURCEPKG on $SOURCEHOST ($RESPONSE)"
|
||||||
exit 1;;
|
exit 1 ;;
|
||||||
* ) echo "Please answer yes or no.";;
|
* ) echo "Please answer yes or no.";;
|
||||||
esac
|
esac
|
||||||
done
|
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
|
else
|
||||||
if [ $DEBUG ] ; then echo "Repository for $TARGETORG/$TARGETPKG does not exist on $SOURCEHOST" ; fi
|
if [ $DEBUG ] ; then echo "Repository for $TARGETORG/$TARGETPKG does not exist on $SOURCEHOST" ; fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user