daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Nov 22nd, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env bash
  2.  
  3. FOLDER=$1
  4. WAR_FILE=$2
  5. DIR=$(pwd)
  6. BACKUP_WAR_FILE="original_$WAR_FILE"
  7.  
  8. if [ -z "$FOLDER" ]
  9. then
  10.   echo "First attribute can't be empty"
  11.   exit 1
  12. fi
  13.  
  14. if [ -z "$WAR_FILE" ]
  15. then
  16.   echo "Second attribute can't be empty"
  17.   exit 1
  18. fi
  19.  
  20. echo "Injecting '$FOLDER' folder structure into $WAR_FILE"
  21. echo "  > Create $WAR_FILE backup: $BACKUP_WAR_FILE"
  22. cp $WAR_FILE $BACKUP_WAR_FILE
  23.  
  24. echo "  > Temporary move $WAR_FILE to $FOLDER"
  25. mv $WAR_FILE $FOLDER
  26. cd $FOLDER
  27.  
  28. echo "  > Repackaging $WAR_FILE with content of $FOLDER"
  29. zip -gr $WAR_FILE ./
  30.  
  31. echo "  > Move repackaged $WAR_FILE original destination: $DIR"
  32. mv $WAR_FILE $DIR
  33. cd $DIR
RAW Paste Data
Top