mirror of
https://github.com/unraid/api.git
synced 2026-01-18 14:39:39 -06:00
refactor: split myservers config into own cfg
This commit is contained in:
@@ -3,5 +3,6 @@ PATHS_STATES=$(pwd)/../core/test/fixtures/states
|
||||
PATHS_PLUGINS=$(pwd)/../core/test/fixtures/plugins
|
||||
PATHS_UNRAID_VERSION=$(pwd)/../core/test/fixtures/etc/unraid-version
|
||||
PATHS_DYNAMIX_CONFIG=$(pwd)/../core/test/fixtures/boot/config/plugins/dynamix/dynamix.cfg
|
||||
PATHS_MY_SERVERS_CONFIG=$(pwd)/../core/test/fixtures/boot/config/plugins/Unraid.net/myservers.cfg
|
||||
NCHAN=false
|
||||
PORT=5000
|
||||
@@ -29,7 +29,7 @@ Debug logs can be enabled via stdout while running with `start-debug`.
|
||||
## Playground
|
||||
|
||||
The playground can be access via `http://tower.local/graphql` while `PLAYGROUND=true` and `INTROSPECTION=true`. These values can be set in the `ecosystem.config.js` file in `/usr/local/bin/node/unraid-api`.
|
||||
To get your API key open a terminal on your server and run `cat /boot/config/plugins/dynamix/dynamix.cfg | grep apikey= | cut -d '"' -f2`. Add that api key in the "HTTP headers" panel of the playground.
|
||||
To get your API key open a terminal on your server and run `cat /boot/config/plugins/Unraid.net/myservers.cfg | grep apikey= | cut -d '"' -f2`. Add that api key in the "HTTP headers" panel of the playground.
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Written by: Alexis Tyler
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import chokidar from 'chokidar';
|
||||
import { EventEmitter } from 'events';
|
||||
import toMillisecond from 'ms';
|
||||
@@ -116,12 +117,11 @@ export class ApiManager extends EventEmitter {
|
||||
// Create singleton
|
||||
ApiManager.instance = this;
|
||||
|
||||
// Watch for changes to the dynamix.cfg file
|
||||
// Watch for changes to the myservers.cfg file
|
||||
// @todo Move API keys to their own file
|
||||
const basePath = paths.get('dynamix-base')!;
|
||||
const configPath = paths.get('dynamix-config')!;
|
||||
const configPath = paths.get('myservers-config')!;
|
||||
if (options.watch) {
|
||||
chokidar.watch(basePath, {
|
||||
chokidar.watch(path.basename(configPath), {
|
||||
ignoreInitial: true
|
||||
}).on('all', async (_eventName, filePath) => {
|
||||
if (filePath === configPath) {
|
||||
|
||||
@@ -16,6 +16,7 @@ export interface Paths {
|
||||
'emhttpd-socket': string;
|
||||
'dynamix-base': string;
|
||||
'dynamix-config': string;
|
||||
'myservers-config': string;
|
||||
'nginx-origin': string;
|
||||
'machine-id': string;
|
||||
}
|
||||
@@ -46,6 +47,7 @@ export const defaultPaths = new Map<keyof Paths, string>([
|
||||
['states', '/usr/local/emhttp/state/'],
|
||||
['dynamix-base', '/boot/config/plugins/dynamix/'],
|
||||
['dynamix-config', '/boot/config/plugins/dynamix/dynamix.cfg'],
|
||||
['myservers-config', '/boot/config/plugins/Unraid.net/myservers.cfg'],
|
||||
['nginx-origin', '/var/run/nginx.origin'],
|
||||
['machine-id', '/etc/machine-id']
|
||||
]);
|
||||
|
||||
@@ -8,6 +8,7 @@ const config = {
|
||||
PATHS_STATES: path.resolve(__dirname, './dev/states'),
|
||||
PATHS_DYNAMIX_BASE: path.resolve(__dirname, './dev/dynamix'),
|
||||
PATHS_DYNAMIX_CONFIG: path.resolve(__dirname, './dev/dynamix/dynamix.cfg'),
|
||||
PATHS_MY_SERVERS_CONFIG: path.resolve(__dirname, './dev/Unraid.net/myservers.cfg'),
|
||||
API_KEY: 'TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST'
|
||||
},
|
||||
files: [
|
||||
|
||||
11
dev/Unraid.net/myservers.cfg
Normal file
11
dev/Unraid.net/myservers.cfg
Normal file
@@ -0,0 +1,11 @@
|
||||
[remote]
|
||||
apikey="_______________________BIG_API_KEY_HERE_________________________"
|
||||
email="test@example.com"
|
||||
wanaccess="no"
|
||||
wanport="0"
|
||||
username="zspearmint"
|
||||
avatar="https://via.placeholder.com/200"
|
||||
regWizTime="1611175408732_0951-1653-3509-FBA155FA23C0"
|
||||
event="REG_WIZARD"
|
||||
keyfile="_____________________EVEN_BIGGER_KEY_HERE_________________________"
|
||||
license=""
|
||||
@@ -18,20 +18,6 @@ critical="90"
|
||||
hot="45"
|
||||
max="55"
|
||||
sysinfo="/Tools/SystemProfiler"
|
||||
[remote]
|
||||
apikey="TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST_TEST"
|
||||
wanaccess="yes"
|
||||
wanport="0"
|
||||
sshprivkey="-----BEGIN OPENSSH PRIVATE KEY-----
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
-----END OPENSSH PRIVATE KEY-----
|
||||
"
|
||||
sshpubkey="ssh-ed25519 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
"
|
||||
[notify]
|
||||
entity="1"
|
||||
normal="1"
|
||||
@@ -46,6 +32,4 @@ date="d-m-Y"
|
||||
time="H:i"
|
||||
position="top-right"
|
||||
path="/tmp/notifications"
|
||||
system="*/1 * * * *"
|
||||
[wizard]
|
||||
hideWizard="1"
|
||||
system="*/1 * * * *"
|
||||
Reference in New Issue
Block a user