-
Notifications
You must be signed in to change notification settings - Fork 4
/
update-crosware-from-zip.sh
38 lines (32 loc) · 874 Bytes
/
update-crosware-from-zip.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
#
# update crosware from master.zip
#
set -eu
set -o pipefail
function failexit() {
echo "${BASH_SOURCE[0]}: ${@}" 1>&2
exit 1
}
reqs=( 'unzip' 'tar' )
for req in ${reqs[@]} ; do
command -v ${req} >/dev/null 2>&1 || failexit "req ${req} not found"
done
: ${version:="master"}
: ${zipfile:="${version}.zip"}
: ${zipurl:="https://github.com/ryanwoodsmall/crosware/archive/${zipfile}"}
: ${extdir:="crosware-${version}"}
: ${cwtop:="/usr/local/crosware"}
: ${cwtmp:="${cwtop}/tmp"}
if [ ! -e "${cwtmp}" ] ; then
mkdir -p "${cwtmp}" || failexit "could not ${cwtmp} or it does not exist"
fi
pushd "${cwtmp}"
rm -rf "${extdir}"
rm -f "${zipfile}"
curl -kLo "${zipfile}" "${zipurl}" || wget -O "${zipfile}" "${zipurl}"
unzip "${zipfile}"
( cd "${extdir}" ; tar -cf - . | ( cd "${cwtop}" ; tar -xvf - ) )
rm -f "${zipfile}"
rm -rf "${extdir}"
popd