Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -e
- function debug(){
- if [ -z DEBUG ]; then
- echo $@;
- fi
- }
- if [ $# -ne 2 ]; then
- echo "Usage is $0 delivery_zip sv_zip";
- exit 1;
- else
- debug "I'm gonna put $1 into $2";
- fi
- debug "Checking configuration, looking at redirect to ensure we are using the same value everywhere";
- function getversion(){
- local __resultvar=$1
- local tmpresult=$(python -c "import json; f = open('$2'); data = json.load(f); f.close(); print data['VERSION']")
- eval $__resultvar="'$tmpresult'"
- }
- function getredirecturl(){
- local __resultvar=$1
- local tmpresult=$(python -c "import json; f = open('$2'); data = json.load(f); f.close(); print data['ADMINISTRATION_HOST']")
- eval $__resultvar="'$tmpresult'"
- }
- DELIVERY_ZIP=$(realpath $1);
- SV_ZIP=$(realpath $2);
- unzip -p $SV_ZIP opt/seagate/email_sender/config.json > tmp.file.txt
- getredirecturl SV_REDIRECT "tmp.file.txt"
- tar -xzf $DELIVERY_ZIP --strip-components=1 email_sender/config.json
- getversion VERSION "config.json"
- getredirecturl CONF_REDIRECT "config.json"
- rm tmp.file.txt
- rm config.json
- if [ "$SV_REDIRECT" != "$CONF_REDIRECT" ]; then
- echo ""
- echo "****************************************************************************************";
- echo "The Administration host url is different from the one from the Softvision zip... Exiting";
- echo "SV package contains $SV_REDIRECT and new package contains $CONF_REDIRECT";
- echo "****************************************************************************************";
- exit 2;
- fi
- if [ -d sv_tmp_deployement ]; then
- rm -rf sv_tmp_deployement;
- fi
- mkdir sv_tmp_deployement;
- TOP_FOLDER=$PWD;
- {
- cd sv_tmp_deployement;
- unzip -q "$SV_ZIP";
- cd opt/seagate/;
- rm -rf email_sender templetator templetator_config update_scripts apply_patches.sh
- tar xzf $DELIVERY_ZIP;
- cd $TOP_FOLDER/sv_tmp_deployement;
- ZIPVERSION=$(echo $SV_ZIP | sed "s/XXX/$VERSION/")
- if [ -f $ZIPVERSION ]; then
- rm $ZIPVERSION;
- fi
- zip -q -r $ZIPVERSION *
- md5sum $ZIPVERSION > $ZIPVERSION.md5sum
- echo "$ZIPVERSION Generated successfully"
- }
- cd $TOP_FOLDER
- rm -rf sv_tmp_deployement;
- mv $ZIPVERSION .
- mv $ZIPVERSION.md5sum .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement