### Install and Start Oryx React UI Source: https://github.com/ossrs/oryx/blob/main/DEVELOPER.md This command installs the necessary Node.js dependencies for the Oryx React UI and then starts the development server. It requires Node.js and npm to be installed. The UI will be accessible at http://localhost:3000. ```bash (cd ui && npm install && npm start) ``` -------------------------------- ### Install and Start Oryx Service (JavaScript) Source: https://github.com/ossrs/oryx/blob/main/scripts/setup-bt/index.html This JavaScript code installs, starts, and manages the Oryx service. It queries the SRS, cleans up installations, and uses asynchronous operations to handle the process. The code also updates the UI with progress messages and disables buttons during the installation process. It also dispatches a management command. ```JavaScript async function installOryx() { _request('querySrs'); console.log(`installing pid is ${JSON.stringify(pid)}`); if (pid.r0) { await oryx_request('cleanupIntall'); } await new Promise((resolve, reject) => { installing(resolve, reject); }); layer.msg('Oryx启动中,请稍后......', {icon: 1}); $('.btn_install_srs').html('正在启动').attr({'disabled': 'disabled'}); await new Promise(resolve => setTimeout(resolve, 30000)); layer.msg('Oryx安装成功', {icon: 1}); $('.btn_install_srs').html('安装完成').attr({'disabled': 'disabled'}); await new Promise(resolve => setTimeout(resolve, 1500)); await oryx_dispatch($("p[name='mgmt']")); } $(function () { oryx_init(); }); ``` -------------------------------- ### Build and Install BT Plugin Source: https://github.com/ossrs/oryx/blob/main/DEVELOPER.md This bash script sequence first uninstalls any existing BT plugin, removes a configuration file, then creates a zip archive of the plugin for installation. Finally, it installs the newly built BT plugin within the 'bt' Docker container. ```bash docker exec -it bt bash /www/server/panel/plugin/oryx/install.sh uninstall 2>/dev/null || echo OK && docker exec -it bt rm -f /data/config/.env && bash scripts/setup-bt/auto/zip.sh --output $(pwd)/build --extract && docker exec -it bt bash /www/server/panel/plugin/oryx/install.sh install ``` -------------------------------- ### Install BT Plugin via Python Scripts Source: https://github.com/ossrs/oryx/blob/main/DEVELOPER.md This command sequence executes Python scripts within the 'bt' Docker container to manage site configurations and install the Oryx plugin. It performs uninstallation, environment file removal, and then installs the plugin using a setup script with specified parameters. ```bash docker exec -it bt python3 /www/server/panel/plugin/oryx/bt_api_remove_site.py && docker exec -it bt python3 /www/server/panel/plugin/oryx/bt_api_create_site.py && docker exec -it bt python3 /www/server/panel/plugin/oryx/bt_api_setup_site.py && docker exec -it bt bash /www/server/panel/plugin/oryx/setup.sh \ --r0 /tmp/oryx_install.r0 --nginx /www/server/nginx/logs/nginx.pid \ --www /www/wwwroot --site srs.stack.local ``` -------------------------------- ### Start aaPanel Plugin Development Container Source: https://github.com/ossrs/oryx/blob/main/DEVELOPER.md Starts a Docker container for aaPanel plugin development, mounting the local Oryx build directory as a plugin. It configures necessary ports, environment variables, and volumes for a development environment. Ensure the BT API key is configured and saved to $HOME/.bt/api.json. ```bash docker rm -f bt aapanel 2>/dev/null && AAPANEL_KEY=$(cat $HOME/.bt/api.json |awk -F token_crypt '{print $2}' |cut -d'"' -f3) && docker run -p 80:80 -p 443:443 -p 7800:7800 -p 1935:1935 -p 8000:8000/udp -p 10080:10080/udp \ --env CANDIDATE=$(ifconfig en0 |grep 'inet ' |awk '{print $2}') \ -v $(pwd)/build/oryx:/www/server/panel/plugin/oryx \ -v $HOME/.bt/api.json:/www/server/panel/config/api.json -e BT_KEY=$AAPANEL_KEY \ --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host \ -d --rm -it -v $(pwd):/g -w /g --name=aapanel ossrs/aapanel-plugin-dev:1 ``` -------------------------------- ### Install Oryx using Helm Source: https://github.com/ossrs/oryx/blob/main/DEVELOPER.md These commands demonstrate different ways to install Oryx using Helm. The first installs the latest version from the added repository. The second installs from a local tgz file, and the third installs from a tgz file while configuring persistent storage path. ```bash helm install srs srs/oryx helm install srs ~/git/srs-helm/stable/oryx-1.0.6.tgz helm install srs ~/git/srs-helm/stable/oryx-1.0.6.tgz \ --set persistence.path=$HOME/data ``` -------------------------------- ### Attempt Oryx Installation (JavaScript) Source: https://github.com/ossrs/oryx/blob/main/scripts/setup-aapanel/index.html Initiates the Oryx installation process. It validates the domain input, checks service readiness, and calls the appropriate installation functions. Includes error handling and UI updates. ```javascript async function oryx_try_install() { const domain = $('.txt_srs_domain').val(); if (!domain) { alert('Please input the domain'); throw 'no domain'; } const domainRegex = /^(?=.{1,253})(?:(?!-)[A-Za-z0-9-]{1,63}(?/dev/null || echo ok && docker rm -f redis srs 2>/dev/null && docker run --rm -it --name oryx -v $HOME/data:/data \ -p 2022:2022 -p 2443:2443 -p 1935:1935 -p 8000:8000/udp -p 10080:10080/udp \ -p 80:2022 -p 443:2443 -e CANDIDATE=$(ifconfig en0 |grep 'inet ' |awk '{print $2}') \ platform ``` -------------------------------- ### Oryx Installation Core Logic (JavaScript) Source: https://github.com/ossrs/oryx/blob/main/scripts/setup-aapanel/index.html Executes the core installation steps for Oryx. This includes checking and installing dependencies (like NGINX, Docker), creating and setting up the SRS site, and configuring the firewall. ```javascript async function oryx_install() { if ($('.install_log').empty()) { $('.install_log').show().val('Installing...\n'); } let tips = layer.msg('Check the service status.', {icon: 16}); const services = await oryx_request('serviceStatus'); console.log(`services status is ${JSON.stringify(services)}`); layer.close(tips); // If BT or aaPanel not ready to install SRS, should wait. if (services?.plugin_ready !== 'ok') { const msg = `Installing Oryx plugin, please try again later.`; layer.msg(msg, {icon: 2}); throw msg; } // Request to install depends services. const deps = [ ...(services?.nginx ? [] : [{id: 'nginx', title: 'NGINX', call: 'bt.soft.install'}]), ]; // If no docker manager plugin, or docker service, install the plugin. // If there is a docker installed, we only need to start it, don't require the docker plugin. if (!services?.docker_manager && !services?.docker_installed) { deps.push({id: 'docker', title: 'Docker', call: 'bt.soft.install'}); } const tasks = await oryx_request('installTasks'); const notInstalledDeps = deps.filter(dep => { if (tasks.filter(task => { return task?.name?.indexOf(`[${dep.id}-`) >= 0 ? task : null; }).length > 0) { return null; } return dep; }); if (notInstalledDeps.length) { return await install_dependence(notInstalledDeps); } if (deps.length) { return await installing_dependence(deps); } // Try to install docker service. if (!services?.docker_installed) { layer.msg('Install Docker service', {icon: 1}); await oryx_request('installService', {service: 'docker'}); await new Promise(resolve => setTimeout(resolve, 1000)); } // Try to start docker service. if (!services?.docker_running) { layer.msg('Start Docker service', {icon: 1}); await oryx_request('restartService', {service: 'docker'}); await new Promise(resolve => setTimeout(resolve, 1000)); } // Try to create site for Oryx. if (!services?.site_created) { const domain = $('.txt_srs_domain').val(); layer.msg(`Create the Oryx website: ${domain}`, {icon: 1}); const site = await oryx_request('createSrsSite', {domain: domain}); console.log(`Create site ${JSON.stringify(site)}`); await new Promise(resolve => setTimeout(resolve, 1000)); } // Setup the website. Note that it depends on http configuration files. if (!services?.site_setup) { layer.msg('Setup the Oryx website', {icon: 1}); const data = await oryx_request('setupSrsSite'); console.log('setup site', data); await new Promise(resolve => setTimeout(resolve, 1000)); } // Setup the firewall. if (!services?.firewall_ready) { layer.msg('Setup the firewall', {icon: 1}); const data = await oryx_request('setupFirewall'); console.log('setup firewall', data); await new Promise(resolve => setTimeout(resolve, 1000)); } } ``` -------------------------------- ### Start SRS and Redis using Docker on macOS Source: https://github.com/ossrs/oryx/blob/main/DEVELOPER.md This command starts Redis and SRS services using Docker on a macOS development environment. It ensures previous containers are stopped and removed, maps necessary ports, and mounts configuration and data volumes. It requires Docker to be installed and the `ossrs/srs:5` image to be available. ```bash docker stop redis 2>/dev/null || echo ok && docker rm -f redis srs 2>/dev/null && docker run --name redis --rm -it -v $HOME/data/redis:/data -p 6379:6379 -d redis:5.0 && touch platform/containers/data/config/srs.server.conf platform/containers/data/config/srs.vhost.conf && docker run --name srs --rm -it \ -v $(pwd)/platform/containers/data/config:/usr/local/srs/containers/data/config \ -v $(pwd)/platform/containers/conf/srs.release-mac.conf:/usr/local/srs/conf/docker.conf \ -v $(pwd)/platform/containers/objs/nginx:/usr/local/srs/objs/nginx \ -p 1935:1935 -p 1985:1985 -p 8080:8080 -p 8000:8000/udp -p 10080:10080/udp \ -d ossrs/srs:5 ``` -------------------------------- ### Install Packer and DigitalOcean Plugin for Building SRS Droplet Image Source: https://github.com/ossrs/oryx/blob/main/DEVELOPER.md Installs Packer and the DigitalOcean plugin required for building the SRS droplet image on DigitalOcean. Ensure you have Homebrew installed for macOS. ```bash brew tap hashicorp/tap && brew install hashicorp/tap/packer && PACKER_LOG=1 packer plugins install github.com/digitalocean/digitalocean ``` -------------------------------- ### Core SRS Installation Logic (JavaScript) Source: https://github.com/ossrs/oryx/blob/main/scripts/setup-bt/index.html Manages the detailed installation of SRS, including checking and installing dependencies like Nginx and Docker if necessary. It also handles site creation, setup, and firewall configuration. Relies heavily on `oryx_request` for various backend operations and UI feedback via `layer.msg`. Dependencies: jQuery, `oryx_request`, `install_dependence`, `installing_dependence`. ```javascript async function oryx_install() { if ($('.install_log').empty()) { $('.install_log').show().val('Installing...\n'); } let tips = layer.msg('检测服务状态', {icon: 16}); const services = await oryx_request('serviceStatus'); console.log(`services status is ${JSON.stringify(services)}`); layer.close(tips); // If BT or aaPanel not ready to install SRS, should wait. if (services?.plugin_ready !== 'ok') { const msg = `正在安装SRS插件,请稍后再试`; layer.msg(msg, {icon: 2}); throw msg; } // Request to install depends services. const deps = [ ...(services?.nginx ? [] : [{id: 'nginx', title: 'NGINX', call: 'bt.soft.install'}]), ]; // If no docker manager plugin, or docker service, install the plugin. // If there is a docker installed, we only need to start it, don't require the docker plugin. if (!services?.docker_manager && !services?.docker_installed) { deps.push({id: 'docker', title: 'Docker', call: 'bt.soft.install'}); } const tasks = await oryx_request('installTasks'); const notInstalledDeps = deps.filter(dep => { if (tasks.filter(task => { return task?.name?.indexOf(`[${dep.id}-`) >= 0 ? task : null; }).length > 0) { return null; } return dep; }); if (notInstalledDeps.length) { return await install_dependence(notInstalledDeps); } if (deps.length) { return await installing_dependence(deps); } // Try to install docker service. if (!services?.docker_installed) { layer.msg('安装Docker服务', {icon: 1}); await oryx_request('installService', {service: 'docker'}); await new Promise(resolve => setTimeout(resolve, 1000)); } // Try to start docker service. if (!services?.docker_running) { layer.msg('启动Docker服务', {icon: 1}); await oryx_request('restartService', {service: 'docker'}); await new Promise(resolve => setTimeout(resolve, 1000)); } // Try to create site for Oryx. if (!services?.site_created) { const domain = $('.txt_srs_domain').val(); layer.msg(`创建Oryx站点: ${domain}`, {icon: 1}); const site = await oryx_request('createSrsSite', {domain: domain}); console.log(`Create site ${JSON.stringify(site)}`); await new Promise(resolve => setTimeout(resolve, 1000)); } // Setup the website. Note that it depends on http configuration files. if (!services?.site_setup) { layer.msg('设置Oryx站点', {icon: 1}); const data = await oryx_request('setupSrsSite'); console.log('setup site', data); await new Promise(resolve => setTimeout(resolve, 1000)); } // Setup the firewall. if (!services?.firewall_ready) { layer.msg('设置防火墙', {icon: 1}); const data = await oryx_request('setupFirewall'); console.log('setup firewall', data); await new Promise(resolve => setTimeout(resolve, 1000)); } } ``` -------------------------------- ### Run System Tests for Script Installer Source: https://github.com/ossrs/oryx/blob/main/DEVELOPER.md Runs a comprehensive suite of system tests for the script installer. This involves generating environment variables, compiling tests, and executing the test binary with various configurations for HTTP and HTTPS endpoints. The tests verify system stability and API interactions, with options to control test timeouts, verbosity, and parallel execution. ```bash rm -f test/oryx.test && docker exec -it script make -j -C test && bash scripts/tools/secret.sh --output test/.env && sleep 5 && docker exec -it script ./test/oryx.test -test.timeout=1h -test.failfast -test.v -endpoint http://localhost:2022 \ -srs-log=true -wait-ready=true -init-password=true -check-api-secret=true -init-self-signed-cert=true \ -test.run TestSystem_Empty && bash scripts/tools/secret.sh --output test/.env && sleep 5 && docker exec -it script ./test/oryx.test -test.timeout=1h -test.failfast -test.v -wait-ready -endpoint http://localhost:2022 \ -srs-log=true -wait-ready=true -init-password=false -check-api-secret=true \ -test.parallel 3 && docker exec -it script ./test/oryx.test -test.timeout=1h -test.failfast -test.v -wait-ready -endpoint https://localhost:2443 \ -srs-log=true -wait-ready=true -init-password=false -check-api-secret=true \ -test.parallel 3 ``` -------------------------------- ### Build and Install aaPanel Plugin Source: https://github.com/ossrs/oryx/blob/main/DEVELOPER.md This script sequence first uninstalls any existing Oryx plugin, then builds a zip archive of the plugin, and finally installs it into the aaPanel environment within the Docker container. It handles potential errors during the uninstall process. ```bash docker exec -it aapanel rm -f /data/config/.env && docker exec -it aapanel bash /www/server/panel/plugin/oryx/install.sh uninstall 2>/dev/null || echo OK && bash scripts/setup-aapanel/auto/zip.sh --output $(pwd)/build --extract && docker exec -it aapanel bash /www/server/panel/plugin/oryx/install.sh install ``` -------------------------------- ### Install and Uninstall BT Plugin Source: https://github.com/ossrs/oryx/blob/main/DEVELOPER.md This snippet handles the installation and uninstallation of the BT plugin for Oryx. It first attempts to uninstall any existing version of the plugin, then zips up the new plugin files, copies them to the server, unzips them, and finally installs the plugin. ```bash ssh root@$LNAME.$LDOMAIN bash /www/server/panel/plugin/oryx/install.sh uninstall 2>/dev/null || echo OK && bash scripts/setup-bt/auto/zip.sh --output $(pwd)/build --extract && scp build/bt-oryx.zip root@$LNAME.$LDOMAIN:~ && ssh root@$LNAME.$LDOMAIN unzip -q bt-oryx.zip -d /www/server/panel/plugin && ssh root@$LNAME.$LDOMAIN bash /www/server/panel/plugin/oryx/install.sh install ``` -------------------------------- ### Run Oryx Backend Application Source: https://github.com/ossrs/oryx/blob/main/DEVELOPER.md This command executes the Oryx platform backend application using Go. It navigates to the 'platform' directory and runs the main application file. Ensure the Go environment is set up and dependencies are installed. ```bash (cd platform && go run .) ``` -------------------------------- ### Test Build Script and Install Script in Docker Container Source: https://github.com/ossrs/oryx/blob/main/DEVELOPER.md Executes the uninstallation script, followed by the build script, and then the installation script within the 'script' Docker container. This sequence ensures the installer is tested in a clean environment. The output of the build script is directed to the './build' directory in the host system. ```bash docker exec -it script rm -f /data/config/.env && docker exec -it script bash build/oryx/scripts/setup-ubuntu/uninstall.sh 2>/dev/null || echo OK && bash scripts/setup-ubuntu/build.sh --output $(pwd)/build --extract && docker exec -it script bash build/oryx/scripts/setup-ubuntu/install.sh --verbose ``` -------------------------------- ### Start BT Plugin Development Container Source: https://github.com/ossrs/oryx/blob/main/DEVELOPER.md This bash script starts a Docker container for BT plugin development. It removes existing containers, retrieves a BT API token, and mounts local build artifacts into the container. It configures environment variables for the candidate IP and API key, and sets up necessary volume mounts for persistent data and configurations. The container runs in detached mode with privileged access. ```bash docker rm -f bt aapanel 2>/dev/null && BT_KEY=$(cat $HOME/.bt/api.json |awk -F token_crypt '{print $2}' |cut -d'"' -f3) && docker run -p 80:80 -p 443:443 -p 7800:7800 -p 1935:1935 -p 8000:8000/udp -p 10080:10080/udp \ --env CANDIDATE=$(ifconfig en0 |grep 'inet ' |awk '{print $2}') \ -v $(pwd)/build/oryx:/www/server/panel/plugin/oryx \ -v $HOME/.bt/userInfo.json:/www/server/panel/data/userInfo.json \ -v $HOME/.bt/api.json:/www/server/panel/config/api.json -e BT_KEY=$BT_KEY \ --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host \ -d --rm -it -v $(pwd):/g -w /g --name=bt ossrs/bt-plugin-dev:1 ``` -------------------------------- ### Install Oryx using JavaScript Source: https://github.com/ossrs/oryx/blob/main/scripts/setup-aapanel/index.html Asynchronously installs the Oryx service by repeatedly requesting installation status and updating the UI with progress. It handles success, failure, and log output. Dependencies include 'oryx_request', 'layer', and DOM manipulation via jQuery. ```javascript async function do_oryx_install() { const installing = async (resolve, reject) => { $('.btn_install_srs').html('Installing').attr({'disabled': 'disabled'}); let pos = 1; for (; ;) { try { const pid = await oryx_request('installSrs', {start: pos, end: pos + 100}); console.log(`installing pid is ${JSON.stringify(pid)}`); if (pid.tail) { const elem = $('.install_log').val($('.install_log').val() + pid.tail); if (elem.get(0)?.scrollHeight) elem.get(0).scrollTop = elem.get(0).scrollHeight; } pos += pid.tail ? (pid.tail.match(/\n/g)?.length || 0) : 0; if (pid.srs) return resolve(); if (pid.r0) { layer.msg('Install Oryx failed', {icon: 2}); return reject(pid); } await new Promise(r0 => setTimeout(r0, 3000)); } catch (e) { return reject(e); } } }; const pid = await oryx_request('querySrs'); console.log(`installing pid is ${JSON.stringify(pid)}`); if (pid.r0) { await oryx_request('cleanupIntall'); } await new Promise((resolve, reject) => { installing(resolve, reject); }); layer.msg('Starting Oryx......', {icon: 1}); $('.btn_install_srs').html('Starting').attr({'disabled': 'disabled'}); await new Promise(resolve => setTimeout(resolve, 30000)); layer.msg('Oryx installation successful.', {icon: 1}); $('.btn_install_srs').html('Installed').attr({'disabled': 'disabled'}); await new Promise(resolve => setTimeout(resolve, 1500)); await oryx_dispatch($("p[name='mgmt']")); } $(function () { oryx_init(); }); ``` -------------------------------- ### Install go-openai Package Source: https://github.com/ossrs/oryx/blob/main/platform/vendor/github.com/sashabaranov/go-openai/README.md This command installs the go-openai package, which provides Go clients for the OpenAI API. Ensure you have Go version 1.18 or greater installed. ```bash go get github.com/sashabaranov/go-openai ``` -------------------------------- ### Oryx Initialization and Dispatch Logic in JavaScript Source: https://github.com/ossrs/oryx/blob/main/scripts/setup-aapanel/index.html Initializes the Oryx application by setting up event listeners for menu clicks and the install button. It fetches service status and dispatches the appropriate view based on the Oryx installation state. It also handles querying the SRS process status. ```javascript async function oryx_init() { $(".bt-w-menu p").click(function () { oryx_dispatch($(this)); }); $('.btn_install_srs').click(function () { oryx_try_install(); }); const services = await oryx_request('serviceStatus'); if (services?.site_domain) { $('.txt_srs_domain').val(services?.site_domain); } console.log(`services is ${JSON.stringify(services)}`); if (!services?.srs_ready || services?.srs_error) { $(".bt-w-menu p\[name='install'\]").addClass('bgw').siblings().removeClass('bgw'); $('.install_version_box').show().siblings().hide(); await oryx_setup_install_view(); } else { await oryx_dispatch($("p\[name='mgmt']")); } const pid = await oryx_request('querySrs'); console.log(`srs is ${JSON.stringify(services)}`); if (pid?.running) { await do_oryx_install(); } } async function oryx_refresh_logs() { const pid = await oryx_request('querySrs'); if (pid.tail) { const elem = $('.install_log').val($('.install_log').val() + pid.tail).show(); elem.get(0).scrollTop = elem.get(0)?.scrollHeight; } } async function oryx_dispatch(self) { const menuName = self.attr('name'); const services = await oryx_request('serviceStatus'); if (!services?.srs_ready || services?.srs_error) { if (menuName !== 'install') layer.msg('Please install the Oryx first', {icon: 7}); return console.log(`service not ready ${JSON.stringify(services)}`); } self.addClass('bgw').siblings().removeClass('bgw'); $(`.conter_box\[name=${menuName}\]`).show().siblings().hide(); if (menuName === 'service') { await oryx_setup_service_view(); } else if (menuName === 'mgmt') { await oryx_setup_mgmt_view(); } else if (menuName === 'install') { await oryx_setup_install_view(); } } async function oryx_setup_install_view() { const pid = await oryx_request('querySrs'); console.log(`installing pid is ${JSON.stringify(pid)}`); if (pid?.srs || pid?.running) { $('.b ``` -------------------------------- ### Oryx Dependency Installation Prompts in JavaScript Source: https://github.com/ossrs/oryx/blob/main/scripts/setup-aapanel/index.html Functions to display modal dialogs for installing Oryx dependencies. `install_dependence` shows a list of dependencies to be installed, while `installing_dependence` indicates that dependencies are currently being installed. Both use the `layer` modal library and return Promises. ```javascript async function install_dependence(deps) { const depsContent = deps.map((dep, index) => { return `
Please install the following dependencies:
Please continue to install the Oryx after installing the dependencies.
`, success: function (layero, index) { // Note that this is called when the window is open, not closed or finished. resolve(); }, }); }); } async function installing_dependence(deps) { const depsContent = deps.map((dep, index) => { const desc = `Installing ${dep.title}`; return `Please install the following dependencies: