Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 27 lines (20 sloc) 732 Bytes
#!/bin/sh
set -ex
umask 0022 # allow rX for group/other
tmpdir="$(dirname "<%= @dest %>")/razor-$$" # not very secure
trap "rm -rf '${tmpdir}'" exit
mkdir -p "${tmpdir}"
# OK, we need to download and unpack the archive into the destination...
curl -Lo "${tmpdir}"/scratch.zip "<%= @url %>"
# Now, unpack it in the same location.
unzip -d "${tmpdir}" "${tmpdir}"/scratch.zip
rm -rf "${tmpdir}"/scratch.zip
# Finally, move that into place overwriting the destination files, but
# avoiding destroying additional files. This helps with upgrades...
mkdir -p "<%= @dest %>"
if ! tar cC "${tmpdir}/<%= @root %>" . | tar xC "<%= @dest %>"; then
rm -rf "<%= @dest %>"
exit 1
fi
# ...done.
exit 0