77 map.entrypoint.sh : |
88 echo "Startup"
99 pip install requests PyJWT cryptography
10- apk add bash
10+ apk add bash git nodejs npm curl zip jq
11+ echo "Installing hugo"
12+ HUGO_VERSION="0.69.2"
13+ curl -sLo "/tmp/hugo.tgz" "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz"
14+ tar -xzf /tmp/hugo.tgz
15+ chmod a+x /hugo
16+ mv /hugo /usr/bin/hugo
17+ echo "Installing dart-saas"
18+ npm install -g sass
19+ echo "First manual run of update map"
20+ bash /map.update.sh
1121 echo "*/10 * * * * /bin/bash /map.update.sh" >> /etc/crontabs/root
1222 echo "Starting cron"
1323 crond -f -L /proc/1/fd/1 -l 4
1424 echo "Error: Cron exited"
25+ map.build.zip.sh : |
26+ if [ -d /workspace ]; then
27+ rm -rf /workspace
28+ fi
29+ git clone --recursive https://github.com/nycmeshnet/nycmesh.net /workspace
30+ cd /workspace
31+ export STANDALONE_MAP_BUILD="true"
32+ export NODE_OPTIONS='--openssl-legacy-provider'
33+ sh update-map.sh
34+ export HUGO_ENVIRONMENT="production"
35+ export HUGO_CACHEDIR="/tmp/hugo_cache"
36+ hugo --minify --baseURL "https://nycmesh.net/"
37+ echo "Build Map Payload"
38+ mkdir -p public/map/img/
39+ mv public/img/map/ public/map/img/map/
40+ mv public/favicon.ico public/map/favicon.ico
41+ mv public/404.html public/map/
42+ echo "Make zip"
43+ if [ -f "/content/new_content.zip" ]; then
44+ rm /content/new_content.zip
45+ fi
46+ cd public/map
47+ if [ -f "./index.html" ]; then
48+ zip -r /content/new_content.zip .
49+ fi
50+ cd /
51+ rm -rf /workspace
1552 map.update.sh : |
1653 #!/bin/bash
1754 echo "Updating content"
18- python3 /get_content.py
55+ if [ ! -z "$BUILD_MAP" ]; then
56+ echo "building map"
57+ bash /map.build.zip.sh
58+ else
59+ echo "downloading map"
60+ python3 /get_content.py
61+ fi
62+ content_zip="/content/new_content.zip"
1963 echo "Update counter"
2064 content_dir="/content/current"
2165 counter_file="/content/counter"
@@ -26,14 +70,16 @@ data:
2670 ((counter++))
2771 echo "$counter" > "$counter_file"
2872 echo "Counter is $counter"
29- if [ "$counter" -gt "500" ]; then
73+ if [ "$counter" -gt "500" ] && [ -f "$content_zip" ] ; then
3074 echo "Reset counter"
3175 rm -f $counter_file
3276 rm -rf $content_dir
3377 fi
34- echo "Unpacking content"
35- content_zip="/content/new_content.zip"
36- unzip -o $content_zip -d $content_dir
37- echo "Cleanup"
38- rm -f $content_zip
39- # Cleanup downloaded content
78+ if [ -f "$content_zip" ]; then
79+ echo "Unpacking content"
80+ unzip -o $content_zip -d $content_dir
81+ echo "Cleanup"
82+ rm -f $content_zip
83+ else
84+ echo "content zip not found"
85+ fi
0 commit comments