forked from no-dice/django-bootstrap-themes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·43 lines (36 loc) · 1.47 KB
/
update.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
39
40
41
42
43
#!/bin/sh
set -e
#
# Bootstrap 3 / 4 theme updater
#
# dependencies: linux shell, busybox <https://busybox.net/>, jq <https://stedolan.github.io/jq/>
#
# usage: ./update.sh
#
DIRNAME=$(dirname $0)
THEMEPATH="${DIRNAME}/bootstrap_themes/static/bootstrap/themes"
btversions=("https://bootswatch.com/api/3.json" "https://bootswatch.com/api/4.json")
btreleases="https://api.github.com/repos/twbs/bootstrap/releases"
csstypes=("css" "cssMin")
for btversion in ${btversions[@]}; do
for csstype in ${csstypes[@]}; do
curl $btversion | jq -r ".themes[]|.${csstype}" | while read url; do wget -P "$THEMEPATH" -x -nH $url; done
done
done
for ver in 3 4; do
lv="$(curl -s $btreleases | jq '.[].assets[].browser_download_url' | sort | pcregrep "bootstrap-${ver}[\.\d]+-dist.zip" | tail -1 | tr -d \")"
[ -d "$THEMEPATH/${ver}/default" ] && rm -rf "$THEMEPATH/${ver}/default"
wget -qO- $lv | busybox unzip -qd "$THEMEPATH/${ver}" - && mv $THEMEPATH/${ver}/bootstrap-${ver}* "$THEMEPATH/${ver}/default"
done
echo "Generate themes.py..."
cat <<EOL > ${DIRNAME}/bootstrap_themes/themes.py
# themes.py autogenerated $(date +%F.%T), edits will be overriden, see update.sh script
bootstrap3_themes = (
$(for theme in bootstrap_themes/static/bootstrap/themes/3/*; do echo "('${theme##*/}', '${theme##*/}'),"; done)
)
bootstrap4_themes = (
$(for theme in bootstrap_themes/static/bootstrap/themes/4/*; do echo "('${theme##*/}', '${theme##*/}'),"; done)
)
EOL
# End of file
# vim: set ts=2 sw=2 noet: