Last active
July 28, 2016 10:00
-
-
Save tonvanbart/593b345cd0bd4cdcf1aac377fa5d0ae0 to your computer and use it in GitHub Desktop.
Create a zip-of-zips from a given directory structure.
This file contains 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 | |
main() { | |
if [ "$#" -ne 2 ]; then | |
printusage | |
exit 0 | |
fi | |
dozip $1 $2 | |
} | |
function dozip { | |
cd $1 | |
for d in $(ls -d */); do | |
echo "zipping $d" | |
cd $d | |
zip ../$d.zip * | |
cd .. | |
done | |
echo "creating $2.zip" | |
zip ../$2.zip * | |
} | |
function printusage { | |
cat << EXPLEND | |
Helper script to create a provisioning package. | |
Usage: $0 <directory> <zipname> | |
Creates a zip-of-zips from <directory> and names it "<zipname>.zip" | |
First, all top level directories inside are zipped one by one, then the top level directory is zipped. | |
If the output zipfile already exists, it will be updated. | |
EXPLEND | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment