        location /update_download {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

            default_type text/plain;

            content_by_lua '
                local args = ngx.req.get_uri_args()
                local ecosystem = args.ecosystem or 0
                ngx.say(ecosystem)

                local handle = io.popen("bash /opt/redpitaya/www/apps/updater/download.sh "..ecosystem.." &")
                local res = handle:read("*a")
                handle:close()

                ngx.say(res)
            ';
        }

        location /update_check {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

            default_type text/plain;

            content_by_lua '
                local handle = io.popen("bash /opt/redpitaya/www/apps/updater/check.sh")
                local res = handle:read("*a")
                handle:close()

                ngx.say(res)
            ';
        }

        location /update_list {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

            default_type text/plain;

            content_by_lua '
                local args = ngx.req.get_uri_args()
                local type = args.type or 0
                local handle = io.popen("bash /opt/redpitaya/www/apps/updater/list.sh "..type)
                local res = handle:read("*a")
                handle:close()

                ngx.say(res)
            ';
        }

        location /update_extract {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

            default_type text/plain;

            content_by_lua '
                local handle = io.popen("bash /opt/redpitaya/www/apps/updater/extract.sh")
                local res = handle:read("*a")
                handle:close()

                ngx.say(res)
            ';
        }

        location /update_ecosystem {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

            default_type text/plain;

            content_by_lua '
                os.execute("/bin/cp -f /opt/redpitaya/www/apps/updater/daemon /tmp && /tmp/daemon")
                ngx.say("OK")
            ';
        }

        location /get_info {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

            default_type application/json;

            content_by_lua '
                local f = io.open("/opt/redpitaya/www/apps/info/info.json", "r")
                local content = f:read("*all")
                content = content:sub(1, -4)
                f:close()

                f = io.popen("fw_printenv | grep hw_rev=STEM_125-10")
                local stem_content = f:read("*all")
                local stem_version = ""

                if stem_content == "" then
                    stem_version = [["STEM 14"\n]]
                else
                    stem_version = [["STEM 10"\n]]
                end

                f:close()

                ngx.say(content .. [[\n,"stem_ver": ]] .. stem_version .. "}")
            ';
        }

        location /update_changelog {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
            add_header 'Content-type' 'text/plain; charset=utf-8';

            default_type text/plain;

            content_by_lua '
                local args = ngx.req.get_uri_args()
                local id = args.id or 0
                local handle = io.popen("bash /opt/redpitaya/www/apps/updater/changelog.sh "..id)
                local res = handle:read("*a")
                handle:close()

                ngx.say(res)
            ';
        }
