-
-
Save lpsantil/f6fcd9fbdb0d9f6f6581f68559e313d1 to your computer and use it in GitHub Desktop.
Embed TAR file in a shell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Instructions: | |
# 1) Create your TAR archive | |
# tar -czpf file.tar <file1> <file2> ... <fileN> | |
# 2) Append the TAR file contents to the script | |
# cat file.tar >> embeddedPayload.sh | |
# 3) Run script. (./embeddedPayload.sh) | |
echo "Bash Source: "${BASH_SOURCE[0]} | |
# Script Varibles | |
SCRIPT_DIR="$(cd -P "$( dirname "${BASH_SOURCE[0]}" )" ; pwd)" | |
SKIP=$(awk '/^__TARFILE_FOLLOWS__/ { print NR + 1; exit 0; }' $0) | |
echo "Script Dir: " $SCRIPT_DIR | |
echo "Skip: "$SKIP | |
# Extract | |
echo "Extracting install ... " | |
tail -n +${SKIP} $0 | tar -zpvx | |
exit 0 | |
# NOTE: Don't place any newline characters after the last line below. | |
__TARFILE_FOLLOWS__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment