Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #!/bin/bash
  2. # Creates a base64-encoded self-extracting tar archive. The extracting system
  3. # must have GNU tar, GNU coreutils (for base64), and bzip2 installed.
  4. # Created June 2011 by Mike Bourgeous
  5. # Released into the public domain, or if that is not possible, under CC0
  6.  
  7. function create_archive()
  8. {
  9. set -e
  10. echo '#!/bin/sh'
  11. echo 'cat << _SFX_EOF_ | base64 -d | tar -jxp'
  12. tar -jcv -- "$@" | base64 -w 120
  13. RESULT=${PIPESTATUS[0]}
  14. echo '_SFX_EOF_'
  15. return $RESULT
  16. }
  17.  
  18. if [ "$1" = "" -o "$2" = "" ]; then
  19. echo "Usage: $0 output_file input_files..."
  20. echo "Use '-' for output_file to send to stdout"
  21. exit 1
  22. fi
  23.  
  24. OUTFILE="$1"
  25.  
  26. set -e
  27.  
  28. shift
  29.  
  30. if [ "$OUTFILE" = "-" ]; then
  31. create_archive "$@"
  32. else
  33. create_archive "$@" > "$OUTFILE"
  34. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement