Last active
April 28, 2023 00:14
-
-
Save mokrates/382d63c82862c0d176edae8f75127261 to your computer and use it in GitHub Desktop.
self extracting archive with bash
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 | |
if [ "${1::1}" == "/" ]; then | |
echo "refusing to archive absolute filenames" >&2 | |
exit 1 | |
fi | |
while [ "$1" != "" ]; do | |
if [ -d "$1" ]; then | |
"$0" "$1"/* | |
shift | |
else | |
if [ "$(dirname $1)" != "." ]; then | |
echo "mkdir -p '$(dirname $1)'" | |
fi | |
echo "base64 -d << '+++' | gunzip > '$1'" | |
cat "$1" | gzip | base64 | |
echo +++ | |
shift | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment