Created
July 1, 2014 10:01
-
-
Save benevans/ecffd5e0f83684beb41c to your computer and use it in GitHub Desktop.
Enable/disable an Artifactory Proxies' offline mode from the command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0'?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" | |
xmlns:af="http://artifactory.jfrog.org/xsd/1.5.1"> | |
<xsl:output method="text" indent="no"/> | |
<xsl:template match="text()"/> | |
<xsl:template match="af:config/af:offlineMode"> | |
<xsl:value-of select="./text()" /> | |
</xsl:template> | |
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0'?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" | |
xmlns:af="http://artifactory.jfrog.org/xsd/1.5.1"> | |
<xsl:template match="@*|node()"> | |
<xsl:copy> | |
<xsl:apply-templates select="@*|node()"/> | |
</xsl:copy> | |
</xsl:template> | |
<xsl:template match="af:offlineMode/text()"> | |
<xsl:value-of select="$offline" /> | |
</xsl:template> | |
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ENDPOINT="http://localhost:8081/artifactory/api/system/configuration" | |
USER=$(grep '^artifactory.username' ~/.build.properties | cut -d= -f2 |tr -d ' ') | |
PASS=$(grep '^artifactory.password' ~/.build.properties | cut -d= -f2 |tr -d ' ') | |
CURL_OPTS="-s --user "$USER:$PASS" --url $ENDPOINT" | |
cd $(dirname $0) | |
newval=$1; shift | |
if [ -z "$newval" ]; then | |
# query | |
result=$(curl $CURL_OPTS | xsltproc af-offline-query.xsl -) | |
echo offline: $result | |
else | |
# update | |
curl $CURL_OPTS | | |
xsltproc --stringparam offline "$newval" af-offline-set.xsl - | | |
curl $CURL_OPTS -H "Content-type:application/xml" -d @- >/dev/null | |
fi | |
# vi: set filetype=bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment