# HG changeset patch # User Miloslav Zezulka # Date 1503403485 -7200 # Node ID 255adf10b4fd16313b644dca50dad6905e227725 # Parent 2f04aa98a8a92e1cebfe835e5f9092791b4d4651 Copy web-client to web-gateway when web-gateway build is specified Reviewed-by: jerboaa Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-August/024618.html diff -r 2f04aa98a8a9 -r 255adf10b4fd thermostat-ng.sh --- a/thermostat-ng.sh Wed Aug 23 13:56:55 2017 +0200 +++ b/thermostat-ng.sh Tue Aug 22 14:04:45 2017 +0200 @@ -232,16 +232,6 @@ build "$WEB_CLIENT_ROOT" npm_build } -# deploy web-client resources statically, more info at http://icedtea.classpath.org/pipermail/thermostat/2017-May/023164.html -copy_web_client_to_web_gateway() { - local dist_dir="${WEB_CLIENT_ROOT}/dist"; - if [ -d "$dist_dir" ]; then - cp -r $dist_dir $WEB_GATEWAY_ROOT/distribution/target/image/web-client; - echo "Web client copied to web-gateway." - else - fail "Web client could not be copied to web-gateway because the directory web-client/dist/ does not exist. Make sure the web-client has been built correctly." - fi -} # Shuts down everything in reverse order. # Called via trap @@ -355,12 +345,41 @@ esac } +# deploy web-client resources statically, more info at http://icedtea.classpath.org/pipermail/thermostat/2017-May/023164.html +copy_web_client_to_web_gateway() { + local dist_dir="${WEB_CLIENT_ROOT}/dist"; + if [ -d "$dist_dir" ]; then + cp -r $dist_dir $WEB_GATEWAY_ROOT/distribution/target/image/web-client; + echo "Web client copied to web-gateway." + else + fail "Web client could not be copied to web-gateway because the directory web-client/dist/ does not exist. Make sure the web-client has been built correctly." + fi +} + +build_and_copy_web_client() { + build_web_client; copy_web_client_to_web_gateway +} + +ensure_web_client_present_in_gateway() { + local dist_dir="${WEB_CLIENT_ROOT}/dist"; + if [ -d "$dist_dir" ]; then + cp -r $dist_dir $WEB_GATEWAY_ROOT/distribution/target/image/web-client; + echo "Web client copied to web-gateway." + else + # This is in case both web-client and web-gateway are selected for build; + # we do not want to build web-client twice. + WEB_CLIENT=false; + + build_and_copy_web_client; + fi +} + build_all_requested_components() { if [ "$WEB_GATEWAY" = "true" ]; then - build_web_gateway + build_web_gateway; ensure_web_client_present_in_gateway fi if [ "$WEB_CLIENT" = "true" ]; then - build_web_client; copy_web_client_to_web_gateway + build_and_copy_web_client fi if [ "$AGENT" = "true" ]; then build_agent