From 48944c32acc5d550b7c2154cd36b5aae72c7daa4 Mon Sep 17 00:00:00 2001 From: Roland Date: Sat, 5 Nov 2022 14:38:00 -0600 Subject: [PATCH] Reworking install scripts to run parts in parallel. --- scripts/install_debian_11.sh | 32 ++++++++++++++++++++--------- scripts/install_map_ubuntu_20.04.sh | 2 +- scripts/install_ubuntu_20.04.sh | 30 +++++++++++++++++++-------- scripts/reset_map.sh | 2 +- 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/scripts/install_debian_11.sh b/scripts/install_debian_11.sh index e2df0ee1..ead1ab56 100755 --- a/scripts/install_debian_11.sh +++ b/scripts/install_debian_11.sh @@ -11,14 +11,18 @@ apt install -y apt-transport-https ca-certificates curl gnupg-agent gcc libpq-de chromium chromium-driver cpufrequtils network-manager npm # Install Archiving tools. -npm install -g 'git+https://github.com/gildas-lormeau/SingleFile' -npm install -g 'git+https://github.com/pirate/readability-extractor' - -# Build React app -[[ ! -f /usr/local/bin/serve || ! -f /usr/bin/serve ]] && npm -g install serve -cd /opt/wrolpi/app || exit 5 -npm install || npm install || npm install || npm install # try install multiple times -npm run build +SF_VERSION="1.0.15" +if [ "$(single-file --version)" != "${SF_VERSION}" ]; then + ( + wget --continue https://github.com/gildas-lormeau/SingleFile/archive/refs/tags/v${SF_VERSION}.tar.gz -O \ + /tmp/SingleFile.git.tar.gz + cd /tmp + tar xf SingleFile.git.tar.gz + cd SingleFile-${SF_VERSION} + npm install + ) & # Install in background. +fi +readability-extractor --version || npm install -g 'git+https://github.com/pirate/readability-extractor' # Setup the virtual environment that main.py expects pip3 --version || ( @@ -27,8 +31,16 @@ pip3 --version || ( python3 /tmp/get-pip.py ) -# Install python requirements files -pip3 install -r /opt/wrolpi/requirements.txt +# Build React app in background job. +[[ ! -f /usr/local/bin/serve || ! -f /usr/bin/serve ]] && npm -g install serve +cd /opt/wrolpi/app || exit 5 +npm install || npm install || npm install || npm install # try install multiple times :( +npm run build & + +# Install python requirements files in background job. +pip3 install -r /opt/wrolpi/requirements.txt & + +wait $(jobs -p) # Install the WROLPi nginx config over the default nginx config. cp /opt/wrolpi/nginx.conf /etc/nginx/nginx.conf diff --git a/scripts/install_map_ubuntu_20.04.sh b/scripts/install_map_ubuntu_20.04.sh index 823ca660..941999f4 100755 --- a/scripts/install_map_ubuntu_20.04.sh +++ b/scripts/install_map_ubuntu_20.04.sh @@ -19,7 +19,7 @@ set -e [ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -1)" ] && apt update # Install map dependencies. apt install -y libboost-all-dev git tar unzip wget bzip2 build-essential autoconf libtool libxml2-dev libgeos-dev \ - libgeos++-dev libpq-dev libbz2-dev libproj-dev munin-node munin protobuf-c-compiler libfreetype6-dev libtiff5-dev \ + libgeos++-dev libpq-dev libbz2-dev libproj-dev protobuf-c-compiler libfreetype6-dev libtiff5-dev \ libicu-dev libgdal-dev libcairo2-dev libcairomm-1.0-dev libagg-dev liblua5.2-dev ttf-unifont lua5.1 liblua5.1-0-dev \ postgis postgresql-12-postgis-3 postgresql-12-postgis-3-scripts osm2pgsql gdal-bin libmapnik-dev mapnik-utils \ python3-mapnik apache2 apache2-dev libcurl4-gnutls-dev libiniparser-dev libmemcached-dev librados-dev \ diff --git a/scripts/install_ubuntu_20.04.sh b/scripts/install_ubuntu_20.04.sh index 06b1c0d5..7afa5a94 100755 --- a/scripts/install_ubuntu_20.04.sh +++ b/scripts/install_ubuntu_20.04.sh @@ -5,7 +5,7 @@ set -x set -e # Install npm repos. -curl -fsSL https://deb.nodesource.com/setup_14.x | bash - +npm --version || curl -fsSL https://deb.nodesource.com/setup_14.x | bash - # Update if we haven't updated in the last day. [ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -1)" ] && apt update # Install dependencies @@ -14,8 +14,18 @@ apt install -y apt-transport-https ca-certificates curl gnupg-agent gcc libpq-de ffmpeg hostapd nodejs chromium-browser chromium-chromedriver cpufrequtils network-manager # Install Archiving tools. -npm install -g 'git+https://github.com/gildas-lormeau/SingleFile' -npm install -g 'git+https://github.com/pirate/readability-extractor' +SF_VERSION="1.0.15" +if [ "$(single-file --version)" != "${SF_VERSION}" ]; then + ( + wget --continue https://github.com/gildas-lormeau/SingleFile/archive/refs/tags/v${SF_VERSION}.tar.gz -O \ + /tmp/SingleFile.git.tar.gz + cd /tmp + tar xf SingleFile.git.tar.gz + cd SingleFile-${SF_VERSION} + npm install + ) & # Install in background. +fi +readability-extractor --version || npm install -g 'git+https://github.com/pirate/readability-extractor' # Setup the virtual environment that main.py expects pip3 --version || ( @@ -24,14 +34,16 @@ pip3 --version || ( python3 /tmp/get-pip.py ) -# Install python requirements files -pip3 install -r /opt/wrolpi/requirements.txt - -# Build React app +# Build React app in background job. [[ ! -f /usr/local/bin/serve || ! -f /usr/bin/serve ]] && npm -g install serve cd /opt/wrolpi/app || exit 5 -npm install || npm install || npm install || npm install # try install multiple times -npm run build +npm install || npm install || npm install || npm install # try install multiple times :( +npm run build & + +# Install python requirements files in background job. +pip3 install -r /opt/wrolpi/requirements.txt & + +wait $(jobs -p) # Install the WROLPi nginx config over the default nginx config. cp /opt/wrolpi/nginx.conf /etc/nginx/nginx.conf diff --git a/scripts/reset_map.sh b/scripts/reset_map.sh index baedf1cb..e1d797ee 100755 --- a/scripts/reset_map.sh +++ b/scripts/reset_map.sh @@ -26,7 +26,7 @@ Help() { } FORCE=false -while getopts ":hf:" option; do +while getopts ":hf" option; do case $option in h) # display Help Help