The current version will be found at https://gist.github.com/mike-bourgeous/a48f8e8c87be9f0875bed16980ab1775
Please make all comments, stars, forks, etc. there.
The current version will be found at https://gist.github.com/mike-bourgeous/a48f8e8c87be9f0875bed16980ab1775
Please make all comments, stars, forks, etc. there.
#!/bin/bash | |
# Creates a base64-encoded self-extracting tar archive. The extracting system | |
# must have GNU tar, GNU coreutils (for base64), and bzip2 installed. | |
# Created June 2011 by Mike Bourgeous | |
# Released into the public domain, or if that is not possible, under CC0 | |
function create_archive() | |
{ | |
set -e | |
echo '#!/bin/sh' | |
echo 'cat << _SFX_EOF_ | base64 -d | tar -jxp' | |
tar -jcv -- "$@" | base64 -w 120 | |
RESULT=${PIPESTATUS[0]} | |
echo '_SFX_EOF_' | |
return $RESULT | |
} | |
if [ "$1" = "" -o "$2" = "" ]; then | |
echo "Usage: $0 output_file input_files..." | |
echo "Use '-' for output_file to send to stdout" | |
exit 1 | |
fi | |
OUTFILE="$1" | |
set -e | |
shift | |
if [ "$OUTFILE" = "-" ]; then | |
create_archive "$@" | |
else | |
create_archive "$@" > "$OUTFILE" | |
fi |