Last active
November 3, 2022 08:06
-
-
Save xlcommunity/3080aabf38f584dd8db6 to your computer and use it in GitHub Desktop.
Small set of utilities to get/export/import templates from XL Release servers.
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 | |
##################################################################################################### | |
# | |
# THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS | |
# FOR A PARTICULAR PURPOSE. THIS CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS. | |
# | |
##################################################################################################### | |
PROGNAME=${0##*/} | |
USERNAME=admin | |
PASSWORD=admin | |
XLRELEASE_HOSTNAME=localhost | |
XLRELEASE_PORT=5516 | |
XLRELEASE_PROTOCOL=http | |
CURL=/usr/bin/curl | |
CURL_SWITCHES=-s | |
OPTIONS=`getopt -s bash -o h --long user:,password:,hostname:,port:,protocol: --name $PROGNAME -- "$@" ` | |
eval set -- "$OPTIONS" | |
while true; do | |
case "$1" in | |
--user) | |
USERNAME=$2 | |
;; | |
--password) | |
PASSWORD=$2 | |
;; | |
--hostname) | |
XLRELEASE_HOSTNAME=$2 | |
;; | |
--port) | |
XLRELEASE_PORT=$2 | |
;; | |
--protocol) | |
XLRELEASE_PROTOCOL=$2 | |
;; | |
--) | |
shift | |
break | |
;; | |
esac | |
shift | |
done | |
if [ -d "export" ]; | |
then | |
rm -f export/* | |
else | |
mkdir export | |
fi | |
for TEMPLATE_ID in `cat templatesToExport.txt` | |
do | |
echo "Exporting template id: $TEMPLATE_ID" | |
PREPARE_DOWNLOAD_KEY=`$CURL $CURL_SWITCHES $XLRELEASE_PROTOCOL://$USERNAME:$PASSWORD@$XLRELEASE_HOSTNAME:$XLRELEASE_PORT/releases/$TEMPLATE_ID/export?format=zip` | |
DOWNLOAD_KEY=`echo $PREPARE_DOWNLOAD_KEY | cut -d'"' -f4` | |
echo $DOWNLOAD_KEY | |
$CURL $CURL_SWITCHES -o export/$TEMPLATE_ID.xlr $XLRELEASE_PROTOCOL://$USERNAME:$PASSWORD@$XLRELEASE_HOSTNAME:$XLRELEASE_PORT/export/zip/$DOWNLOAD_KEY | |
done |
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 | |
##################################################################################################### | |
# | |
# THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS | |
# FOR A PARTICULAR PURPOSE. THIS CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS. | |
# | |
##################################################################################################### | |
PROGNAME=${0##*/} | |
USERNAME=admin | |
PASSWORD=admin | |
XLRELEASE_HOSTNAME=localhost | |
XLRELEASE_PORT=5516 | |
XLRELEASE_PROTOCOL=http | |
CURL=/usr/bin/curl | |
CURL_SWITCHES=-s | |
OPTIONS=`getopt -s bash -o h --long user:,password:,hostname:,port:,protocol: --name $PROGNAME -- "$@" ` | |
eval set -- "$OPTIONS" | |
while true; do | |
case "$1" in | |
--user) | |
USERNAME=$2 | |
;; | |
--password) | |
PASSWORD=$2 | |
;; | |
--hostname) | |
XLRELEASE_HOSTNAME=$2 | |
;; | |
--port) | |
XLRELEASE_PORT=$2 | |
;; | |
--protocol) | |
XLRELEASE_PROTOCOL=$2 | |
;; | |
--) | |
shift | |
break | |
;; | |
esac | |
shift | |
done | |
for TEMPLATE_FILE in `cd export;ls -1` | |
do | |
UPLOAD_TOKEN=`curl -s -u ${USERNAME}:${PASSWORD} http://localhost:5516/upload/token/templates` | |
#echo "$TEMPLATE_FILE token = $UPLOAD_TOKEN" | |
CURL_FILE_TO_BE_UPLOADED="-F'file=@export/$TEMPLATE_FILE" | |
$CURL $CURL_SWITCHES -H "Content-Type: multipart/form-data" $XLRELEASE_PROTOCOL://$USERNAME:$PASSWORD@$XLRELEASE_HOSTNAME:$XLRELEASE_PORT/upload/templates/zip/$UPLOAD_TOKEN -X POST $CURL_FILE_TO_BE_UPLOADED | |
echo "" | |
done |
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 | |
##################################################################################################### | |
# | |
# THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS | |
# FOR A PARTICULAR PURPOSE. THIS CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS. | |
# | |
##################################################################################################### | |
PROGNAME=${0##*/} | |
USERNAME=admin | |
PASSWORD=admin | |
XLRELEASE_HOSTNAME=localhost | |
XLRELEASE_PORT=5516 | |
XLRELEASE_PROTOCOL=http | |
CURL=/usr/bin/curl | |
CURL_SWITCHES=-s | |
TEMPIDS="tmpids.txt" | |
OPTIONS=`getopt -s bash -o h --long user:,password:,hostname:,port:,protocol: --name $PROGNAME -- "$@" ` | |
eval set -- "$OPTIONS" | |
while true; do | |
case "$1" in | |
--user) | |
USERNAME=$2 | |
;; | |
--password) | |
PASSWORD=$2 | |
;; | |
--hostname) | |
XLRELEASE_HOSTNAME=$2 | |
;; | |
--port) | |
XLRELEASE_PORT=$2 | |
;; | |
--protocol) | |
XLRELEASE_PROTOCOL=$2 | |
;; | |
--) | |
shift | |
break | |
;; | |
esac | |
shift | |
done | |
$CURL $CURL_SWITCHES $XLRELEASE_PROTOCOL://$USERNAME:$PASSWORD@$XLRELEASE_HOSTNAME:$XLRELEASE_PORT/api/v1/templates | grep -Po '"id":"Applications\\\/.[^\\]*?"' > $TEMPIDS | |
rm -f templatesToExport.txt | |
for TEMPLATE in `cat ${TEMPIDS}` | |
do | |
TEMPLATE_ID=`echo $TEMPLATE | cut -d'/' -f2 | cut -d'"' -f1` | |
echo $TEMPLATE_ID >> templatesToExport.txt | |
done | |
rm -f $TEMPIDS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment