From 568c2cb57fedf353ac48f5473cda4ea910300836 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Wed, 16 Sep 2020 19:56:06 +0800 Subject: [PATCH] config.cli: use as default by symlinking to config --- .github/workflows/build.yml | 1 - .github/workflows/check.yml | 1 - .github/workflows/codeql-analysis.yml | 3 -- .travis.yml | 2 -- Dockerfile | 1 - README.md | 52 +++++++++++++++------------ config.js | 1 + package.json | 2 +- 8 files changed, 32 insertions(+), 31 deletions(-) create mode 120000 config.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 811888e7..12b4ca81 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,5 @@ jobs: with: node-version: ${{ matrix.node }} - - run: cp config.cli.js config.js - run: npm ci - run: npm run build diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index bb58fe9a..2924e9aa 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -24,6 +24,5 @@ jobs: with: node-version: ${{ matrix.node }} - - run: cp config.cli.js config.js - run: npm ci - run: npm run ${{ matrix.check }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 63c2bbb0..0fc6d770 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,9 +43,6 @@ jobs: with: languages: ${{ matrix.language }} - - name: Use config.cli.js as config.js - run: cp config.cli.js config.js - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - name: Autobuild uses: github/codeql-action/autobuild@v1 diff --git a/.travis.yml b/.travis.yml index 2b341356..00b83f24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,6 @@ matrix: fast_finish: true allow_failures: - node_js: 10 -before_script: - - cp config.cli.js config.js script: - npm run check-source-formatting - npm run lint diff --git a/Dockerfile b/Dockerfile index 9f91eca3..226c1855 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,6 @@ RUN npm set unsafe-perm true RUN npm install # Build package -RUN cp config.cli.js config.js RUN npm run build RUN npm pack --ignore-scripts diff --git a/README.md b/README.md index 508d966c..05e19439 100644 --- a/README.md +++ b/README.md @@ -18,40 +18,47 @@ Check out the [Wiki](https://github.com/jesec/flood/wiki) for more information. ### Pre-Requisites -1. [rTorrent](https://github.com/rakshasa/rtorrent) needs to be installed and running __with XMLRPC__ configuration. - * For Linux & OS X, check out [rTorrent's installation wiki](https://github.com/rakshasa/rtorrent/wiki/Installing#compilation-help) and/or [this third-party tutorial](https://jes.sc/kb/rTorrent+ruTorrent-Seedbox-Guide.php#Install-Dependencies). When you run `./configure`, be sure to run with the `--with-xmlrpc-c` flag. - * For Windows, try [this guide](https://rtwi.jmk.hu/wiki/rTorrentOnWindows). +1. [rTorrent](https://github.com/rakshasa/rtorrent) needs to be installed and running **with XMLRPC** configuration. + - For Linux & OS X, check out [rTorrent's installation wiki](https://github.com/rakshasa/rtorrent/wiki/Installing#compilation-help) and/or [this third-party tutorial](https://jes.sc/kb/rTorrent+ruTorrent-Seedbox-Guide.php#Install-Dependencies). When you run `./configure`, be sure to run with the `--with-xmlrpc-c` flag. + - For Windows, try [this guide](https://rtwi.jmk.hu/wiki/rTorrentOnWindows). 2. Install [NodeJS](https://nodejs.org/) version `Current` (you might want to manage different Node versions with [nodenv](https://github.com/nodenv/nodenv) or [nvm](https://github.com/creationix/nvm) or [n](https://github.com/tj/n)). Flood tracks latest NodeJS release and does NOT provide support to legacy NodeJS versions. 3. Install `node-gyp` pre-requisites, see https://www.npmjs.com/package/node-gyp#installation, ex: `python`, `make`, `gcc`. ### Configuration -Copy `config.template.js` to `config.js` and review its comments. **This is required.** +By default, Flood uses a command line configuration interface. If you installed Flood via `npm`, you should be able to use `flood` or `npx flood` to launch Flood. If you compile Flood from source, you will be able to use `npm run start` to execute Flood. -When loading the web interface, you will be prompted to configure the connection to rtorrent. Other configuration options are handled `config.js`. +Run `flood --help`, `npx flood --help` or `npm run start -- --help` to get help about command line arguments. + +If you want to know more about configurations, check `config.template.js`. + +If static configuration is preferred, copy `config.template.js` to `config.js` and edit it. + +When Flood's builtin user management is enabled (default), you will be prompted to configure the connection to rTorrent when loading the web interface. **What to configure** 1. Be sure to create a long and unique secret (used to sign [JWT auth tokens](https://github.com/auth0/node-jsonwebtoken)). -3. If you are proxying requests to Flood from your own web server, configure Flood's path from the host at the `baseURI` property. All requests will be prefixed with this value. - * For example, if serving Flood from `https://foo.bar/apps/flood`, you would set `baseURI` to `/apps/flood`. If serving flood from `https://foo.bar`, you do not need to configure `baseURI`. - * [Read more about proxying requests to Flood on the Wiki](https://github.com/Flood-UI/flood/wiki/Using-Flood-behind-a-reverse-proxy), this is a common pain-point for users. +2. If you are proxying requests to Flood from your own web server, configure Flood's path from the host at the `--baseuri` (or `baseURI`) property. All requests will be prefixed with this value. + - For example, if serving Flood from `https://foo.bar/apps/flood`, you would set `baseURI` to `/apps/flood`. If serving flood from `https://foo.bar`, you do not need to configure `baseURI`. + - [Read more about proxying requests to Flood on the Wiki](https://github.com/Flood-UI/flood/wiki/Using-Flood-behind-a-reverse-proxy), this is a common pain-point for users. ### Compiling assets and starting the server From the root of the Flood directory... + 1. Run `npm install` if you haven't already or if you've pulled changes. 2. Run `npm run build`. 3. Run `npm start`. -Access the UI in your browser. With default settings, go to `http://localhost:3000`. You can configure the port in `config.js`. +Access the UI in your browser. With default settings, go to `http://localhost:3000`. You can configure the port via `--port` argument. ### Updating I've been bad about cutting actual releases, so check this repo for recent commits. 1. To update, run `git pull` in this repository's directory. -1. Check `config.template.js` for configuration changes that you may wish to incoporate in your `config.js`. +1. Check `config.template.js` for configuration changes that you may wish to incorporate in your `config.js`. 1. Kill the currently running Flood server. 1. Run `npm install` to update dependencies. 1. Run `npm run build` to transpile and bundle static assets. @@ -59,15 +66,16 @@ I've been bad about cutting actual releases, so check this repo for recent commi ### Troubleshooting -* Debian, Ubuntu and RHEL-based distributions users can install latest `nodejs` from [NodeSource](https://github.com/nodesource/distributions). -* Ask for help in the [Flood Discord server](https://discord.gg/Z7yR5Uf). +- When you use `npm run start` to execute Flood, you have to pass command line arguments after `--`. For example, `npm run start -- --host 0.0.0.0 --port 8080`. +- Debian, Ubuntu and RHEL-based distributions users can install latest `nodejs` from [NodeSource](https://github.com/nodesource/distributions). +- Ask for help in the [Flood Discord server](https://discord.gg/Z7yR5Uf). ### Local Development 1. Run `npm install`. 2. Run `npm run start:development:server` and `npm run start:development:client` in separate terminal instances. - * `npm run start:development:server` uses [nodemon](https://github.com/remy/nodemon) to watch for changes to the server-side JavaScript. - * `npm run start:development:client` watches for changes in the client-side source. + - `npm run start:development:server` uses [nodemon](https://github.com/remy/nodemon) to watch for changes to the server-side JavaScript. + - `npm run start:development:client` watches for changes in the client-side source. 3. Access the UI in your browser. Defaults to `localhost:4200`. ### Environment Variables @@ -80,13 +88,13 @@ I've been bad about cutting actual releases, so check this repo for recent commi 1. `uuidgen > flood.secret` 2. `docker build -t rtorrent-flood .` -3. ``docker run --name rtorrent-flood -e FLOOD_SECRET=`cat flood.secret` -p 3000:3000 rtorrent-flood`` +3. `` docker run --name rtorrent-flood -e FLOOD_SECRET=`cat flood.secret` -p 3000:3000 rtorrent-flood `` 4. Other supported environment variables: - * `FLOOD_BASE_URI` - * `FLOOD_ENABLE_SSL` - * `FLOOD_DISABLE_AUTH` - * `RTORRENT_SCGI_HOST` - * `RTORRENT_SCGI_PORT` - * `RTORRENT_SOCK=true` + `RTORRENT_SOCK_PATH` + - `FLOOD_BASE_URI` + - `FLOOD_ENABLE_SSL` + - `FLOOD_DISABLE_AUTH` + - `RTORRENT_SCGI_HOST` + - `RTORRENT_SCGI_PORT` + - `RTORRENT_SOCK=true` + `RTORRENT_SOCK_PATH` -The docker container includes a volume at `/data`, which is where the database will be located. Additionally, you can place your SSL files there, `/data/flood_ssl.key` and `/data/flood_ssl.cert`. Set `FLOOD_ENABLE_SSL` to `true` to enable their use if present. Additionally, a local rtorrent socket file located at `/data/rtorrent.sock` can be used if `RTORRENT_SOCK` is set to `true`. The location of the socket file can be overrided by setting `RTORRENT_SOCK_PATH` to the path of the socket. +The docker container includes a volume at `/data`, which is where the database will be located. Additionally, you can place your SSL files there, `/data/flood_ssl.key` and `/data/flood_ssl.cert`. Set `FLOOD_ENABLE_SSL` to `true` to enable their use if present. Additionally, a local rtorrent socket file located at `/data/rtorrent.sock` can be used if `RTORRENT_SOCK` is set to `true`. The location of the socket file can be overrided by setting `RTORRENT_SOCK_PATH` to the path of the socket. diff --git a/config.js b/config.js new file mode 120000 index 00000000..2fd52e8c --- /dev/null +++ b/config.js @@ -0,0 +1 @@ +config.cli.js \ No newline at end of file diff --git a/package.json b/package.json index fb9103eb..a642329f 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "check-source-formatting": "node scripts/prettier.js check", "check-types": "tsc", "lint": "NODE_ENV=development eslint --max-warnings 0 . --ext .js --ext .jsx --ext .ts --ext .tsx", - "prepack": "rm -rf dist && cp config.cli.js config.js && npm run build", + "prepack": "rm -rf dist && npm run build", "start": "node --use_strict dist/server/bin/start.js", "start:development": "UPDATED_SCRIPT=start:development:server npm run deprecated-warning && npm run start:development:server", "start:development:client": "node client/scripts/start.js",