Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. #!/bin/bash
  2. set -e
  3.  
  4. function debug(){
  5. if [ -z DEBUG ]; then
  6. echo $@;
  7. fi
  8. }
  9.  
  10. if [ $# -ne 2 ]; then
  11. echo "Usage is $0 delivery_zip sv_zip";
  12. exit 1;
  13. else
  14. debug "I'm gonna put $1 into $2";
  15. fi
  16.  
  17. debug "Checking configuration, looking at redirect to ensure we are using the same value everywhere";
  18.  
  19. function getversion(){
  20. local __resultvar=$1
  21. local tmpresult=$(python -c "import json; f = open('$2'); data = json.load(f); f.close(); print data['VERSION']")
  22. eval $__resultvar="'$tmpresult'"
  23. }
  24.  
  25. function getredirecturl(){
  26. local __resultvar=$1
  27. local tmpresult=$(python -c "import json; f = open('$2'); data = json.load(f); f.close(); print data['ADMINISTRATION_HOST']")
  28. eval $__resultvar="'$tmpresult'"
  29. }
  30.  
  31. DELIVERY_ZIP=$(realpath $1);
  32. SV_ZIP=$(realpath $2);
  33.  
  34. unzip -p $SV_ZIP opt/seagate/email_sender/config.json > tmp.file.txt
  35. getredirecturl SV_REDIRECT "tmp.file.txt"
  36. tar -xzf $DELIVERY_ZIP --strip-components=1 email_sender/config.json
  37. getversion VERSION "config.json"
  38. getredirecturl CONF_REDIRECT "config.json"
  39. rm tmp.file.txt
  40. rm config.json
  41.  
  42. if [ "$SV_REDIRECT" != "$CONF_REDIRECT" ]; then
  43. echo ""
  44. echo "****************************************************************************************";
  45. echo "The Administration host url is different from the one from the Softvision zip... Exiting";
  46. echo "SV package contains $SV_REDIRECT and new package contains $CONF_REDIRECT";
  47. echo "****************************************************************************************";
  48. exit 2;
  49. fi
  50.  
  51. if [ -d sv_tmp_deployement ]; then
  52. rm -rf sv_tmp_deployement;
  53. fi
  54.  
  55. mkdir sv_tmp_deployement;
  56. TOP_FOLDER=$PWD;
  57. {
  58. cd sv_tmp_deployement;
  59. unzip -q "$SV_ZIP";
  60. cd opt/seagate/;
  61. rm -rf email_sender templetator templetator_config update_scripts apply_patches.sh
  62. tar xzf $DELIVERY_ZIP;
  63. cd $TOP_FOLDER/sv_tmp_deployement;
  64. ZIPVERSION=$(echo $SV_ZIP | sed "s/XXX/$VERSION/")
  65. if [ -f $ZIPVERSION ]; then
  66. rm $ZIPVERSION;
  67. fi
  68. zip -q -r $ZIPVERSION *
  69. md5sum $ZIPVERSION > $ZIPVERSION.md5sum
  70. echo "$ZIPVERSION Generated successfully"
  71. }
  72. cd $TOP_FOLDER
  73. rm -rf sv_tmp_deployement;
  74. mv $ZIPVERSION .
  75. mv $ZIPVERSION.md5sum .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement